sa

Fork of nRF51822 by Nordic Semiconductor

Files at this revision

API Documentation at this revision

Comitter:
rgrover1
Date:
Tue Nov 03 12:45:21 2015 +0000
Parent:
462:ed195faa45b1
Child:
464:bf85bf7e73d5
Commit message:
Synchronized with git rev 6b763c87
Author: Rohit Grover
bring in the latest changes for BLE::init() where we allow <object, member> tuples for init callback.

Changed in this revision

source/nRF5xn.cpp Show annotated file Show diff for this revision Revisions of this file
source/nRF5xn.h Show annotated file Show diff for this revision Revisions of this file
--- 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;
 }
 
--- a/source/nRF5xn.h	Mon Nov 02 17:34:04 2015 +0000
+++ b/source/nRF5xn.h	Tue Nov 03 12:45:21 2015 +0000
@@ -34,7 +34,7 @@
     nRF5xn(void);
     virtual ~nRF5xn(void);
 
-    virtual ble_error_t init(BLE::InstanceID_t instanceID, BLE::InitializationCompleteCallback_t);
+    virtual ble_error_t init(BLE::InstanceID_t instanceID, FunctionPointerWithContext<BLE::InitializationCompleteCallbackContext *> callback);
     virtual bool        hasInitialized(void) const {
         return initialized;
     }