Example program for the Eddystone Beacon service.

Dependencies:   BLE_API mbed nRF51822 X_NUCLEO_IDB0XA1

Fork of BLE_EddystoneBeacon by URIBeacon

This example demonstrates how to set up and initialize a Eddystone Beacon. For more details on the Eddystone specification please see the Eddystone Github Page.

The Basics

An Eddystone Beacon is a Bluetooth Low Energy beacon, that means it does all of its data transfer in GAP advertising packets. Eddystone beacons, unlike other beacons, broadcast multiple types of data. Currently Eddystone beacons have 3 frame types (UID, URL, TLM) that will get swapped out periodically. This swapping of frame data allows Eddystone beacons to send many different types of data, thus increasing their usefulness over traditional beacons. Note that the UID frame type provides the same 16Bytes of UUID namespace that iBeacons do and the URL frame type provides the same functionality as a URIBeacon.

For more details see the Eddystone Specification.

Smartphone Apps

nRF Master Control Panel - this program recognizes Eddystone beacons and will display the data for all frame types.

iPhone Physical Web app

Android App

Walkthrough of Physical Web application

Technical Details

The Eddystone Specification looks like the following image. Please note that this may change over time and for up to date information the official spec should be referenced. /media/uploads/mbedAustin/scratch-1-.png

The Eddystone Frames get swapped in and out depending on what frames you have enabled. The only required frame type is the TLM frame, all others are optional and you can have any number enabled. To disable the UID or URL frames give their values a 'NULL' in the Eddystone constructor. The Eddystone spec recommends broadcasting 10 frames a second.

Note

  • The current Eddystone mbed example does not allow for combining the eddystone service with other services, this will be changes in a future update.
  • There is an Eddystone Config service that allows for updating beacons in the field. We are working on an example for this, so keep your eyes pealed for a future update.
Committer:
mbedAustin
Date:
Thu Oct 01 16:28:22 2015 +0000
Revision:
32:41840b78597e
Parent:
31:bdd03742096a
Child:
33:862e6e0831ea
Updating example to comply with latest API changes

Who changed what in which revision?

UserRevisionLine numberNew contents of line
screamer 0:c04d932e96c9 1 /* mbed Microcontroller Library
mbedAustin 32:41840b78597e 2 * Copyright (c) 2006-2013 ARM Limited
screamer 0:c04d932e96c9 3 *
screamer 0:c04d932e96c9 4 * Licensed under the Apache License, Version 2.0 (the "License");
screamer 0:c04d932e96c9 5 * you may not use this file except in compliance with the License.
screamer 0:c04d932e96c9 6 * You may obtain a copy of the License at
screamer 0:c04d932e96c9 7 *
screamer 0:c04d932e96c9 8 * http://www.apache.org/licenses/LICENSE-2.0
screamer 0:c04d932e96c9 9 *
screamer 0:c04d932e96c9 10 * Unless required by applicable law or agreed to in writing, software
screamer 0:c04d932e96c9 11 * distributed under the License is distributed on an "AS IS" BASIS,
screamer 0:c04d932e96c9 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
screamer 0:c04d932e96c9 13 * See the License for the specific language governing permissions and
screamer 0:c04d932e96c9 14 * limitations under the License.
screamer 0:c04d932e96c9 15 */
screamer 0:c04d932e96c9 16
screamer 0:c04d932e96c9 17 #include "mbed.h"
mbedAustin 32:41840b78597e 18 #include "BLE.h"
mbedAustin 31:bdd03742096a 19 #include "ble/services/EddystoneService.h"
screamer 0:c04d932e96c9 20
rgrover1 8:1a21308e5008 21 BLE ble;
mbedAustin 26:2896fbdd0450 22 uint8_t UIDnamespace[] = {0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x88,0x99,0xAA}; // 10Bytes for Namespace UUID
mbedAustin 26:2896fbdd0450 23 uint8_t UIDinstance[] = {0xbb,0xcc,0xdd,0xee,0xff,0x00}; // 6Bytes for Instance UUID
mbedAustin 30:6c2db8bf5b17 24 char Url[] = "http://www.mbed.org";
mbedAustin 32:41840b78597e 25 int8_t radioTxPower = 20;
mbedAustin 32:41840b78597e 26 int8_t advTxPower = -20;
mbedAustin 30:6c2db8bf5b17 27 uint16_t beaconPeriodus = 1000;
mbedAustin 32:41840b78597e 28 uint8_t tlmVersion = 0x00;
mbedAustin 32:41840b78597e 29
mbedAustin 30:6c2db8bf5b17 30
mbedAustin 30:6c2db8bf5b17 31 //Callbacks for temperature / battery updates
mbedAustin 30:6c2db8bf5b17 32 Ticker tlmBattery;
mbedAustin 30:6c2db8bf5b17 33 Ticker tlmTemperature;
mbedAustin 30:6c2db8bf5b17 34 int battery = 0;
mbedAustin 30:6c2db8bf5b17 35 int temp = 0;
mbedAustin 30:6c2db8bf5b17 36
mbedAustin 32:41840b78597e 37 // Setup Eddystone Service
mbedAustin 32:41840b78597e 38 EddystoneService eddyBeacon(ble,beaconPeriodus,radioTxPower);
mbedAustin 30:6c2db8bf5b17 39
mbedAustin 32:41840b78597e 40
mbedAustin 32:41840b78597e 41 // Function to update beacon battery voltage
mbedAustin 30:6c2db8bf5b17 42 void tlmBatteryCallback(void){
mbedAustin 30:6c2db8bf5b17 43 eddyBeacon.updateTlmBatteryVoltage(battery++);
mbedAustin 30:6c2db8bf5b17 44 }
mbedAustin 30:6c2db8bf5b17 45
mbedAustin 32:41840b78597e 46 // Function to update Beacon Temperature
mbedAustin 30:6c2db8bf5b17 47 void tlmTemperatureCallback(void){
mbedAustin 30:6c2db8bf5b17 48 eddyBeacon.updateTlmBeaconTemp(temp++);
mbedAustin 30:6c2db8bf5b17 49 }
screamer 0:c04d932e96c9 50
screamer 0:c04d932e96c9 51 int main(void)
screamer 0:c04d932e96c9 52 {
mbedAustin 32:41840b78597e 53 printf("Starting Example\r\n"); // To enable low power mode disable all printf's
mbedAustin 32:41840b78597e 54
mbedAustin 32:41840b78597e 55 // Set Eddystone Frame Data (TLM,UID,URI...etc)
mbedAustin 32:41840b78597e 56 eddyBeacon.setTLMFrameData(tlmVersion,5.0);
mbedAustin 32:41840b78597e 57 eddyBeacon.setURLFrameData(advTxPower, Url, 2.0);
mbedAustin 32:41840b78597e 58 eddyBeacon.setUIDFrameData(advTxPower, UIDnamespace, UIDinstance, 3.0);
mbedAustin 32:41840b78597e 59
mbedAustin 32:41840b78597e 60 // Attach functions to modify TLM data
mbedAustin 30:6c2db8bf5b17 61 tlmTemperature.attach(tlmTemperatureCallback,2.0f);
mbedAustin 30:6c2db8bf5b17 62 tlmBattery.attach(tlmBatteryCallback, 1.0f);
mbedAustin 32:41840b78597e 63
mbedAustin 32:41840b78597e 64 // Start Advertising the eddystone service.
mbedAustin 32:41840b78597e 65 eddyBeacon.start();
mbedAustin 32:41840b78597e 66
mbedAustin 15:af8c24f34a9f 67 printf("Running...\r\n");
screamer 0:c04d932e96c9 68 while (true) {
screamer 0:c04d932e96c9 69 ble.waitForEvent();
screamer 0:c04d932e96c9 70 }
screamer 0:c04d932e96c9 71 }