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.
Bytes | Data | description |
0,1,2 | 0x020106 | This sets the flags for General Discoverable and BR/EDR not supported |
3,4 | 0x1AFF | This says the length of the Manufacturer specific data field will be 26 bytes |
0,1 | 0x4C00 | Company ID |
2 | 0x02 | ID |
3 | 0x15 | length 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.
For a more depth explanation please see these well done explanations:
- iBeacons – How do they (technically) work? : a great explanation of Beacons and especially iBeacons
- How do iBeacons work? : a great leymans overview of iBeacons and Beacons at large by extension
Revision 79:4e16bde5c10a, committed 2016-09-20
- Comitter:
- Vincent Coubard
- Date:
- Tue Sep 20 12:41:28 2016 +0100
- Parent:
- 78:88531e13c8e7
- Commit message:
- Update libraries.
Add ST shield via config system.
Changed in this revision
diff -r 88531e13c8e7 -r 4e16bde5c10a BLE_API.lib --- a/BLE_API.lib Mon Apr 11 16:23:21 2016 +0000 +++ b/BLE_API.lib Tue Sep 20 12:41:28 2016 +0100 @@ -1,1 +1,1 @@ -http://mbed.org/teams/Bluetooth-Low-Energy/code/BLE_API/#66159681aa21 +https://developer.mbed.org/teams/Bluetooth-Low-Energy/code/BLE_API/#65474dc93927
diff -r 88531e13c8e7 -r 4e16bde5c10a mbed.bld --- a/mbed.bld Mon Apr 11 16:23:21 2016 +0000 +++ b/mbed.bld Tue Sep 20 12:41:28 2016 +0100 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/99a22ba036c9 \ No newline at end of file +https://mbed.org/users/mbed_official/code/mbed/builds/abea610beb85
diff -r 88531e13c8e7 -r 4e16bde5c10a mbed_app.json --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed_app.json Tue Sep 20 12:41:28 2016 +0100 @@ -0,0 +1,13 @@ +{ + "target_overrides": { + "K64F": { + "target.features_add": ["BLE"], + "target.extra_labels_add": ["ST_BLUENRG"], + "target.macros_add": ["IDB0XA1_D13_PATCH"] + }, + "NUCLEO_F401RE": { + "target.features_add": ["BLE"], + "target.extra_labels_add": ["ST_BLUENRG"] + } + } +} \ No newline at end of file
diff -r 88531e13c8e7 -r 4e16bde5c10a nRF51822.lib --- a/nRF51822.lib Mon Apr 11 16:23:21 2016 +0000 +++ b/nRF51822.lib Tue Sep 20 12:41:28 2016 +0100 @@ -1,1 +1,1 @@ -http://mbed.org/teams/Nordic-Semiconductor/code/nRF51822/#f7faad332abc +https://mbed.org/teams/Nordic-Semiconductor/code/nRF51822/#c90ae1400bf2
diff -r 88531e13c8e7 -r 4e16bde5c10a shields/TARGET_ST_BLUENRG.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/shields/TARGET_ST_BLUENRG.lib Tue Sep 20 12:41:28 2016 +0100 @@ -0,0 +1,1 @@ +https://developer.mbed.org/teams/ST/code/X_NUCLEO_IDB0XA1/#fa98703ece8e