Merge pull request #2778 from pan-/avoid_inclusion_of_ble_code_if_not_used

BLE - Nordic implementation: Move singleton into a function.
pull/2663/merge
Sam Grove 2016-09-25 21:57:23 -05:00 committed by GitHub
commit d8efe713e7
2 changed files with 12 additions and 4 deletions

View File

@ -33,7 +33,11 @@ extern "C" {
/** /**
* The singleton which represents the nRF51822 transport for the BLE. * 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 * BLE-API requires an implementation of the following function in order to
@ -47,7 +51,7 @@ createBLEInstance(void)
nRF5xn& nRF5xn::Instance(BLE::InstanceID_t instanceId) nRF5xn& nRF5xn::Instance(BLE::InstanceID_t instanceId)
{ {
return deviceInstance; return getDeviceInstance();
} }
nRF5xn::nRF5xn(void) : nRF5xn::nRF5xn(void) :

View File

@ -34,7 +34,11 @@ extern "C" {
/** /**
* The singleton which represents the nRF51822 transport for the BLE. * 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 * 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) nRF5xn& nRF5xn::Instance(BLE::InstanceID_t instanceId)
{ {
return deviceInstance; return getDeviceInstance();
} }
nRF5xn::nRF5xn(void) : nRF5xn::nRF5xn(void) :