BLE - Nordic implementation: Move singleton into a function.

This change remove BLE code from the binary generated if the user code doesn't
use BLE.
pull/2778/head
Vincent Coubard 2016-09-22 11:44:22 +01:00
parent c1c1492fa7
commit b4ac8f214a
1 changed files with 6 additions and 2 deletions

View File

@ -34,7 +34,11 @@ extern "C" {
/**
* The singleton which represents the nRF51822 transport for the BLE.
*/
static nRF5xn deviceInstance;
static nRF5xn& getDeviceInstance() {
static nRF5xn deviceInstance;
return deviceInstance;
}
/**
* BLE-API requires an implementation of the following function in order to
@ -48,7 +52,7 @@ createBLEInstance(void)
nRF5xn& nRF5xn::Instance(BLE::InstanceID_t instanceId)
{
return deviceInstance;
return getDeviceInstance();
}
nRF5xn::nRF5xn(void) :