diff options
| author | Avamander <avamander@gmail.com> | 2021-04-18 17:28:14 (GMT) |
|---|---|---|
| committer | Avamander <avamander@gmail.com> | 2021-04-24 08:39:53 (GMT) |
| commit | 40d45d923b033363ff1304b47eac238dd4495a57 (patch) | |
| tree | 9e7b668fdf23a7be892b8e2bf8b4d62b884cee06 /src/components/ble/BatteryInformationService.cpp | |
| parent | e56ebb8bd621cc8838e86fa032d680a6e7a35ffc (diff) | |
Reformatted all the files according to clang-format style
Diffstat (limited to 'src/components/ble/BatteryInformationService.cpp')
| -rw-r--r-- | src/components/ble/BatteryInformationService.cpp | 52 |
1 files changed, 20 insertions, 32 deletions
diff --git a/src/components/ble/BatteryInformationService.cpp b/src/components/ble/BatteryInformationService.cpp index bc66ff7..10a78d6 100644 --- a/src/components/ble/BatteryInformationService.cpp +++ b/src/components/ble/BatteryInformationService.cpp @@ -7,39 +7,26 @@ using namespace Pinetime::Controllers; constexpr ble_uuid16_t BatteryInformationService::batteryInformationServiceUuid; constexpr ble_uuid16_t BatteryInformationService::batteryLevelUuid; - - -int BatteryInformationServiceCallback(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt *ctxt, void *arg) { +int BatteryInformationServiceCallback(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt* ctxt, void* arg) { auto* batteryInformationService = static_cast<BatteryInformationService*>(arg); return batteryInformationService->OnBatteryServiceRequested(conn_handle, attr_handle, ctxt); } -BatteryInformationService::BatteryInformationService(Controllers::Battery& batteryController) : - batteryController{batteryController}, - characteristicDefinition{ - { - .uuid = (ble_uuid_t *) &batteryLevelUuid, - .access_cb = BatteryInformationServiceCallback, - .arg = this, - .flags = BLE_GATT_CHR_F_READ, - .val_handle = &batteryLevelHandle - }, - { - 0 - } - }, - serviceDefinition{ - { - /* Device Information Service */ - .type = BLE_GATT_SVC_TYPE_PRIMARY, - .uuid = (ble_uuid_t *) &batteryInformationServiceUuid, - .characteristics = characteristicDefinition - }, - { - 0 - }, - }{ - +BatteryInformationService::BatteryInformationService(Controllers::Battery& batteryController) + : batteryController {batteryController}, + characteristicDefinition {{.uuid = (ble_uuid_t*) &batteryLevelUuid, + .access_cb = BatteryInformationServiceCallback, + .arg = this, + .flags = BLE_GATT_CHR_F_READ, + .val_handle = &batteryLevelHandle}, + {0}}, + serviceDefinition { + {/* Device Information Service */ + .type = BLE_GATT_SVC_TYPE_PRIMARY, + .uuid = (ble_uuid_t*) &batteryInformationServiceUuid, + .characteristics = characteristicDefinition}, + {0}, + } { } void BatteryInformationService::Init() { @@ -51,9 +38,10 @@ void BatteryInformationService::Init() { ASSERT(res == 0); } -int BatteryInformationService::OnBatteryServiceRequested(uint16_t connectionHandle, uint16_t attributeHandle, - ble_gatt_access_ctxt *context) { - if(attributeHandle == batteryLevelHandle) { +int BatteryInformationService::OnBatteryServiceRequested(uint16_t connectionHandle, + uint16_t attributeHandle, + ble_gatt_access_ctxt* context) { + if (attributeHandle == batteryLevelHandle) { NRF_LOG_INFO("BATTERY : handle = %d", batteryLevelHandle); static uint8_t batteryValue = batteryController.PercentRemaining(); int res = os_mbuf_append(context->om, &batteryValue, 1); |
