microbit-dal: added #define to determine BLE usage
NO_BLE can now be defined to determine whether ble will be brought up or not at initialisation of uBit. This is especially useful for two new Yotta targets: bbc-microbit-classic-gcc-nosd, bbc-microbit-classic-armcc-nosd, which do not use softdevice.
This commit is contained in:
parent
0552741cf1
commit
f8ebfc69fb
3 changed files with 14 additions and 2 deletions
|
@ -5,7 +5,11 @@
|
|||
//#define MICROBIT_DBG
|
||||
|
||||
#include "mbed.h"
|
||||
|
||||
#ifndef NO_BLE
|
||||
#include "ble/BLE.h"
|
||||
#endif
|
||||
|
||||
#include "ble/services/DeviceInformationService.h"
|
||||
|
||||
//error number enumeration
|
||||
|
|
|
@ -24,7 +24,6 @@ void bleDisconnectionCallback(Gap::Handle_t handle, Gap::DisconnectionReason_t r
|
|||
uBit.ble->startAdvertising(); // restart advertising!
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* Create a representation of a MicroBit device as a global singleton.
|
||||
|
@ -88,6 +87,7 @@ void MicroBit::init()
|
|||
// Seed our random number generator
|
||||
seedRandom();
|
||||
|
||||
#ifndef NO_BLE
|
||||
// Start the BLE stack.
|
||||
ble = new BLEDevice();
|
||||
|
||||
|
@ -108,6 +108,12 @@ void MicroBit::init()
|
|||
ble->setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED);
|
||||
ble->setAdvertisingInterval(Gap::MSEC_TO_ADVERTISEMENT_DURATION_UNITS(1000));
|
||||
ble->startAdvertising();
|
||||
#else
|
||||
ble = NULL;
|
||||
ble_firmware_update_service = NULL;
|
||||
ble_device_information_service = NULL;
|
||||
ble_event_service = NULL;
|
||||
#endif
|
||||
|
||||
// Start refreshing the Matrix Display
|
||||
systemTicker.attach(this, &MicroBit::systemTick, MICROBIT_DISPLAY_REFRESH_PERIOD);
|
||||
|
|
|
@ -54,7 +54,8 @@ int main()
|
|||
uBit.init();
|
||||
|
||||
uBit.sleep(100);
|
||||
|
||||
|
||||
#ifndef NO_BLE
|
||||
// Test if we need to enter BLE pairing mode...
|
||||
int i=0;
|
||||
while (uBit.buttonA.isPressed() && uBit.buttonB.isPressed() && i<10)
|
||||
|
@ -65,6 +66,7 @@ int main()
|
|||
if (i == 10 && uBit.ble_firmware_update_service != NULL)
|
||||
uBit.ble_firmware_update_service->pair();
|
||||
}
|
||||
#endif
|
||||
|
||||
app_main();
|
||||
|
||||
|
|
Loading…
Reference in a new issue