PUBLISH HelloBlue

Dependencies:   BLE_API mbed nRF51822

Fork of HelloBlue by Wayne Keenan

Revision:
0:a89b73f690c1
Child:
1:b84d6e0b404e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Jan 28 17:35:34 2015 +0000
@@ -0,0 +1,33 @@
+#include "mbed.h"
+#include "BLEDevice.h"
+
+#include "DFUService.h"
+
+const static char     DEVICE_NAME[]        = "HelloBlue";
+
+BLEDevice ble;
+
+void disconnectionCallback(Gap::Handle_t handle, Gap::DisconnectionReason_t reason)
+{
+    ble.startAdvertising(); // restart advertising
+}
+
+int main(void)
+{
+    ble.init();
+    ble.onDisconnection(disconnectionCallback);
+
+    DFUService dfu(ble);
+
+    /* Setup advertising. */
+    ble.accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE);
+    ble.accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LOCAL_NAME, (uint8_t *)DEVICE_NAME, sizeof(DEVICE_NAME));
+    ble.setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED);
+    ble.setAdvertisingInterval(Gap::MSEC_TO_ADVERTISEMENT_DURATION_UNITS(1000));
+    ble.startAdvertising();
+    
+   while (true) {
+        ble.waitForEvent();
+    }
+}
+