Google has an interesting initiative called the Physical Web, which aims to enable any device to broadcast a specific URI (e.g. website) that users can detect with their cellphone/tablet and navigate to. The aim is to provide a standard, light-weight 'window' into any networked device.
The concept is similar to Apple's iBeacon, in that a specially formatted Bluetooth Low Energy (BLE) advertising packet is sent out from a radio to anyone in the radio range, and a listening app on the mobile phone that can pick the packets up and alert users. To demo, we'll be using the official Physical Web apps available for Android and iOS.
Instead of advertising 128-bit UUIDs like iBeacon, Google defines an (open!) standard they call UriBeacon which advertises URIs, typically a shortened web address.
The primary use case is enabling any device to advertise a web-address where users can interact with the object, or where further information about the device can be found.
A vending machine might redirect you to a payment system, for example, or a sensor node might redirect you to the web interface where the sensor data and it's history can be searched and navigated.
The Bluefruit LE Friend from Adafruit already include everything you need to advertise as UriBeacon nodes.
You simply need to tell the BLE Friend what URI you want it to advertise. To do that, we'll create a specially formatted advertising packet that contains your short (or shortened) URI, and tell the Bluefruit LE Friend to advertise with that packet instead of the default data.
The full UriBeacon advertising packet specs are available online in the UriBeacon Github repo:
Simply enter your URI into the textbox below and click the generator button:
Make sure you start with http:// or other valid URI prefixes! For example, here's the output for "http://www.adafruit.com"
Once you have the advertising packet generated with the above tool, insert your Bluefruit LE Friend into your USB port, put it in 'Command Mode', open up your favorite terminal software, and enter the AT+GAPSETADVDATA command with the UriBeacon payload.
For example, if we used http://www.adafruit.com as our URI, we would enter the following command:
This should generate an 'OK' response if everything went OK, and you can reset your device to get a clean start with the following command:
To detect the UriBeacon advertising packets, simply open up the Physical Web application on your BLE-enabled Android or iOS device.
You will see a scanning icon similar to the image below (Android app):
Once a node is detected, you'll see the advertised URI (which should be expanded if you used a popular shortening service like bit.ly to stay within the size constraints of BLE advertising packets, which must be 27 bytes or smaller):
The AT+GAPSETADVDATA command will store the values you supply in non-volatile memory, and they will be used as soon as the device powers up.
To clear the data and reset your Bluefruit LE Beacon to normal operating mode, simply enter the following command in Command Mode: