summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJF <jf@codingfield.com>2020-05-16 15:30:54 +0200
committerJF <jf@codingfield.com>2020-05-16 15:30:54 +0200
commit56fba1c242eac45e3fde0a98602429ee95bf31c0 (patch)
tree282bc9c4d8e7837b134b0996079d0759dfa93ccf
parentc55dd06f1a1eba05229a064085a3d84acd14187c (diff)
parented168716b5055d3efec9b30b1b1a3c7ef6c5b17d (diff)
Merge branch 'nimble' of git.proxmox3:JF/PineTime into nimble
-rw-r--r--src/Components/Ble/NimbleController.cpp21
-rw-r--r--src/main.cpp7
2 files changed, 18 insertions, 10 deletions
diff --git a/src/Components/Ble/NimbleController.cpp b/src/Components/Ble/NimbleController.cpp
index 826d255b..172bcb9f 100644
--- a/src/Components/Ble/NimbleController.cpp
+++ b/src/Components/Ble/NimbleController.cpp
@@ -82,9 +82,14 @@ void NimbleController::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() {
@@ -121,14 +126,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,
@@ -144,7 +149,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: {
@@ -167,7 +172,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();
diff --git a/src/main.cpp b/src/main.cpp
index 7c5eaf7c..e0e9b65e 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -184,8 +184,11 @@ void nimble_port_init(void) {
ble_hs_init();
ble_store_ram_init();
- hal_timer_init(5, NULL);
- os_cputime_init(32768);
+ int res;
+ res = hal_timer_init(5, NULL);
+ ASSERT(res == 0);
+ res = os_cputime_init(32768);
+ ASSERT(res == 0);
ble_ll_init();
ble_hci_ram_init();
nimble_port_freertos_init(BleHost);