vbfgh

Dependencies:   BLE_API HCSR04 X_NUCLEO_IDB0XA1 mbed

Fork of BLE_LED_Button_Nucleo by Jan Jongboom

Revision:
7:c9271599ec5f
Parent:
6:fca54d71d10e
Child:
9:35a5a5796286
diff -r fca54d71d10e -r c9271599ec5f main.cpp
--- a/main.cpp	Fri Jun 19 23:42:36 2015 +0000
+++ b/main.cpp	Sat Jun 20 23:30:44 2015 +0000
@@ -18,7 +18,7 @@
 #include "BLE.h"
 #include "LEDService.h"
 
-BLEDevice  ble;
+BLE        ble;
 DigitalOut alivenessLED(LED1);
 DigitalOut actuatedLED(LED2);
 
@@ -29,7 +29,7 @@
 
 void disconnectionCallback(Gap::Handle_t handle, Gap::DisconnectionReason_t reason)
 {
-    ble.startAdvertising();
+    ble.gap().startAdvertising();
 }
 
 void periodicCallback(void)
@@ -43,8 +43,8 @@
  * @param[in] params
  *     Information about the characterisitc being updated.
  */
-void onDataWrittenCallback(const GattCharacteristicWriteCBParams *params) {
-    if ((params->charHandle == ledServicePtr->getValueHandle()) && (params->len == 1)) {
+void onDataWrittenCallback(const GattWriteCallbackParams *params) {
+    if ((params->handle == ledServicePtr->getValueHandle()) && (params->len == 1)) {
         actuatedLED = *(params->data);
     }
 }
@@ -58,20 +58,20 @@
     ticker.attach(periodicCallback, 1);
 
     ble.init();
-    ble.onDisconnection(disconnectionCallback);
-    ble.onDataWritten(onDataWrittenCallback);
+    ble.gap().onDisconnection(disconnectionCallback);
+    ble.gattServer().onDataWritten(onDataWrittenCallback);
 
     bool initialValueForLEDCharacteristic = false;
     LEDService ledService(ble, initialValueForLEDCharacteristic);
     ledServicePtr = &ledService;
 
     /* 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();