From 5580ac82002b3918311fc1d2e15fc1fdb8369f00 Mon Sep 17 00:00:00 2001 From: Glenn Ruben Bakke Date: Sun, 12 Mar 2017 22:46:40 +0100 Subject: [PATCH] nrf5/bluetooth: Adding more implementation in scan start function. However, commented out for time beeing, as there is some memory issues when activating central. --- nrf5/bluetooth/ble_drv.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/nrf5/bluetooth/ble_drv.c b/nrf5/bluetooth/ble_drv.c index 5792b69f12..7ee2037b18 100644 --- a/nrf5/bluetooth/ble_drv.c +++ b/nrf5/bluetooth/ble_drv.c @@ -36,7 +36,7 @@ #include "ble.h" // sd_ble_uuid_encode -#define BLE_DRIVER_VERBOSE 1 +#define BLE_DRIVER_VERBOSE 0 #if BLE_DRIVER_VERBOSE #define BLE_DRIVER_LOG printf #else @@ -664,6 +664,9 @@ void ble_drv_gatts_event_handler_set(mp_obj_t obj, ubluepy_gatts_evt_callback_t #if (BLUETOOTH_SD == 130) || (BLUETOOTH_SD == 132) void ble_drv_scan_start(void) { +#if 0 + SD_TEST_OR_ENABLE(); + ble_gap_scan_params_t scan_params; scan_params.active = 1; scan_params.interval = MSEC_TO_UNITS(100, UNIT_0_625_MS); @@ -671,13 +674,18 @@ void ble_drv_scan_start(void) { scan_params.timeout = 0; // Infinite #if (BLUETOOTH_SD == 130) - scan_params.selective = 0, - scan_params.p_whitelist = NULL, + scan_params.selective = 0; + scan_params.p_whitelist = NULL; #else - scan_params.use_whitelist = 0, + scan_params.use_whitelist = 0; #endif - sd_ble_gap_scan_start(&scan_params); + uint32_t err_code; + if ((err_code = sd_ble_gap_scan_start(&scan_params)) != 0) { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, + "Can not start scanning. status: 0x" HEX2_FMT, (uint16_t)err_code)); + } +#endif // 0 } void ble_drv_scan_stop(void) {