Nordic stack and drivers for the mbed BLE API

Dependents:   BLE_ANCS_SDAPI BLE_temperature BLE_HeartRate writable_gatt ... more

Files at this revision

API Documentation at this revision

Comitter:
vcoubard
Date:
Mon Jan 11 10:19:29 2016 +0000
Parent:
585:3775ab44cb4a
Child:
587:596071444447
Commit message:
Synchronized with git rev 7f02a2d5
Author: Andres Amaya Garcia
Add check for return code of ble_init

Changed in this revision

source/btle/btle.cpp Show annotated file Show diff for this revision Revisions of this file
source/nRF5xn.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/source/btle/btle.cpp	Mon Jan 11 10:19:28 2016 +0000
+++ b/source/btle/btle.cpp	Mon Jan 11 10:19:29 2016 +0000
@@ -118,9 +118,7 @@
     ASSERT_STATUS( softdevice_ble_evt_handler_set(btle_handler));
     ASSERT_STATUS( softdevice_sys_evt_handler_set(sys_evt_dispatch));
 
-    btle_gap_init();
-
-    return ERROR_NONE;
+    return btle_gap_init();
 }
 
 static void btle_handler(ble_evt_t *p_ble_evt)
--- a/source/nRF5xn.cpp	Mon Jan 11 10:19:28 2016 +0000
+++ b/source/nRF5xn.cpp	Mon Jan 11 10:19:29 2016 +0000
@@ -95,6 +95,20 @@
     return versionString;
 }
 
+/**************************************************************************/
+/*!
+    @brief  Initialize the BLE stack.
+
+    @returns    ble_error_t
+
+    @retval     BLE_ERROR_NONE if everything executed properly and
+                BLE_ERROR_ALREADY_INITIALIZED if the stack has already
+                been initialized (possibly through a call to nRF5xn::init().
+                BLE_ERROR_INTERNAL_STACK_FAILURE is returned if initialization
+                of the internal stack (SoftDevice) failed.
+
+*/
+/**************************************************************************/
 ble_error_t nRF5xn::init(BLE::InstanceID_t instanceID, FunctionPointerWithContext<BLE::InitializationCompleteCallbackContext *> callback)
 {
     if (initialized) {
@@ -109,7 +123,9 @@
     instanceID   = instanceID;
 
     /* ToDo: Clear memory contents, reset the SD, etc. */
-    btle_init();
+    if (btle_init() != ERROR_NONE) {
+        return BLE_ERROR_INTERNAL_STACK_FAILURE;
+    }
 
     initialized = true;
     BLE::InitializationCompleteCallbackContext context = {