From a1c3cc04dc94d80c6e7c50e2ef2f8abe795f3fdb Mon Sep 17 00:00:00 2001 From: hathach Date: Thu, 16 Mar 2017 16:00:52 +0700 Subject: [PATCH] clean up --- cores/nRF5/debug.cpp | 7 +++- libraries/Bluefruit52Lib/src/BLECentral.h | 5 +++ libraries/Bluefruit52Lib/src/bluefruit.cpp | 42 +--------------------- 3 files changed, 12 insertions(+), 42 deletions(-) diff --git a/cores/nRF5/debug.cpp b/cores/nRF5/debug.cpp index 0220e64c..30009ffe 100644 --- a/cores/nRF5/debug.cpp +++ b/cores/nRF5/debug.cpp @@ -213,6 +213,8 @@ static const char* _gatts_evt_str[] = const char* dbg_ble_event_str(uint16_t evt_id) { + static char unknown_evt[7] = {0}; + if ( is_within(BLE_EVT_BASE, evt_id, BLE_EVT_LAST) ) return _base_evt_str[evt_id-BLE_EVT_BASE]; else if ( is_within(BLE_GAP_EVT_BASE, evt_id, BLE_GAP_EVT_LAST) ) @@ -222,7 +224,10 @@ const char* dbg_ble_event_str(uint16_t evt_id) else if ( is_within(BLE_GATTS_EVT_BASE, evt_id, BLE_GATTS_EVT_LAST) ) return _gatts_evt_str[evt_id-BLE_GATTS_EVT_BASE]; else - return NULL; + { + sprintf(unknown_evt, "0x04X", evt_id); + return unknown_evt; + } } #endif diff --git a/libraries/Bluefruit52Lib/src/BLECentral.h b/libraries/Bluefruit52Lib/src/BLECentral.h index 0640c9b7..8474e6ca 100644 --- a/libraries/Bluefruit52Lib/src/BLECentral.h +++ b/libraries/Bluefruit52Lib/src/BLECentral.h @@ -78,6 +78,11 @@ class BLECentral bool connected(void); + /*------------------------------------------------------------------*/ + /* GATTC Discovery + *------------------------------------------------------------------*/ + + typedef void (*connect_callback_t) (void); typedef void (*disconnect_callback_t) (uint8_t reason); diff --git a/libraries/Bluefruit52Lib/src/bluefruit.cpp b/libraries/Bluefruit52Lib/src/bluefruit.cpp index e144da49..27042b4a 100644 --- a/libraries/Bluefruit52Lib/src/bluefruit.cpp +++ b/libraries/Bluefruit52Lib/src/bluefruit.cpp @@ -168,19 +168,6 @@ err_t AdafruitBluefruit::begin(bool prph_enable, bool central_enable) VERIFY_STATUS( sd_ble_enable(¶ms, &app_ram_base) ); -#if 0 - // Configure Radio inactive interrupt to use with hardtime-critical function - // such as Neopixel show() - s_radio_inactive_sem = xSemaphoreCreateBinary(); - VERIFY(s_radio_inactive_sem, NRF_ERROR_NO_MEM); - - NVIC_ClearPendingIRQ(RADIO_NOTIFICATION_IRQn); - NVIC_SetPriority(SD_EVT_IRQn, 7); -// NVIC_EnableIRQ(RADIO_NOTIFICATION_IRQn); - - VERIFY_STATUS( sd_radio_notification_cfg_set(NRF_RADIO_NOTIFICATION_TYPE_INT_ON_INACTIVE, 0) ); -#endif - /*------------- Configure GAP -------------*/ // Peripheral Preferred Connection Parameters @@ -392,30 +379,6 @@ void AdafruitBluefruit::stopConnLed(void) /*------------------------------------------------------------------*/ /* Thread & SoftDevice Event handler *------------------------------------------------------------------*/ -#if 0 -void RADIO_NOTIFICATION_IRQHandler(void) -{ -// PRINT_LOCATION(); - xSemaphoreGiveFromISR(s_radio_inactive_sem, NULL); -} - -void waitForRadioInactive(void) -{ -// bool radio_inactive = xSemaphoreTake(s_radio_inactive_sem, 0); -// PRINT_INT(radio_inactive); - -// NVIC_ClearPendingIRQ(RADIO_NOTIFICATION_IRQn); -// NVIC_EnableIRQ(RADIO_NOTIFICATION_IRQn); - -// // wait forever -// delay(100); -// radio_inactive = xSemaphoreTake(s_radio_inactive_sem, 0); -// -// PRINT_INT(radio_inactive); -// NVIC_DisableIRQ(RADIO_NOTIFICATION_IRQn); -} -#endif - void SD_EVT_IRQHandler(void) { // Notify both BLE & SOC Task @@ -492,10 +455,7 @@ void AdafruitBluefruit::_ble_handler(void) if( ERROR_NONE == err) { #if CFG_DEBUG - Serial.print("[BLE]: "); - if ( dbg_ble_event_str(evt->header.evt_id) ) Serial.print(dbg_ble_event_str(evt->header.evt_id)); - else Serial.printf("0x04X", evt->header.evt_id); - Serial.println(); + Serial.printf("[BLE]: %s\n", dbg_ble_event_str(evt->header.evt_id)); #endif switch ( evt->header.evt_id )