Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BLE_API mbed nRF51822 X_NUCLEO_IDB0XA1
Fork of BLE_HeartRate by
Diff: main.cpp
- Revision:
- 73:49b6090478e2
- Parent:
- 72:99c283dfe28d
- Child:
- 74:c9d58e7847c4
diff -r 99c283dfe28d -r 49b6090478e2 main.cpp
--- a/main.cpp Mon Nov 02 09:49:57 2015 +0000
+++ b/main.cpp Mon Nov 02 10:11:26 2015 +0000
@@ -20,7 +20,6 @@
#include "ble/services/BatteryService.h"
#include "ble/services/DeviceInformationService.h"
-BLE ble;
DigitalOut led1(LED1);
const static char DEVICE_NAME[] = "HRM1";
@@ -35,7 +34,7 @@
void disconnectionCallback(const Gap::DisconnectionCallbackParams_t *params)
{
- ble.gap().startAdvertising(); // restart advertising
+ BLE::Instance(BLE::DEFAULT_INSTANCE).gap().startAdvertising(); // restart advertising
}
void periodicCallback(void)
@@ -77,8 +76,13 @@
Ticker ticker;
ticker.attach(periodicCallback, 1); // blink LED every second
+ BLE& ble = BLE::Instance(BLE::DEFAULT_INSTANCE);
ble.init(bleInitComplete);
+ /* SpinWait for initialization to complete. This is necessary because the
+ * BLE object is used in the main loop below. */
+ while (ble.hasInitialized()) { /* spin loop */ }
+
// infinite loop
while (1) {
// check for trigger from periodicCallback()
