summaryrefslogtreecommitdiff
path: root/src/components/ble/HeartRateService.cpp
diff options
context:
space:
mode:
authorAvamander <avamander@gmail.com>2021-04-18 20:28:14 +0300
committerAvamander <avamander@gmail.com>2021-04-24 11:39:53 +0300
commit40d45d923b033363ff1304b47eac238dd4495a57 (patch)
tree9e7b668fdf23a7be892b8e2bf8b4d62b884cee06 /src/components/ble/HeartRateService.cpp
parente56ebb8bd621cc8838e86fa032d680a6e7a35ffc (diff)
Reformatted all the files according to clang-format style
Diffstat (limited to 'src/components/ble/HeartRateService.cpp')
-rw-r--r--src/components/ble/HeartRateService.cpp51
1 files changed, 20 insertions, 31 deletions
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<HeartRateService*>(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();