A template for applications where some small amount of data needs to be notified to a phone app over BLE. It is a good starting point for notifications.

Dependencies:   BLE_API mbed nRF51822

Fork of BLE_Button by Bluetooth Low Energy

Revision:
6:18d8750f39ee
Parent:
5:43a3ab27f2e4
Child:
8:a7ba7aaba460
--- a/main.cpp	Sat Jun 20 00:00:32 2015 +0000
+++ b/main.cpp	Sat Jun 20 23:52:29 2015 +0000
@@ -18,7 +18,7 @@
 #include "BLE.h"
 #include "ButtonService.h"
 
-BLEDevice   ble;
+BLE         ble;
 DigitalOut  led1(LED1);
 InterruptIn button(BUTTON1);
 
@@ -39,7 +39,7 @@
 
 void disconnectionCallback(Gap::Handle_t handle, Gap::DisconnectionReason_t reason)
 {
-    ble.startAdvertising();
+    ble.gap().startAdvertising();
 }
 
 void periodicCallback(void)
@@ -56,18 +56,18 @@
     button.rise(buttonReleasedCallback);
 
     ble.init();
-    ble.onDisconnection(disconnectionCallback);
+    ble.gap().onDisconnection(disconnectionCallback);
 
     ButtonService buttonService(ble, false /* initial value for button pressed */);
     buttonServicePtr = &buttonService;
 
     /* setup advertising */
-    ble.accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE);
-    ble.accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_16BIT_SERVICE_IDS, (uint8_t *)uuid16_list, sizeof(uuid16_list));
-    ble.accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LOCAL_NAME, (uint8_t *)DEVICE_NAME, sizeof(DEVICE_NAME));
-    ble.setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED);
-    ble.setAdvertisingInterval(1000); /* 1000ms. */
-    ble.startAdvertising();
+    ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE);
+    ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_16BIT_SERVICE_IDS, (uint8_t *)uuid16_list, sizeof(uuid16_list));
+    ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LOCAL_NAME, (uint8_t *)DEVICE_NAME, sizeof(DEVICE_NAME));
+    ble.gap().setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED);
+    ble.gap().setAdvertisingInterval(1000); /* 1000ms. */
+    ble.gap().startAdvertising();
 
     while (true) {
         ble.waitForEvent();