Bluetooth Low Energy for Smart Plug

Dependencies:   BLE_API mbed nRF51822

Fork of SmartPlugBLE by Pavit Noinongyao

Revision:
2:6db5c9a2894c
Parent:
0:25ad6eba7916
--- a/main.cpp	Tue Jul 07 04:58:28 2015 +0000
+++ b/main.cpp	Wed Jul 08 07:25:11 2015 +0000
@@ -3,11 +3,10 @@
 #include "BLECommunication.h"
 #include "BLE.h"
 BLE ble;
-uint8_t DEVICE_NAME[] = "NRFTEST";
-uint16_t list[] = {SPS_UUID_SERVICE};
 
 void disconnectionCallback(Gap::Handle_t handle, Gap::DisconnectionReason_t reason)
 {
+    printf("reason = x%08x\r\n",reason);
     ble.gap().startAdvertising();
 }
 
@@ -17,21 +16,4 @@
     Ticker ticker;
     SmartPlugBLE smartPlugBLE;
     BLECommunication bleComm(smartPlugBLE,ble);
-    ticker.attach(&bleComm,&BLECommunication::periodicCallback, 1);
-    /* Setup advertising. */
-
-    ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE);
-    ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_16BIT_SERVICE_IDS, (uint8_t*)list, sizeof(list));
-    ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::UNKNOWN);
-    ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LOCAL_NAME, (uint8_t *)DEVICE_NAME, sizeof(DEVICE_NAME));//cannot blink after this
-
-    ble.gap().setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED);
-    ble.gap().setAdvertisingInterval(1000); /* 1000ms */
-
-    ble.gap().startAdvertising();
-
-
-    while(1) {
-        ble.waitForEvent();
-    }
 }