The Uniform Resource Identifier Beacon (UriBeacon) defines Bluetooth 4.0 Advertisement Data that contain Web URIs. URIBeacon provides a way for Bluetooth Low Energy devices to discover nearby URIs, for example, provides a way for a user to discover a short URL and then download it on their smartphone.

Dependencies:   BLE_API mbed nRF51822

Fork of BLE_PhysicalWeb by Bluetooth Low Energy

This example demonstrates how to set up and initialize a basic URI Beacon. For a more advanced example of using a URI beacon please see the BLE_PhysicalWeb project. The Google Github Page also gives a great description of what UriBeacons are and how to use them.

Basic Details

URI Beacons are a standard way of providing a URI link in a BLE advertising packet. Website URL's are the most popular URI's. The goal of URI Beacons are to act as a bridge between the physical and digital worlds. Since the URI can be any web capable link the possibilities for use are really endless. The UriBeacons can be thought of as a natural extension of and more useful version of QR codes.

Smartphone App Links

iPhone Physical Web app

Android App

Walkthrough of Physical Web application

Size of URI

The UriBeacon has one purpose, to advertise a web link. Because of the nature of BLE these web links have to be small. In order to provide a nice balance of small and useful the UriBeacon specification has abstracted out the representation of the URI prefix('http://www.', 'https://www.' , ...etc) and suffix ('.com','.org','.edu','.gov' ...etc) to a single byte each. Of the 27 bytes available for a usual BLE payload the UriBeacon has 19 bytes available for the URI. Of these 19bytes one byte must be given to the prefix. That leaves 18 bytes to fit the address and the suffix into. If the suffix used is not one of the standard ones in the UriBeacon specification then each letter will take up 1 byte instead of the entire suffix being abbreviated into a single byte.

Here are the acceptable abbreviations currently available


So for example the address "" would take up 8 bytes. Both "http://www." and ".com" are supported abbreviations so each will be shortened to 1 byte.

Number of BytesData
1"http://www." abbreviated
6"google", 1 byte for each letter
1".com/" abbreviated

An address like "" would take up 11 bytes. Notice that ".ly" is not a supported suffix, so each letter takes up 1 byte.

Number of BytesData
1"http://www." abbreviated

Even addresses with the suffix in the middle are abbreviated, ie "". Notice here that the '.com' is in the middle of an address, it is still shortened to just 1 byte.

Number of BytesData
1"http://www." abbreviated
1".com/" abbreviated

Using UriBeacons with mbed BLE API

Using the UriBeacon with the mbed API is rather simple. Just like any other BLE project you must first initialize the BLE baselayer by creating a ble object.


BLEDevice ble;

Then you pass the BLE object to a UriBeacon config service.


URIBeaconConfigService *uriBeaconConfig;
uriBeaconConfig = new URIBeaconConfigService(ble, "");

Optionally you can then adjust settings of the UriBeacon such as transmission power levels, grabbing verbose debug information and other handy dandy services.


/* Adjust the TX Power Level */
    const int8_t powerLevels[] = {-20, -4, 0, 10};
    uriBeaconConfig->setTxPowerLevels(powerLevels); // Set TX power levels, Lowest(-20), Low(-4), Medium(0), High(10)
    uriBeaconConfig->setTxPowerMode(URIBeaconConfigService::TX_POWER_MODE_LOW); // Set transmission in Low power mode

/* Adjust Beacon Period*/
setBeaconPeriod(1000); // Set beacon to advertise every 1000ms

Other UriBeacon Services

This is just the bare basics of how URI beacons work. There is also a configuration service that allows URI beacons to be updated, locked, and provides other management feature. That is beyond the scope of this example but details can be found in the Technical Details section below.

Technical Details

For more details on how URI beacons work please see these websites:
UriBeacon Github Project : the github home for all things UriBeacon (maintained by google)
UriBeacon Specification : lots of good technical details
UriBeacon configuration service - This is a service that pairs with the UriBeacon that allows changing the URI's, locking them, and some other cool features. This service is not detailed in this example application.
Android App : smartphone application to view nearby UriBeacons.
iOS App : Sample code for using UriBeacons with iOS.
The PhysicalWeb Project : a project that the UriBeacon is central to.

In case you're really interested here is a diagram that nicely sums up how the 27bytes of advertising data payload are used.


RevisionDateWhoCommit message
29:5a1112254406 2015-12-10 rgrover1 updating underlying libraries to the latest. ; also fixed a bug in main() in the loop which waits for initialization to complete. default tip
28:061605602ef1 2015-11-06 rgrover1 updating to the latest of the underlying libraries.
27:6282226b1b8a 2015-08-11 rgrover1 updating libraries.
26:a2396234b4a8 2015-07-14 rgrover1 updating to the latest of the underlying libraries.
25:867bf234e47d 2015-07-02 rgrover1 updating to the latest of the underlying libraries.
24:2c2555bb5cba 2015-06-20 rgrover1 switch to newer APIs; replace BLEDevice with BLE
23:001aebcbac9a 2015-06-19 rgrover1 updating to the latest of the underlying libraries.
22:10326311af7e 2015-06-08 rgrover1 updating to the latest of the underlying libraries.
21:ccdec4b23476 2015-05-11 rgrover1 Updating to the latest of the underlying libraries.
20:7a64b463656d 2015-04-30 rgrover1 updating underlying libraries to v8.0 of Nordic SDK.;
19:982bbbc3fc96 2015-03-23 rgrover1 we now pass URIBeacon validator
18:569257e0af4e 2015-03-16 rgrover1 minor change to a comment.
17:e2c0a1696e39 2015-03-13 rgrover1 updated to the latest from BLE_API.; Moving persistence checking into the Nordic specific flash adaptor code.
16:1daa78939a3b 2015-03-09 rgrover1 updating the URIBeacon demo to the latest API for URIBeaconConfigService.; ; Hopefully the app has been simplified now.
15:44052a745782 2015-03-06 rgrover1 updating underlying libraries.
14:868a1207022d 2015-02-16 rgrover1 fix license header; and delete un-necessary nrfUriBeaconConfigService.h.
13:b82d8db73633 2015-02-13 rgrover1 Updating to Bill's version of the URIBeacon app
12:a60959597fb4 2015-01-22 rgrover1 updating to 0.2.10 of BLE_API.
11:c77cc2b74101 2015-01-21 rgrover1 adding implementation for nrfURIBeaconConfigService, which ports the platform-agnostic URIBeaconConfigService to the nRF51822 and implements lock persistence.
10:41db7f0bc677 2014-12-12 rgrover1 updating underlying libraries to their latest version
9:e7f47bec97b8 2014-12-04 mbedAustin Initial Commit of the URI Beacon example. A simplified version of PhysicalWeb .
8:b816829fb712 2014-12-03 rgrover1 config service remains avaialble for only 30 seconds.
7:6faec5978fb4 2014-12-01 rgrover1 updating to 0.2.6 of BLE_API.; Incorporated feedback from Bill Schilit regarding URIBeaconConfigService.
6:31b65d4ea67d 2014-11-28 rgrover1 Implementation for URIBeacon2; ;
5:e5b0bfe715d5 2014-11-05 rgrover1 merge
4:a72d66f900ec 2014-11-05 rgrover1 updating underlying libraries.
3:1d2526788eaa 2014-10-09 stevep replace http://www with http://
2:b7b8197d1a32 2014-10-08 rgrover1 white space diff.
1:65e87169548d 2014-10-08 rgrover1 removing un-necessary comments.
0:790a27ffc99b 2014-10-08 rgrover1 mbed's implementation of the Google PhysicalWeb