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

Committer:
mbedAustin
Date:
Tue Feb 03 18:23:07 2015 +0000
Revision:
0:f519dff5c6a7
Child:
2:6ec277483638
Initial commit for AltBeacon compatible program

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbedAustin 0:f519dff5c6a7 1 /* mbed Microcontroller Library
mbedAustin 0:f519dff5c6a7 2 * Copyright (c) 2006-2013 ARM Limited
mbedAustin 0:f519dff5c6a7 3 *
mbedAustin 0:f519dff5c6a7 4 * Licensed under the Apache License, Version 2.0 (the "License");
mbedAustin 0:f519dff5c6a7 5 * you may not use this file except in compliance with the License.
mbedAustin 0:f519dff5c6a7 6 * You may obtain a copy of the License at
mbedAustin 0:f519dff5c6a7 7 *
mbedAustin 0:f519dff5c6a7 8 * http://www.apache.org/licenses/LICENSE-2.0
mbedAustin 0:f519dff5c6a7 9 *
mbedAustin 0:f519dff5c6a7 10 * Unless required by applicable law or agreed to in writing, software
mbedAustin 0:f519dff5c6a7 11 * distributed under the License is distributed on an "AS IS" BASIS,
mbedAustin 0:f519dff5c6a7 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
mbedAustin 0:f519dff5c6a7 13 * See the License for the specific language governing permissions and
mbedAustin 0:f519dff5c6a7 14 * limitations under the License.
mbedAustin 0:f519dff5c6a7 15 */
mbedAustin 0:f519dff5c6a7 16
mbedAustin 0:f519dff5c6a7 17 #include "mbed.h"
mbedAustin 0:f519dff5c6a7 18 #include "AltBeaconService.h"
mbedAustin 0:f519dff5c6a7 19
mbedAustin 0:f519dff5c6a7 20 /**
mbedAustin 0:f519dff5c6a7 21 * For this demo application, populate the beacon advertisement payload
mbedAustin 0:f519dff5c6a7 22 * with 2 AD structures: FLAG and MSD (manufacturer specific data).
mbedAustin 0:f519dff5c6a7 23 *
mbedAustin 0:f519dff5c6a7 24 * Reference:
mbedAustin 0:f519dff5c6a7 25 * Bluetooth Core Specification 4.0 (Vol. 3), Part C, Section 11, 18
mbedAustin 0:f519dff5c6a7 26 */
mbedAustin 0:f519dff5c6a7 27
mbedAustin 0:f519dff5c6a7 28 BLEDevice ble;
mbedAustin 0:f519dff5c6a7 29
mbedAustin 0:f519dff5c6a7 30 /**
mbedAustin 0:f519dff5c6a7 31 * The AltBeacon requires a manufacturer ID, and a Beacon ID
mbedAustin 0:f519dff5c6a7 32 * the first 16 bytes of the BeaconID should be a UUID and the remaining
mbedAustin 0:f519dff5c6a7 33 * 4 bytes can be used as you see fit.
mbedAustin 0:f519dff5c6a7 34 *
mbedAustin 0:f519dff5c6a7 35 * Note: please remember to calibrate your beacon
mbedAustin 0:f519dff5c6a7 36 * RSSI for more accurate results.
mbedAustin 0:f519dff5c6a7 37 */
mbedAustin 0:f519dff5c6a7 38 uint8_t beaconID[] = { 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,
mbedAustin 0:f519dff5c6a7 39 0x10,0x11,0x12,0x13,0x14,0x15,0x00,0x01,0x00,0x02 };
mbedAustin 0:f519dff5c6a7 40 uint16_t manufacturerID = 0x5900; //Nordic SIG ID
mbedAustin 0:f519dff5c6a7 41 int8_t rssi = -122;
mbedAustin 0:f519dff5c6a7 42
mbedAustin 0:f519dff5c6a7 43
mbedAustin 0:f519dff5c6a7 44 int main(void)
mbedAustin 0:f519dff5c6a7 45 {
mbedAustin 0:f519dff5c6a7 46 // Initialize BLE baselayer
mbedAustin 0:f519dff5c6a7 47 ble.init();
mbedAustin 0:f519dff5c6a7 48
mbedAustin 0:f519dff5c6a7 49 // Initialize AltBeacon
mbedAustin 0:f519dff5c6a7 50 AltBeaconService altbeacon(ble, manufacturerID, beaconID, rssi);
mbedAustin 0:f519dff5c6a7 51
mbedAustin 0:f519dff5c6a7 52 // Set advertising time
mbedAustin 0:f519dff5c6a7 53 ble.setAdvertisingInterval(160); /* 100ms; in multiples of 0.625ms. */
mbedAustin 0:f519dff5c6a7 54 ble.startAdvertising();
mbedAustin 0:f519dff5c6a7 55
mbedAustin 0:f519dff5c6a7 56 while(1) {
mbedAustin 0:f519dff5c6a7 57 ble.waitForEvent(); // allows or low power operation
mbedAustin 0:f519dff5c6a7 58 }
mbedAustin 0:f519dff5c6a7 59 }