diff options
| author | Michele Bini <michele.bini@gmail.com> | 2022-03-30 20:50:42 (GMT) |
|---|---|---|
| committer | Michele Bini <michele.bini@gmail.com> | 2022-03-30 20:50:42 (GMT) |
| commit | 5db030547eeb0aae422447ddb63f0bd2f9d5f384 (patch) | |
| tree | 648bdc9654a3d826eaef1cefaa4b329495016569 /src/components/ble/NimbleController.cpp | |
| parent | e1cb4f64097a7d084f178f762546cecb5bd3c6be (diff) | |
Revert "sans heart"ultraredux-heart
This reverts commit 6ef420d2407a4685b56a233f6b0f849e90c6cf49.
Diffstat (limited to 'src/components/ble/NimbleController.cpp')
| -rw-r--r-- | src/components/ble/NimbleController.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/components/ble/NimbleController.cpp b/src/components/ble/NimbleController.cpp index f63d98c..bc712f4 100644 --- a/src/components/ble/NimbleController.cpp +++ b/src/components/ble/NimbleController.cpp @@ -27,7 +27,8 @@ NimbleController::NimbleController(Pinetime::System::SystemTask& systemTask, DateTime& dateTimeController, NotificationManager& notificationManager, Battery& batteryController, - Pinetime::Drivers::SpiNorFlash& spiNorFlash + Pinetime::Drivers::SpiNorFlash& spiNorFlash, + HeartRateController& heartRateController ) : systemTask {systemTask}, bleController {bleController}, @@ -42,6 +43,7 @@ NimbleController::NimbleController(Pinetime::System::SystemTask& systemTask, currentTimeService {dateTimeController}, batteryInformationService {batteryController}, immediateAlertService {systemTask, notificationManager}, + heartRateService {systemTask, heartRateController}, serviceDiscovery({¤tTimeClient, &alertNotificationClient}) { } @@ -84,6 +86,7 @@ void NimbleController::Init() { dfuService.Init(); batteryInformationService.Init(); immediateAlertService.Init(); + heartRateService.Init(); int rc; rc = ble_hs_util_ensure_addr(0); @@ -240,6 +243,14 @@ int NimbleController::OnGAPEvent(ble_gap_event* event) { event->subscribe.prev_notify, event->subscribe.cur_notify, event->subscribe.prev_indicate); + + if (event->subscribe.reason == BLE_GAP_SUBSCRIBE_REASON_TERM) { + heartRateService.UnsubscribeNotification(event->subscribe.conn_handle, event->subscribe.attr_handle); + } else if (event->subscribe.prev_notify == 0 && event->subscribe.cur_notify == 1) { + heartRateService.SubscribeNotification(event->subscribe.conn_handle, event->subscribe.attr_handle); + } else if (event->subscribe.prev_notify == 1 && event->subscribe.cur_notify == 0) { + heartRateService.UnsubscribeNotification(event->subscribe.conn_handle, event->subscribe.attr_handle); + } break; case BLE_GAP_EVENT_MTU: |
