diff options
| author | JF <jf@codingfield.com> | 2020-05-02 17:48:59 +0200 |
|---|---|---|
| committer | JF <jf@codingfield.com> | 2020-05-02 17:48:59 +0200 |
| commit | 66caada0d2da7731a0d08b0dadcf3ae05d2d41e5 (patch) | |
| tree | dbaaaf34d4ac8a52c2fbc8a621d56f2743698f2a /src/Components/Ble/NimbleController.cpp | |
| parent | 40e3ac61bd4256645ed40273f2762caea9e85b97 (diff) | |
| parent | ed168716b5055d3efec9b30b1b1a3c7ef6c5b17d (diff) | |
Merge branch 'nimble' into nimble-ota
Diffstat (limited to 'src/Components/Ble/NimbleController.cpp')
| -rw-r--r-- | src/Components/Ble/NimbleController.cpp | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/Components/Ble/NimbleController.cpp b/src/Components/Ble/NimbleController.cpp index f16d8af0..23bd3e2f 100644 --- a/src/Components/Ble/NimbleController.cpp +++ b/src/Components/Ble/NimbleController.cpp @@ -77,9 +77,14 @@ void NimbleController::Init() { dfuService.Init(); int res; res = ble_hs_util_ensure_addr(0); + ASSERT(res == 0); res = ble_hs_id_infer_auto(0, &addrType); + ASSERT(res == 0); res = ble_svc_gap_device_name_set(deviceName); - ble_gatts_start(); + + ASSERT(res == 0); + res = ble_gatts_start(); + ASSERT(res == 0); } void NimbleController::StartAdvertising() { @@ -117,14 +122,14 @@ void NimbleController::StartAdvertising() { int res; res = ble_gap_adv_set_fields(&fields); - assert(res == 0); + ASSERT(res == 0); - ble_gap_adv_rsp_set_fields(&rsp_fields); + res = ble_gap_adv_rsp_set_fields(&rsp_fields); + ASSERT(res == 0); - ble_gap_adv_start(addrType, NULL, 10000, + res = ble_gap_adv_start(addrType, NULL, 10000, &adv_params, GAPEventCallback, this); - - + ASSERT(res == 0); } int OnAllSvrDisco(uint16_t conn_handle, @@ -140,7 +145,7 @@ int NimbleController::OnGAPEvent(ble_gap_event *event) { switch (event->type) { case BLE_GAP_EVENT_ADV_COMPLETE: NRF_LOG_INFO("Advertising event : BLE_GAP_EVENT_ADV_COMPLETE"); - NRF_LOG_INFO("advertise complete; reason=%d", event->adv_complete.reason); + NRF_LOG_INFO("advertise complete; reason=%dn status=%d", event->adv_complete.reason, event->connect.status); StartAdvertising(); break; case BLE_GAP_EVENT_CONNECT: { @@ -164,7 +169,7 @@ int NimbleController::OnGAPEvent(ble_gap_event *event) { break; case BLE_GAP_EVENT_DISCONNECT: NRF_LOG_INFO("Advertising event : BLE_GAP_EVENT_DISCONNECT"); - NRF_LOG_INFO("disconnect; reason=%d ", event->disconnect.reason); + NRF_LOG_INFO("disconnect; reason=%d", event->disconnect.reason); /* Connection terminated; resume advertising. */ connectionHandle = BLE_HS_CONN_HANDLE_NONE; |
