Developing Beacons With Bluetooth® Low Energy (BLE) Technology
Developing Beacons With Bluetooth® Low Energy (BLE) Technology
Developing Beacons With Bluetooth® Low Energy (BLE) Technology
with Bluetooth
Low Energy (BLE)
Technology
Table of Contents
Executive Summary ...................................................................................................................................... 2
Introduction .................................................................................................................................................. 3
What is a Beacon and How is it Used? ......................................................................................................... 3
Two Beacon Usage Models .......................................................................................................................... 4
Proximity-Aware Example Applications ....................................................................................................... 4
A Short History and Technical Overview of Bluetooth Low Energy Technology .......................................... 7
Bluetooth Generic Attribute (GATT) Profile ................................................................................................. 8
The Bluetooth Low Energy Technology Advertising Packet ......................................................................... 8
Beaconing Pseudo-Standards (iBeacon, Eddystone, AltBeacon) ............................................................... 10
Considerations for Designing a Beacon Product ........................................................................................ 12
Privacy and Security Issues ......................................................................................................................... 16
Summary..................................................................................................................................................... 18
Appendix 1 Example Code and Further Reading ..................................................................................... 19
Appendix 2 Detailed Frame Structure and Explanation of iBeacon, Eddystone, and AltBeacon ............ 19
Additional References ................................................................................................................................ 25
Executive Summary
Bluetooth beacons are taking off. They enable proximity-aware applications for customers, businesses, and
industrial environments.
-
End customers benefit through instant coupons and tailored offerings based on where they are.
Businesses benefit through improved visibility to customer buying habits and increased loyalty.
Industrial companies benefit through improved asset monitoring and utilization.
The possibilities are endless, and beacons are set to transform our world. But before they doyou should know
that implementing them can be challenging. Putting beacons on a product, pushing their data into the cloud and
then using it create value all represent new development frontiers for many of us.
Its not straightforward. Did you know that Bluetooth beacons are not, in fact, a Bluetooth standard? Bluetooth
beacons are pseudo-standards running on Bluetooths low energy technology (previously known as Bluetooth
Low Energy, BLE, or Bluetooth Smart), but they use proprietary beacon code beyond that.
This paper covers a lot of territory.
-
To begin, once a beacon developer is ready to start, they need to focus on several key items.
1. Select a widely-adopted, proven Bluetooth stack. Because beacons are new, there is room for FUD from
new entrants. Buyer beware. Use a company that understands low-energy Bluetooth and has the
market adoption to prove it.
2. Select a company with proven software development tools. Software development is more than just an
editor and debugger. It also needs to include mature example code for common use cases, scripting
engines for common commands, and thoughtful APIs for ultimate migration from one standard revision
to another. These tools will all work together to speed development.
3. Select a company with good customer support. This goes hand-in-hand with a market-proven stack and
software tools; if the selected company is market-proven, then they have support forums with hundreds
of questions and answers on hardware and software, an adequate user base and support staff to answer
new ones, a broad portfolio of product variants for different applications, and so on.
Good luck! Read on
Introduction
Bluetooth beacons will have a transformative impact on the way we interact with the physical world. They enable
proximity-based contextual awareness using technology that most of the worlds population now carry in their
pocket a smartphone with applications.
Using wireless technology for proximity detection is not new, but with the introduction of Bluetooths low energy
features1 in 2009, beacons are now being deployed on a wide-reaching scale.
This article explains how beacons work, some of the ways they can be used, and design considerations for
beacon product development.
Beacons are generally used for proximity-aware applications. By monitoring beacons, a device can detect when it
has entered or exited a particular area, and then use that information to create interactive experiences based on
whats nearby. The group proxbook.com provides a list of such proximity-aware applications.
There is no official Bluetooth Special Interest Group (SIG) beacon standard. Instead, there are various beacon
pseudo-standards from company consortiums or large operating system providers. Each pseudo-standard takes
advantage of some of the Bluetooth low energy technologys native facilities and the widespread availability of
Bluetooth itself. The more prominent pseudo-standards are Apples iBeacon, Googles open source
Eddystone, and Radius Networks AltBeacon.
Platform
Apple iOS
Apple Mac
Google Android
* Note that this table shows only native-OS support. Each major OS supports other beacon types as well with relevant applications.
The Bluetooth Special Interest Group (SIG) recently rebranded to remove sub-brands Bluetooth SmartReady and
Bluetooth Smart to reflect only Bluetooth with common language to describe any relevant sub-features. For example,
Bluetooth Smart is now referred to as Bluetooth low energy technology. See Bluetooth.org for more information.
network. The cellular wireless connection is more secure than a local one, and they never have to remove their
wallet!
This same use case is emerging at fast-food drive-throughs. When the driver approaches the beacon-enabled
drive-through equipment, their smartphone detects the beacon and activates customized offers. The same
application can also optimize inventory management based on customer usage.
Imagine viewing the Mona Lisa at The Louvre Museum in Paris, only this time she has a beacon. Your
smartphone would detect the beacon and present you with The Mona Lisa Wikipedia page, a biography of
Leonardo da Vinci, and a history of the famous Peruggia theft of 1911. Finally we know why she is smiling!
Now we know why Mona Lisa is smilingshe has her own Bluetooth beacon!
Beacon Proximity Accuracy
Obviously, proximity-aware applications rely upon knowing which beacons are nearby. But a beacons RF range
can vary from under a meter, to just a few meters, to over 500 meters depending on its transmit power 2. This
makes it impractical to determine proximity based solely on receiving a beacon identifier packet.
For this reason, beacon proximity relies on a comparison of a Received Signal Strength Indicator (RSSI) to a
beacons transmit (Tx) power to approximate the distance to the beacon. Beacons provide a calibrated transmit
(Tx) power figure in their advertising packets. Coupling this information with the RSSI enables a receiving device
to approximate how far away the beacon is. Unfortunately, this calculation cannot be very accurate since RF
signals fade unpredictably according to real-world environmental factors like walls, weather, and people. Luckily,
approximate distance is generally good enough for proximity applications since the typical intent is just to
determine whether the beacon is close by or far away (e.g., 1 meter, 10 meters, or 100 meters).
Bluetooth low energy transmit power was limited to 10 mW until Addendum 5 was released in December 2015, increasing the maximum
allowable Tx power to 100 mW, and providing up to 2.5x more range.
Future versions of the Bluetooth specification will likely incorporate Angle-of-Arrival (AoA) and Angle-of-Departure
(AoD) features which allow a multi-antenna Bluetooth device to accurately determine the spatial location of
another Bluetooth device3. These features will enhance Bluetooths usefulness in applications requiring highaccuracy location detection, potentially giving position accuracy to within tens of centimeters. This level of
precision would enhance the effectiveness of beacons when used in asset management applications.
Bluetooth BR/EDR, Bluetooth Smart Ready, and Bluetooth Smart (BLE) (See footnote 1 above)
Three of Bluetooth low energy technologys 40 channels (37, 38, and 39) are reserved for broadcasting
advertising packets that contain information about the broadcasting nodes capabilities. These advertising
packets are strategically located on frequencies between the three 2.4 GHz Wi-Fi channels to avoid interference
from Wi-Fi.
Bluetooth advertiser nodes use advertising packets in channels 37, 38, and 39 to advertise
their supported GATT profiles.
Scanners receive the advertising packets, decode them, and take action.
Both advertising packets and data packets use the same format (see figure below). Beacons follow the standard
advertising packet format, but then format the embedded data payload to follow a pre-defined structure for the
beacon pseudo-standard it uses. This allows the OS to treat a beacons advertising packet differently from other
Bluetooth advertising packets.
Bluetooth low energy packet format is the same between data packets and advertising packets
Bluetooth low energy devices transmit advertising packets on a selectable interval as short as 20 milliseconds or
as long as several minutes. The same packet is sent on all three of the advertising channels every time the device
advertises, making it more likely that a scanner will pick it up.
Within the advertising packet, the data payload is structured as one or more [length, type, data] triplets.
-
The length field defines the combined size of the subsequent type and data fields;
Followed by the type field which designates whether the data is a name, a service UUID, a Universal
Resource Identifier (URI), or one of many other defined data types; and
Beacons take the structure a step further, defining a sub-structure inside the data field as shown in the following
sections on the various pseudo-standards.
Transmitting a single beacon packet can take up to 376s4, but could be shorter depending on which beacon
standard is followed. How frequently a beacon advertises is a trade-off between power consumption and the
tolerable application latency.
In a more conventional, non-beaconing Bluetooth low energy application, advertising packets provide identifying
information about the advertisers services and are then followed by a period of time in which the advertiser
actively listens for a connection requests from scanners which want access to those services.
However, beaconing Bluetooth applications will typically use non-connectable advertising, essentially fire-andforget, providing all of their useful information in the advertising packet itself. Since they generally dont listen for
connection requests, the radio can be shut off immediately after advertising, further extending battery life.
Its important to note that some beaconing applications include other GATT services in addition to the beacon,
and those services may interleave connectable advertising packets with the non-connectable beacon packets. In
this case the beacon performs a more typical advertising cycle with transmit/listen operations.
10
Eddystone-TLM which can be used to broadcast telemetry (health and status) data about the beacon
itself; and
The Eddystone-URL frame enables mobile platforms to offer web content based on proximity without requiring an
app to be installed, enabling what Google has dubbed The Physical Web, or the ability to walk up and use
anything.
Eddystone logo
Eddystone is already supported in Chrome for iOS, and will be supported in Chrome for Android beginning with
version 49. With the Chrome Today widget, users can access web content relevant to their surroundings, and
receive notifications when encountering beacons.
Googles Physical Web uses Eddystone-URL beacons to allow iOS and Android users to
walk up and use anything in their beacon-tagged surroundings.
The Google Eddystone GitHub page provides the Eddystone Protocol Specification along with tools and open
source code examples, and the Google Developers forum provides more information about the Google beacon
platform. The full Eddystone beacon format is described in detail in the Appendix.
AltBeacon
Radius Networks defined the AltBeacon specification in an attempt to create an OS-agnostic, open-source
standard which wouldnt favor any particular vendor. The specification is available on the AltBeacon website and
is free to use without royalties or licensing fees. Like other beacons, it uses non-connectable, undirected
advertising packets. The full packet format is described in the Appendix.
AltBeacon logo
11
Typical pre-certified Bluetooth low energy beaconing module and Bluetooth SoC reference design
The whitepaper Six Hidden Costs in a 99 Cent SoC provides a good discussion of the
trade-offs to consider when choosing a module or SoC for a Bluetooth beacon.
12
Software
Its fundamentally important to choose a widely deployed and field-proven Bluetooth stack. Most often, this market
success is more important than any promises of new cutting edge features. Market success indicates good
customer support and a stable stack, both of which help get to market quickly.
For beacons in particular, its very important that the protocol efficiently manages sleep modes. When a beacon
broadcasts on 100 ms intervals, it only transmits for about 1 ms and sleeps for the other 99; thus spending 99% of
its life in sleep mode.
Some proven protocol stacks include special features designed specifically to make Bluetooth and beacons more
power efficient. One example is the ability to define multiple beacon frame types (iBeacon, Eddystone-URL, etc.)
along with their timing parameters which the stack can then interleave autonomously without the more powerhungry application code running.
Other important software features include watchdog timers as a fail-safe mechanism, real-time clocks to set
beacon on/off cycles to preserve power, and the ability to support firmware updates.
Beacon Application Code
Beacon application code can be relatively simple and implemented with a high level programming language like
BGScript from Silicon Labs. BGScript is a simple, high-level, BASIC-like programming language thats human
readable and allows Silicon Labs devices to run standalone without an external processor.
The benefit of this type of high-level programming language is that the developer can focus on the application
itself without concerning himself/herself with the timing and complexities of the protocol stack underneath. See
below for a simple commented code example for implementing an iBeacon in BGScript.
13
BGScript iBeacon example code for the BGM111 Bluetooth low energy module
This example code supports the BGM111 module and is implemented with only 38 lines (most of it comments).
The codes advertising packet is constructed to use the Apple AirLocate Service UUID of 74278bda-b644-45208f0c-720eaf059935, with major and minor fields of 0x00, meaning they are unset. The calibrated Tx Power value
of 0xD0 correlates to -48 dBm at one meter. (The BGM111 has +8 dBm of Tx power.)
This is a very basic example of an iBeacon implementation, but a more robust implementation might include the
ability to change the beacons UUID and major/minor values through the over-the-air interface, and possibly
include provisions for updating the beacons firmware.
14
Battery Life
As with any product, the size of the battery versus its power consumption will determine its operating life. Battery
size is sometimes dictated by the beacon industrial design, so a compromise must be made between battery life
and the physical constraints of the final product.
The beacons transmit power and beaconing interval also play an important role in battery life. These parameters
are typically trade-offs against the desired range and proximity accuracy. Higher transmit power provides longer
range and a wider coverage area, but the transmitter will draw more power from the battery for each beacon
event. The application usage model needs to be considered: Will the application benefit from a larger coverage
area? Or is it better to have its proximity limited to a few square meters?
Likewise, the beaconing interval is an important factor in determining a beacons battery life. A beacons power
consumption peaks at several milli-amps while transmitting. Otherwise, it only draws micro-amps while in deep
sleep.
A beacons average battery life is determined by transmit power and its transmit / sleep duty cycle
There are important trade-offs for short versus long transmit cycles, including operating life
and location accuracy.
With transmit power constant, short cycles provide more data points for better location,
while longer cycles provide worse location accuracy but longer battery life.
In terms of performance, a shorter beaconing interval means there are more beacon events to capture, providing
more motion resolution and therefore better location accuracy. A longer interval means the beacon will have
longer battery life but fewer opportunities to get captured, especially by a moving smartphone.
15
Beacon interval also plays a role in smartphone application response times. When apps are in the background,
the OS scans for beacons less frequently, so a more frequent beacon interval increases the likelihood of detection
and resulting activity.
Current profile in a typical Bluetooth low energy advertising event (ADV PDU)
Smartphones can use GPS, Wi-Fi, cellular, and Bluetooth beacons for
proximity-aware applications.
And users can disable them all in settings.
Similarly, concerns have been raised about beacons creating added security risks for IT systems. But this again
implies capabilities that most beacons do not have. The typical beacon is a standalone device with no connection
to any other network, wired or wireless.
However, some beacons are designed with infrastructure network access which allows for central management of
a beacon fleet. In these cases, the beacon manufacturer provides the same level of tamper security as they would
16
for any other device attached to their IT network. On the beaconing side, the beacons data is, by design,
broadcast for all to hear so does not necessarily need to be encrypted or protected in any way.
In beaconing applications where proximity to the beacon may have tangible value, such as reward points for
example, the beacon OEM will implement additional safeguards against beacon spoofing. Without them, spoofed
beacons might fool the system into crediting events too often or to the wrong person. The safeguards could
include simple timestamps for each proximity event with a test for an improbable or unanticipated frequency, the
use of ephemeral IDs, or the use of randomized security keys, generated with each proximity event and validated
by the back-end system.
Security for Device Management Functions
In general, Bluetooth security isnt a concern with beacons since by definition they are broadcast devices with the
intent that any listener can receive the data.
But if the device includes other internal services like device management functions, then those services might be
protected and require authentication before allowing access. In those cases, the beacon will use the security
features built into the Bluetooth protocol (i.e., pairing, authentication, encryption, etc.) and other security
measures implemented by the beacon OEM such as strong password protection.
The most common device management functions are used to configure the beacon during the provisioning, and
access to those services may be limited to a short window of time after the device is reset. After the access
window expires the device becomes a normal broadcast beacon and no longer advertises its internal services.
Provisioning / Deploying the Beacon
When beacons are deployed in the field, its often necessary for the installer to configure the beacon to the
installation, for example by writing a unique major/minor value or instance ID. The most obvious (and most
desirable) way to do this is to take advantage of the over-the-air interface. But exposing the configuration services
over Bluetooth can provide a potential channel for unauthorized access, and the extra advertising packets for the
configuration services can have a significant impact on battery life.
A simple, commonly used solution is to limit exposure of these services to a short window of time either just after
power-up, or after a trigger from a physical input such as a pushbutton or reed switch. This is illustrated below.
During the configuration window, the beacon is connectable (with appropriate authentication) so that the
provisioning configuration can be written into it. Once the timer expires, it reverts to only advertising the nonconnectable beacon packets, effectively hiding the configuration services.
17
Summary
Its hard to imagine we all wont be touched by beacon applications in the near future. Indeed, they may be the
next killer app. Product designers across hundreds of industries will have lots of new challenges to address as
they move to adopt wireless. Choosing the right vendor with innovative technology, a market-proven stack, and
great customer support will help ensure the developer has a smooth experience and a superior final product.
Silicon Labs is an established leader in Bluetooth low energy and beaconing technology, development tools, and
a broad portfolio of Bluetooth beacon-capable SoCs and pre-certified Bluetooth modules.
18
Appendix 2 Detailed Frame Structure and Explanation of iBeacon, Eddystone, and AltBeacon
Apples iBeacon
Apple was an early adopter of beaconing and calls their implementation iBeacon. The iBeacon term is
trademarked by Apple, and vendors who want to sell iBeacon products or use the iBeacon logo must obtain a free
license from Apple. The iBeacon specification and other developer resources can be downloaded from the Apple
Developer website.
iBeacon specifies a 30 byte packet which must be broadcast on 100 millisecond intervals (although iBeacon
OEMs dont always seem to adhere strictly to the 100 ms requirement). The packet structure is shown in Figure X
and explained below.
19
Eddystone-TLM which can be used to broadcast telemetry (health and status) data about the beacon
itself.
20
Eddystone-EID which uses ephemeral (short lived) identifiers for beacon applications requiring more
security. The specification for this frame format has not yet been released.
The Eddystone-URL frame enables mobile platforms to offer web content based on proximity without requiring an
app to be installed first, enabling what Google has dubbed The Physical Web. The Eddystone Protocol
Specification along with tools and open source code examples are on Googles Eddystone GitHub page. The
Eddystone beacon format is shown below with each frame type described.
21
NID = ten byte namespace ID. To ensure uniqueness, the recommended format for the
namespace identifier is to use either SHA-1 hash of a qualified domain name, or an elided UUID
with bytes 5-10 removed.
BID = six byte instance ID which does not need to adhere to any specific format.
RFU = two bytes reserved for future use
Eddystone-URL: The Eddystone-URL frame type advertises a URL using a compressed format for
internet resources accessible with hyper-text transfer protocol (HTTP or HTTPS).
Frame type 0x10 = Eddystone-URL frame type
Tx power (one byte) = a signed 8-bit integer indicating the beacons Tx power in dBm measured
at 0 meters. This can be calculated by measuring Tx power at 1 meter and adding 41 dBm.
URL scheme = one byte which designates the URL prefix. For example 0x00 = http://www.
Encoded URL = up to 17 bytes for the URL using ASCII encoding. If character codes are used
which are not allowed by IETF RFC 1738, then they are interpreted as expansion codes. For
example 0x00 is an invalid character code, and gets translated in the Eddystone-URL beacon as
.com/. Using the compressed format for the URL http://www.silabs.com would result in:
00 73 69 6c 61 62 73 00
For the full list of prefixes and expansion codes which can be used, refer to the Eddystone-URL
spec on the Eddystone GitHub page. They are also shown in the detailed chart below.
To shorten a URL which is longer than 17 bytes, there are many several URL shortening services
on the web such as goo.gl and bit.ly.
Eddystone-URL packet
22
Eddystone-TLM: The Eddystone-TLM frame type allows the beacon to broadcast information about its
own internal operations, which can be used to monitor the health of the beacon. Since TLM frames dont
contain any identifying information they must always be interleaved with either a URL or UID frame to
enable association to the correct beacon. The TLM frame has a fixed length so the Service Data length
byte should always be 0x11.
Frame type 0x20 = Eddystone-TLM frame type
TLM version 0x00 = one byte indicating the version. This is to allow future enhancements and
should always be set to 0x00.
VBATT = two bytes indicating the battery voltage with a resolution of 1 mV/bit. If not supported,
the value should be 0x0000
TEMP = two bytes indicating the beacon temperature in degrees C, and represented using 8:8
fixed point notation (the first byte indicating the signed integer portion and the second byte
indicating the fractional portion). For example, 1.5 C is represented as 0x0180 and -1.5 C is
represented as 0xFE80. If not supported the TEMP value should be set to 0x8000.
ADV_CNT = four bytes indicating the number of advertising events (of all frame types) since the
last reset.
SEC_CNT = four bytes indicating the elapsed time since the last reset in 0.1 second increments.
A four byte value provides enough scope to show 13.5 years of continuous operation.
AltBeacon
The AltBeacon specification was defined by Radius Networks in an attempt to create an open-source, OSagnostic standard for proximity beacons which wouldnt favor any particular vendor. The specification is available
on the AltBeacon website at www.altbeacon.org and is free to use without royalties or licensing fees. Like other
beacons, it uses non-connectable, undirected advertising packets. The packet format is shown and described
below. The current specification does not define a particular beacon timing interval.
AltBeacon Packet
Flags: These first three bytes follow the [length, type, data] structure explained above, and indicate:
Length 0x02 = 2 bytes
Type 0x01 = flags
Value 0x06 = (non-connectable, undirected advertising, single-mode device)
Beacon Identifier: The remainder of the packet is the beacon identifier:
Length 0x1B = 27 bytes (the remainder of the packet)
Type 0xFF = manufacturer specific data
23
Value = the manufacturer specific data is further sub-divided into the following fields:
Mfg ID: Two bytes which define the beacon manufacturers identifier from the Bluetooth SIG assigned
numbers database.
Beacon Code: Two bytes always set to 0xBEAC
Beacon ID: A twenty byte value which uniquely identifies the beacon. The first sixteen bytes of this field
should uniquely identify the organization
Reference RSSI: A signed one byte value indicating average received signal strength at 1m from the
beacon. The range is from 0 to -127.
Mfg Reserved: A one byte value reserved for use that is defined by the beacon manufacturer.
24
Additional References
Specification of the Bluetooth System, Covered Core Package version: 4.2 (2014, Dec 2). Retrieved from
https://www.bluetooth.com/specifications/adopted-specifications.
Bluetooth Core Specification Addendum 5 (2015, Dec 15). Retrieved from
https://www.bluetooth.com/specifications/adopted-specifications.
Gast, M. (2014). Building Applications with iBeacon, Sebasopol, California: OReilly Media, Inc.
Statler, S. (2016). Beacon Technologies: The Hitchhiker's Guide to the Beacosystem, New York, NY: Apress
Media LLC.
Heydon, R. (2012). Bluetooth Low Energy The Developers Handbook, Upper Saddle River, New Jersey:
Pearson Education, Inc.
Proximity Beacon Specification R1 (2015, Sep 4). Retrieved from https://developer.apple.com/ibeacon.
Eddystone Protocol Specification. (n.d.) Retrieved from https://github.com/google/eddystone/blob/master/protocolspecification.md.
AltBeacon Protocol Specification v1.0. (n.d.) Retrieved from https://github.com/AltBeacon/spec
Bluetooth SIG (2015) Bluetooth Smart Technology: Powering the Internet of Things
https://www.bluetooth.com/what-is-bluetooth-technology/bluetooth-technology-basics/low-energy
Six Hidden Costs in a 99 Cent Wireless SoC (2015). Retrieved from
http://www.silabs.com/Support%20Documents/TechnicalDocs/six-hidden-costs-of-a-99-cent-soc.pdf
25