Skip to content

Commit b4ac8f2

Browse files
committed
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.
1 parent c1c1492 commit b4ac8f2

File tree

1 file changed

+6
-2
lines changed
  • features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF5/source

1 file changed

+6
-2
lines changed

features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF5/source/nRF5xn.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ extern "C" {
3434
/**
3535
* The singleton which represents the nRF51822 transport for the BLE.
3636
*/
37-
static nRF5xn deviceInstance;
37+
static nRF5xn& getDeviceInstance() {
38+
static nRF5xn deviceInstance;
39+
return deviceInstance;
40+
}
41+
3842

3943
/**
4044
* BLE-API requires an implementation of the following function in order to
@@ -48,7 +52,7 @@ createBLEInstance(void)
4852

4953
nRF5xn& nRF5xn::Instance(BLE::InstanceID_t instanceId)
5054
{
51-
return deviceInstance;
55+
return getDeviceInstance();
5256
}
5357

5458
nRF5xn::nRF5xn(void) :

0 commit comments

Comments
 (0)