Skip to content

Commit

Permalink
⚡ (ble): Callback on Apply Update Characteristic set in Update Service
Browse files Browse the repository at this point in the history
  • Loading branch information
YannLocatelli committed Mar 25, 2022
1 parent e5a258d commit 846432d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions libs/BLEKit/include/BLEServiceUpdate.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ class BLEServiceUpdate : public interface::BLEService
{
if (params.handle == apply_update_characteristic.getValueHandle()) {
apply_update_value = static_cast<bool>(params.data[0]);
if (apply_update_value && _on_apply_update_true) {
_on_apply_update_true();
}
}
if (params.handle == version_major_characteristic.getValueHandle()) {
version.major = params.data[0];
Expand All @@ -35,10 +38,13 @@ class BLEServiceUpdate : public interface::BLEService
}
};

void onApplyUpdateTrue(std::function<void()> callback) { _on_apply_update_true = callback; }

private:
bool apply_update_value {false};
WriteOnlyGattCharacteristic<bool> apply_update_characteristic {
service::firmware_update::characteristic::apply_update, &apply_update_value};
std::function<void()> _on_apply_update_true {};

FirmwareVersion version {};

Expand Down

0 comments on commit 846432d

Please sign in to comment.