Nano RGB LED mesh

Dependencies:   nrf51-sdk

Dependents:   BLENano_Mesh

Fork of nRF51822 by Nordic Semiconductor

Revision:
463:b869f947a37a
Parent:
461:1f352d938a33
Child:
475:fe3d08b3a8e9
diff -r ed195faa45b1 -r b869f947a37a source/nRF5xn.cpp
--- a/source/nRF5xn.cpp	Mon Nov 02 17:34:04 2015 +0000
+++ b/source/nRF5xn.cpp	Tue Nov 03 12:45:21 2015 +0000
@@ -77,12 +77,14 @@
     return versionString;
 }
 
-ble_error_t nRF5xn::init(BLE::InstanceID_t instanceID, BLE::InitializationCompleteCallback_t callback)
+ble_error_t nRF5xn::init(BLE::InstanceID_t instanceID, FunctionPointerWithContext<BLE::InitializationCompleteCallbackContext *> callback)
 {
     if (initialized) {
-        if (callback) {
-            callback(BLE::Instance(instanceID), BLE_ERROR_ALREADY_INITIALIZED);
-        }
+        BLE::InitializationCompleteCallbackContext context = {
+            BLE::Instance(instanceID),
+            BLE_ERROR_ALREADY_INITIALIZED
+        };
+        callback.call(&context);
         return BLE_ERROR_ALREADY_INITIALIZED;
     }
 
@@ -92,9 +94,11 @@
     btle_init();
 
     initialized = true;
-    if (callback) {
-        callback(BLE::Instance(instanceID), BLE_ERROR_NONE);
-    }
+    BLE::InitializationCompleteCallbackContext context = {
+        BLE::Instance(instanceID),
+        BLE_ERROR_NONE
+    };
+    callback.call(&context);
     return BLE_ERROR_NONE;
 }