diff options
author | Riku Isokoski <riksu9000@gmail.com> | 2021-07-13 22:11:46 +0300 |
---|---|---|
committer | Riku Isokoski <riksu9000@gmail.com> | 2021-07-13 22:11:46 +0300 |
commit | b5eabf6604734e40caa4a3ccbbd8aa9e9dfa7ced (patch) | |
tree | 2cf14c70a8b28dd1691a7583c3b38405682f1c61 /src/components/ble/BatteryInformationService.cpp | |
parent | 7efe2b7c51e1d21305154edad6ddf1b608784451 (diff) | |
parent | a07b6382aef3c30d8ea8f28fcc3cc880d7afd747 (diff) |
Merge branch 'develop' into fix_adc
Diffstat (limited to 'src/components/ble/BatteryInformationService.cpp')
-rw-r--r-- | src/components/ble/BatteryInformationService.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/components/ble/BatteryInformationService.cpp b/src/components/ble/BatteryInformationService.cpp index 10a78d67..7f176904 100644 --- a/src/components/ble/BatteryInformationService.cpp +++ b/src/components/ble/BatteryInformationService.cpp @@ -17,7 +17,7 @@ BatteryInformationService::BatteryInformationService(Controllers::Battery& batte characteristicDefinition {{.uuid = (ble_uuid_t*) &batteryLevelUuid, .access_cb = BatteryInformationServiceCallback, .arg = this, - .flags = BLE_GATT_CHR_F_READ, + .flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_NOTIFY, .val_handle = &batteryLevelHandle}, {0}}, serviceDefinition { @@ -48,4 +48,8 @@ int BatteryInformationService::OnBatteryServiceRequested(uint16_t connectionHand return (res == 0) ? 0 : BLE_ATT_ERR_INSUFFICIENT_RES; } return 0; -}
\ No newline at end of file +} +void BatteryInformationService::NotifyBatteryLevel(uint16_t connectionHandle, uint8_t level) { + auto* om = ble_hs_mbuf_from_flat(&level, 1); + ble_gattc_notify_custom(connectionHandle, batteryLevelHandle, om); +} |