Using nRF51 as Line Beacon

Dependencies:   BLE_API mbed nRF51822

Fork of BLE_GAP_Example by Bluetooth Low Energy

Revision:
16:4271375739ea
Parent:
15:7e06fce6e4f8
--- a/main.cpp	Tue Jan 12 12:00:16 2016 +0000
+++ b/main.cpp	Wed Apr 12 18:52:04 2017 +0000
@@ -18,11 +18,15 @@
 #include "ble/BLE.h"
 
 /* Optional: Device Name, add for human read-ability */
-const static char     DEVICE_NAME[] = "ChangeMe!!";
+const static char     DEVICE_NAME[] = "Line Beacon 001";                                           /* Name it */
+
 
-/* You have up to 26 bytes of advertising data to use. */
-const static uint8_t AdvData[] = {0x01,0x02,0x03,0x04,0x05};   /* Example of hex data */
-//const static uint8_t AdvData[] = {"ChangeThisData"};         /* Example of character data */
+const static uint8_t AdvServiceUUIDs[] = { 0x6F, 0xFE };                           
+const static uint8_t AdvData[] = { 0x6F, 0xFE, 0x02, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x00 };  /* Replace 0xFF, 0xFF, 0xFF, 0xFF, 0xFF to your bot's HWID */
+//const static uint8_t AdvDataFrameType[] = { 0x02 };
+//const static uint8_t AdvDataHWID[] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
+//const static uint8_t AdvDataMeasuredTxPower[] = { 0x7F };
+//const static uint8_t AdvDataDeviceMessage[] = { 0x00 };
 
 /* Optional: Restart advertising when peer disconnects */
 void disconnectionCallback(const Gap::DisconnectionCallbackParams_t *params)
@@ -71,10 +75,13 @@
     ble.gap().setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED);
 
     /* Sacrifice 2B of 31B to AdvType overhead, rest goes to AdvData array you define */
-    ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::MANUFACTURER_SPECIFIC_DATA, AdvData, sizeof(AdvData));
+    ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_16BIT_SERVICE_IDS, AdvServiceUUIDs, sizeof(AdvServiceUUIDs));
+    
+    ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::SERVICE_DATA, AdvServiceUUIDs, sizeof(AdvServiceUUIDs));
 
     /* Optional: Add name to device */
-    //ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LOCAL_NAME, (uint8_t *)DEVICE_NAME, sizeof(DEVICE_NAME));
+    ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::SERVICE_DATA, AdvData, sizeof(AdvData));
+    //ble.gap().setAdvertisingData((const uint8_t *)AdvServiceUUIDs, (const uint8_t *)AdvData);
 
     /* Set advertising interval. Longer interval == longer battery life */
     ble.gap().setAdvertisingInterval(100); /* 100ms */