AltBeacon program for embedded BLE. This program demonstrates how to set up a BLE device to broadcast AltBLE compatible data. Please see the official website for more details. https://github.com/AltBeacon/spec and http://altbeacon.org/

Dependencies:   BLE_API mbed nRF51822

Fork of BLE_AltBeacon by Austin Blackstone

Description

AltBeacon is an open beacon standard developed by Roving Networks. AltBeacons an alternative to the closed sourced and heavily licensed iBeacon standard.

For full details please see the AltBeacon repository

Revision:
2:6ec277483638
Parent:
1:cc428f427838
--- a/AltBeaconService.h	Fri Mar 20 21:10:12 2015 +0000
+++ b/AltBeaconService.h	Tue Jan 12 11:34:09 2016 +0000
@@ -16,7 +16,7 @@
 #ifndef __BLE_ALTBEACON_SERVICE_H__
 #define __BLE_ALTBEACON_SERVICE_H__
 
-#include "BLEDevice.h"
+#include "ble/BLE.h"
 
 /**
 * @class AltBeaconService
@@ -27,8 +27,8 @@
 {
 public:
     /**
-    * @param[ref] _ble
-    *               BLEDevice object for the underlying controller.
+    * @param[in] _ble
+    *               BLE object for the underlying controller.
     * @param[in] mfgID
     *               The beacon device manufacturer's company identifier code. 
     *               Usually this will coorespond to the companies BLE SIG assigned number.
@@ -43,27 +43,30 @@
     * @param[in] mfgReserved
     *               Used for special manufacturer data. Defaults to 0x00 if not specified.
     */
-    AltBeaconService(BLEDevice &_ble, uint16_t mfgID, uint8_t beaconID[20], int8_t refRSSI, uint8_t mfgReserved = 0x00):
+    AltBeaconService(BLE &_ble, uint16_t mfgID, uint8_t beaconID[20], int8_t refRSSI, uint8_t mfgReserved = 0x00):
         ble(_ble)
     {
-        data.mfgID = ((mfgID<<8) | (mfgID >>8));
-        if(refRSSI > 0){refRSSI = 0;} // refRSSI can only be 0 to -127, smash everything above 0 to zero
-        data.refRSSI = refRSSI;
-        data.beaconCode = 0xACBE;
+        /* refRSSI can only be 0 to -127, smash everything above 0 to zero */
+        if (refRSSI > 0) {
+            refRSSI = 0;
+        }
+        data.mfgID       = ((mfgID<<8) | (mfgID >>8));
+        data.refRSSI     = refRSSI;
+        data.beaconCode  = 0xACBE;
         data.mfgReserved = mfgReserved;
 
-        // copy across beacon ID
-        for(int x=0; x<sizeof(data.beaconID); x++) {
+        /* copy across beacon ID */
+        for(int x = 0; x < sizeof(data.beaconID); x++) {
             data.beaconID[x] = beaconID[x];
         }
 
-        // Set up alt beacon
-        ble.accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE );
-        // Generate the 0x1BFF part of the Alt Prefix
-        ble.accumulateAdvertisingPayload(GapAdvertisingData::MANUFACTURER_SPECIFIC_DATA, data.raw, sizeof(data.raw));
+        /* Set up alt beacon */
+        ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE);
+        /* Generate the 0x1BFF part of the Alt Prefix */
+        ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::MANUFACTURER_SPECIFIC_DATA, data.raw, sizeof(data.raw));
 
-        // Set advertising type
-        ble.setAdvertisingType(GapAdvertisingParams::ADV_NON_CONNECTABLE_UNDIRECTED);
+        /* Set advertising type */
+        ble.gap().setAdvertisingType(GapAdvertisingParams::ADV_NON_CONNECTABLE_UNDIRECTED);
     }
 
 public:
@@ -79,8 +82,8 @@
     } data;
 
 private:
-    BLEDevice &ble;
+    BLE &ble;
 
 };
 
-#endif //__BLE_ALTBEACON_SERVICE_H__
+#endif /* __BLE_ALTBEACON_SERVICE_H__ */