Nano RGB LED mesh

Dependencies:   nrf51-sdk

Dependents:   BLENano_Mesh

Fork of nRF51822 by Nordic Semiconductor

Revision:
458:b42881afcc6e
Parent:
403:92d6b4c7bf14
Child:
459:98c44deafc70
--- a/source/nRF5xn.cpp	Mon Nov 02 09:05:11 2015 +0000
+++ b/source/nRF5xn.cpp	Mon Nov 02 09:05:11 2015 +0000
@@ -38,7 +38,7 @@
     return (&deviceInstance);
 }
 
-nRF5xn::nRF5xn(void)
+nRF5xn::nRF5xn(void) : initialized(false), instanceID(BLE::DEFAULT_INSTANCE)
 {
 }
 
@@ -72,11 +72,24 @@
     return versionString;
 }
 
-ble_error_t nRF5xn::init(void)
+ble_error_t nRF5xn::init(BLE::InstanceID_t instanceID, BLE::InitializationCompleteCallback_t callback)
 {
+    if (initialized) {
+        if (callback) {
+            callback(BLE::Instance(instanceID), BLE_ERROR_ALREADY_INITIALIZED);
+        }
+        return BLE_ERROR_ALREADY_INITIALIZED;
+    }
+
+    instanceID   = instanceID;
+
     /* ToDo: Clear memory contents, reset the SD, etc. */
     btle_init();
 
+    initialized = true;
+    if (callback) {
+        callback(BLE::Instance(instanceID), BLE_ERROR_NONE);
+    }
     return BLE_ERROR_NONE;
 }