diff options
author | Jean-François Milants <jf@codingfield.com> | 2021-10-17 08:23:01 +0200 |
---|---|---|
committer | Jean-François Milants <jf@codingfield.com> | 2021-10-17 08:23:01 +0200 |
commit | d1f50157c7e0c471ae0e260fdca82fc472635079 (patch) | |
tree | 5ff50524ec689b5472d04405fd54a983161ff04d /src/components/ble/NimbleController.cpp | |
parent | bf83493c8db1ef8afab34a10d0253c0208304484 (diff) |
MotionService : fix typo and characteristic array size + send notification only if the host subscribed to them.
Diffstat (limited to 'src/components/ble/NimbleController.cpp')
-rw-r--r-- | src/components/ble/NimbleController.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/components/ble/NimbleController.cpp b/src/components/ble/NimbleController.cpp index 879421e7..931c3ae1 100644 --- a/src/components/ble/NimbleController.cpp +++ b/src/components/ble/NimbleController.cpp @@ -215,6 +215,16 @@ 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: |