Bluetooth Low Energy for Smart Plug

Dependencies:   BLE_API mbed nRF51822

Revision:
0:25ad6eba7916
Child:
2:6db5c9a2894c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/BLECommunication.cpp	Tue Jul 07 04:02:14 2015 +0000
@@ -0,0 +1,36 @@
+#include "BLECommunication.h"
+//uint8_t DEVICE_NAME[] = "NRFTEST";
+//uint16_t list[] = {SPS_UUID_SERVICE};
+
+BLECommunication::BLECommunication(SmartPlugBLE& system,BLE &_ble):
+    ble(_ble),smartPlugService(ble,system),led(LED3)
+{
+
+    ble.init();
+    
+    ble.gattServer().onDataWritten(&smartPlugService,&SmartPlugService::onDataWritten);
+    smartPlugService.setupService();
+    //start();
+}
+
+void BLECommunication::start(void)
+{
+    //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(true)
+//    {
+//        ble.waitForEvent();
+//    }
+}
+
+void BLECommunication::periodicCallback(void)
+{
+    led = !led;    
+}
\ No newline at end of file