summaryrefslogtreecommitdiff
path: root/src/Components/Ble
diff options
context:
space:
mode:
authorJF <jf@codingfield.com>2020-05-02 17:42:26 +0200
committerJF <jf@codingfield.com>2020-05-02 17:42:26 +0200
commited168716b5055d3efec9b30b1b1a3c7ef6c5b17d (patch)
tree292101a7d94db95d5e785de2d59fbdca57cada7f /src/Components/Ble
parent332b51464a75e40f2e306c50092735891acfe406 (diff)
Add Asssert & debug messages.
Diffstat (limited to 'src/Components/Ble')
-rw-r--r--src/Components/Ble/NimbleController.cpp21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/Components/Ble/NimbleController.cpp b/src/Components/Ble/NimbleController.cpp
index 02f99180..64ec379d 100644
--- a/src/Components/Ble/NimbleController.cpp
+++ b/src/Components/Ble/NimbleController.cpp
@@ -76,9 +76,14 @@ void NimbleController::Init() {
currentTimeClient.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() {
@@ -115,14 +120,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,
@@ -138,7 +143,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: {
@@ -161,7 +166,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. */
bleController.Disconnect();