Beacon demo for the BLE API using the nRF51822 native mode drivers

Dependencies:   BLE_API mbed nRF51822 X_NUCLEO_IDB0XA1

Introduction

Bluetooth Low Energy Beacons are a service that allow for highly localized positioning. The Beacon service is particularly useful for indoor positioning, low power positioning and location aware software. A particular use of the Beacon service is iBeacon. The iBeacon standard is a Apple specific implementation of Beacons.

The Basics

The Beacon service is a BLE Service that operates in advertising mode only. A Beacon service advertises 4 things:

  • A company ID
  • A unique UUID (unique to a retailer)
  • A Major number (ex a store number)
  • A Minor number (ex a location in the store)
  • Signal Strength at transmitter (requires calibration per each device)

These pieces of information are all you need for a Beacon service to work. The majority of the heavy lifting is done by the smart phone application that reads these four fields and then uses a web app or a database of some sort to turn these numbers into valuable information about what you are near and how near you are to it.

The signal strength field is compared to the actual signal strength at the receiver to determine how close the beacon is to the phone. The number used is the calibrated signal strength 1 meter from the device. By doing this 1 meter increments can be used to measure distance from the Beacon. The distances usually get broken down into 3 ranges:

  • Immediate: Within a few centimeters
  • Near: Within a couple of meters
  • Far: Greater than 10 meters away

Company ID's are used to make beacon UUID's unique to companies. Some example company UUID's are:

  • 0x004C - Apple Inc.
  • 0x0059 - Nordic Semiconductor
  • 0x0078 - Nike
  • ​0x015D - Estimote
  • ​0x0171 - Amazon Fulfillment Service
  • 0xFFFF - reserved for internal testing before release

Here is the Bluetooth SIG's full list of Company ID's.

Example : Coffee Shop X

For example, if a smartphone app reads a BLE Beacon with UUID = 0x1234546... , Major Number=5, Minor number = 3, it would check that against a database. From that database it would find out that UUID 0x123456... is owned by Coffee Shop X, that Major number 5 belongs to the store on main street and that Minor number 3 belongs to the coffee rack in that store. Then the application could check to see if there are any deals for the Coffee Shop X on Main Street on Coffee today. If there are any deals the phone could then alert the user and display a coupon code.

Example : museum

The Beacon service also provides a way for the phone to tell how close it is to the beacon. This can be useful for location aware applications, such as in a museum. For example, the smartphone reads a BLE Beacon with UUID = 0x98765....., Major Number=1, minor number = 0. The smartphone then looks this up in a database and find the UUID is for the Natural Science Museum, Major Number 1 = the Art Gallery room 1, and the minor number 0 = an abstract painting of a duck. If we assume all the paintings are spread out at 10feet each, then the application can sense when you are within 3 feet of the painting (based on signal strength of the Beacon) and give the user information about the painting they are approaching.

Technical Details

An iBeacon is just a normal Bluetooth LE device broadcasting advertisements with special data shoved into the Manufacturer Specific Data field.

The iBeacon prefix is little more than metadata about the advertisement packet.

BytesDatadescription
0,1,20x020106This sets the flags for General Discoverable and BR/EDR not supported
3,40x1AFFThis says the length of the Manufacturer specific data field will be 26 bytes
0,10x4C00Company ID
20x02ID
30x15length of remaining data in bytes (16B UUID+ 2B major, 2B minor, 1B Txpower)

Note that bytes 0-4 are set implicitly by the API by declaring the advertising data to be LE General Discoverable and BR/EDR not supported. The remaining fields that make up an iBeacon advertisement packet can be clearly seen in the image below.

http://www.havlena.net/wp-content/uploads/ibeacon-packet.png

For a more depth explanation please see these well done explanations:

Revisions of mbed.bld

Revision Date Message Actions
71:12660a3eb07d 2015-07-21 updating to the latest of the underlying libraries. File  Diff  Annotate
68:10ab1574c6dd 2015-06-19 updating to the latest of the underlying libraries. File  Diff  Annotate
67:643fca5e7ea5 2015-06-08 updating to the latest of the underlying libraries. File  Diff  Annotate
65:359308d229cc 2015-05-13 updating to Nordic's S130 and to the latest of BLE_API and nRF51 File  Diff  Annotate
63:e100e3e587f1 2015-04-30 updating to v8 of the Nordic SDK. File  Diff  Annotate
62:3774cc553029 2015-04-20 updating underlying libraries. File  Diff  Annotate
60:3034dc913ea1 2015-03-24 updating underlying libraries. File  Diff  Annotate
53:f9ec2c7a47f5 2015-02-12 Updated BLE_API library and mbed library, added iBeaconService.h and altered main.cpp to reflect the use of iBeaconService.h accordingly File  Diff  Annotate
49:2d05e684f9c3 2014-12-08 Changed the name of the example; File  Diff  Annotate
47:447eb23e67e2 2014-11-05 updating underlying libraries. File  Diff  Annotate
44:71ff94cd9c1d 2014-09-22 updating to 0.2.0 of the BLE_API File  Diff  Annotate
40:52e9de9e0186 2014-07-25 updating underlying libraries. File  Diff  Annotate
39:1dfed56efe26 2014-07-04 updating underlying libraries. File  Diff  Annotate
36:282289e1c629 2014-06-13 updating underlying libraries. File  Diff  Annotate
0:7613d21e5974 2014-03-31 First commit of iBeacon demo using the BLE API and native mode nRF51822 driver File  Diff  Annotate