diff options
author | JF <jf@codingfield.com> | 2020-05-01 21:58:31 +0200 |
---|---|---|
committer | JF <jf@codingfield.com> | 2020-05-01 21:58:31 +0200 |
commit | 87c6556ad049077ab14398637031ea029b321baf (patch) | |
tree | 55fbc74c2ea30425a5def6deab44433581445958 /src/Components/Ble/NimbleController.cpp | |
parent | 56b527925ce64bc0a9ef4b0ca51a1648b6400e04 (diff) |
Defer the discovery of services using the system task.
Diffstat (limited to 'src/Components/Ble/NimbleController.cpp')
-rw-r--r-- | src/Components/Ble/NimbleController.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/Components/Ble/NimbleController.cpp b/src/Components/Ble/NimbleController.cpp index ccb1e6ad..f3d271ec 100644 --- a/src/Components/Ble/NimbleController.cpp +++ b/src/Components/Ble/NimbleController.cpp @@ -73,7 +73,6 @@ void NimbleController::Init() { ble_svc_gatt_init(); deviceInformationService.Init(); -// currentTimeClient.Init(); dfuService.Init(); int res; res = ble_hs_util_ensure_addr(0); @@ -156,8 +155,9 @@ int NimbleController::OnGAPEvent(ble_gap_event *event) { bleController.Disconnect(); } else { bleController.Connect(); + systemTask.PushMessage(Pinetime::System::SystemTask::Messages::BleConnected); connectionHandle = event->connect.conn_handle; -// ble_gattc_disc_all_svcs(connectionHandle, OnAllSvrDisco, this); + // Service discovery is deffered via systemtask } } break; @@ -166,6 +166,7 @@ int NimbleController::OnGAPEvent(ble_gap_event *event) { NRF_LOG_INFO("disconnect; reason=%d ", event->disconnect.reason); /* Connection terminated; resume advertising. */ + connectionHandle = BLE_HS_CONN_HANDLE_NONE; bleController.Disconnect(); StartAdvertising(); break; @@ -248,7 +249,6 @@ int NimbleController::OnDiscoveryEvent(uint16_t i, const ble_gatt_error *error, ble_gattc_disc_all_chrs(connectionHandle, alertNotificationClient.StartHandle(), alertNotificationClient.EndHandle(), AlertNotificationCharacteristicDiscoveredCallback, this); } - return 0; } alertNotificationClient.OnDiscoveryEvent(i, error, service); @@ -295,6 +295,10 @@ int NimbleController::OnANSDescriptorDiscoveryEventCallback(uint16_t connectionH return alertNotificationClient.OnDescriptorDiscoveryEventCallback(connectionHandle, error, characteristicValueHandle, descriptor); } +void NimbleController::StartDiscovery() { + ble_gattc_disc_all_svcs(connectionHandle, OnAllSvrDisco, this); +} + |