diff --git a/source/nRF5xn.cpp b/source/nRF5xn.cpp index edfa54b..45393fe 100644 --- a/source/nRF5xn.cpp +++ b/source/nRF5xn.cpp @@ -33,7 +33,7 @@ extern "C" { /** * The singleton which represents the nRF51822 transport for the BLE. */ -static nRF5xn deviceInstance; +static nRF5xn *deviceInstance = NULL; /** * BLE-API requires an implementation of the following function in order to @@ -47,7 +47,10 @@ createBLEInstance(void) nRF5xn& nRF5xn::Instance(BLE::InstanceID_t instanceId) { - return deviceInstance; + if (deviceInstance == NULL) + deviceInstance = new nRF5xn(); + + return *deviceInstance; } nRF5xn::nRF5xn(void) :