Skip to content

Commit e8bddd6

Browse files
committed
BLE - Legacy nordic implementation: Move static singleton into a function.
The change of scope all the code from BLE when this code is not used by the end user application.
1 parent b4ac8f2 commit e8bddd6

File tree

1 file changed

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

1 file changed

+6
-2
lines changed

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

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

3842
/**
3943
* BLE-API requires an implementation of the following function in order to
@@ -47,7 +51,7 @@ createBLEInstance(void)
4751

4852
nRF5xn& nRF5xn::Instance(BLE::InstanceID_t instanceId)
4953
{
50-
return deviceInstance;
54+
return getDeviceInstance();
5155
}
5256

5357
nRF5xn::nRF5xn(void) :

0 commit comments

Comments
 (0)