From 40d45d923b033363ff1304b47eac238dd4495a57 Mon Sep 17 00:00:00 2001 From: Avamander Date: Sun, 18 Apr 2021 20:28:14 +0300 Subject: Reformatted all the files according to clang-format style --- src/components/ble/HeartRateService.cpp | 51 +++++++++++++-------------------- 1 file changed, 20 insertions(+), 31 deletions(-) (limited to 'src/components/ble/HeartRateService.cpp') diff --git a/src/components/ble/HeartRateService.cpp b/src/components/ble/HeartRateService.cpp index ee115ed0..c556566b 100644 --- a/src/components/ble/HeartRateService.cpp +++ b/src/components/ble/HeartRateService.cpp @@ -8,39 +8,29 @@ constexpr ble_uuid16_t HeartRateService::heartRateServiceUuid; constexpr ble_uuid16_t HeartRateService::heartRateMeasurementUuid; namespace { - int HeartRateServiceServiceCallback(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt *ctxt, void *arg) { + int HeartRateServiceServiceCallback(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt* ctxt, void* arg) { auto* heartRateService = static_cast(arg); return heartRateService->OnHeartRateRequested(conn_handle, attr_handle, ctxt); } } // TODO Refactoring - remove dependency to SystemTask -HeartRateService::HeartRateService(Pinetime::System::SystemTask &system, Controllers::HeartRateController& heartRateController) : - system{system}, - heartRateController{heartRateController}, - characteristicDefinition{ - { - .uuid = (ble_uuid_t *) &heartRateMeasurementUuid, - .access_cb = HeartRateServiceServiceCallback, - .arg = this, - .flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_NOTIFY, - .val_handle = &heartRateMeasurementHandle - }, - { - 0 - } - }, - serviceDefinition{ - { - /* Device Information Service */ - .type = BLE_GATT_SVC_TYPE_PRIMARY, - .uuid = (ble_uuid_t *) &heartRateServiceUuid, - .characteristics = characteristicDefinition - }, - { - 0 - }, - }{ +HeartRateService::HeartRateService(Pinetime::System::SystemTask& system, Controllers::HeartRateController& heartRateController) + : system {system}, + heartRateController {heartRateController}, + characteristicDefinition {{.uuid = (ble_uuid_t*) &heartRateMeasurementUuid, + .access_cb = HeartRateServiceServiceCallback, + .arg = this, + .flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_NOTIFY, + .val_handle = &heartRateMeasurementHandle}, + {0}}, + serviceDefinition { + {/* Device Information Service */ + .type = BLE_GATT_SVC_TYPE_PRIMARY, + .uuid = (ble_uuid_t*) &heartRateServiceUuid, + .characteristics = characteristicDefinition}, + {0}, + } { // TODO refactor to prevent this loop dependency (service depends on controller and controller depends on service) heartRateController.SetService(this); } @@ -54,9 +44,8 @@ void HeartRateService::Init() { ASSERT(res == 0); } -int HeartRateService::OnHeartRateRequested(uint16_t connectionHandle, uint16_t attributeHandle, - ble_gatt_access_ctxt *context) { - if(attributeHandle == heartRateMeasurementHandle) { +int HeartRateService::OnHeartRateRequested(uint16_t connectionHandle, uint16_t attributeHandle, ble_gatt_access_ctxt* context) { + if (attributeHandle == heartRateMeasurementHandle) { NRF_LOG_INFO("HEARTRATE : handle = %d", heartRateMeasurementHandle); uint8_t buffer[2] = {0, heartRateController.HeartRate()}; // [0] = flags, [1] = hr value @@ -68,7 +57,7 @@ int HeartRateService::OnHeartRateRequested(uint16_t connectionHandle, uint16_t a void HeartRateService::OnNewHeartRateValue(uint8_t heartRateValue) { uint8_t buffer[2] = {0, heartRateController.HeartRate()}; // [0] = flags, [1] = hr value - auto *om = ble_hs_mbuf_from_flat(buffer, 2); + auto* om = ble_hs_mbuf_from_flat(buffer, 2); uint16_t connectionHandle = system.nimble().connHandle(); -- cgit v1.2.3