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:
0:f519dff5c6a7
Child:
1:cc428f427838
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/AltBeaconService.h	Tue Feb 03 18:23:07 2015 +0000
@@ -0,0 +1,69 @@
+/* mbed Microcontroller Library
+ * Copyright (c) 2006-2015 ARM Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef __BLE_IBEACON_SERVICE_H__
+#define __BLE_IBEACON_SERVICE_H__
+
+#include "BLEDevice.h"
+
+/**
+* @class iBeaconService
+* @brief iBeacon Service. This service sets up a device to broadcast advertising packets to mimic an iBeacon<br>
+*/
+
+class AltBeaconService
+{
+public:
+    AltBeaconService(BLEDevice &_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;
+        data.mfgReserved = mfgReserved;
+
+        // 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 advertising type
+        ble.setAdvertisingType(GapAdvertisingParams::ADV_NON_CONNECTABLE_UNDIRECTED);
+    }
+
+public:
+    union {
+        uint8_t raw[26]; // AltBeacon advertisment data
+        struct {
+            uint16_t mfgID;         // little endian representation of manufacturer ID
+            uint16_t beaconCode;    // Big Endian representation of 0xBEAC
+            uint8_t  beaconID[20];  // 20byte beacon ID, usually 16byte UUID w/ remainder used as necessary
+            int8_t   refRSSI;       // 1 byte signed data, 0 to -127
+            uint8_t  mfgReserved;   // reserved for use by manufacturer to implement special features
+        };
+    } data;
+
+private:
+    BLEDevice &ble;
+
+};
+
+#endif //__BLE_IBEACON_SERVICE_H__