DEVELOPERS BLOG

iBeacons™ aren’t the only Fruit!

CASCADES / 09.26.14 / jcmurray2012

Introduction

I was really interested to discover recently that the iBeacon™ technology specification that Apple™ has written isn’t the only Beacon specification out there. AltBeacon (http://altbeacon.org/ ) is described as “The Open and Interoperable Proximity Beacon Specification” by Radius Networks, which has blogged about the reasons it has introduced a new standard into the Beacon space.

This specification seems to have attracted a fair amount of interest recently with implementation being shown on various platforms such as Android, iOS, RaspberryPi and Arduino, to name a few. Well, this seemed like a challenge to me. I was sure I could demonstrate that BlackBerry 10 was flexible and agile enough to be able to accommodate this new, open specification. Here’s how I did it.

The Use-Case

I’d already written a couple of sample applications that use iBeacon™ technology –WheresMyBeacon and WakeMeByBeacon – so I thought I’d take these two applications and add AltBeacon support to them, along with iBeacon™ support. That meant taking a look at the AltBeacon specification itself: https://github.com/AltBeacon/spec.

What is AltBeacon?

In the same way that iBeacon™ is a structure imposed on the Bluetooth Low Energy Manufacturer’s field in the Bluetooth Low Energy Advertisement Protocol Data Unit (PDU), so is AltBeacon. You can find the diagram below on the AltBeacon specification web site (https://github.com/AltBeacon/spec):

2

At first glance, this looks similar to the iBeacon™ format and, as such, easy to access and parse in BlackBerry 10. The key difference is that while the iBeacon™ format mandates that the Manufacturer Id should be Apple’s (0x004c), AltBeacon doesn’t. A company could use their own Manufacturer Id to further allow interpretation of the other fields, including the Beacon Id, which is just 20 octets of data with no structure imposed on it. As with iBeacon™, it has a Reference RSSI field (the power of the beacon measured in dBm at 1m from the beacon) so that you can gauge proximity in the same way you can with iBeacon.

This looked simple enough, but I had one problem: I didn’t have a real AltBeacon to test with. So I built one!

My AltBeacon Implementation

Here’s my AltBeacon. I used a nice piece of kit from CSR  called the CSR µEnergy® Starter Development Kit. You can see it in the diagram below, in the red box, attached to a programmer (the blue object with USB and SPI cables attached). Pre-empting myself a little, you can also see my BlackBerry 10 device running my updated version of WakeMyByBeacon detecting the AltBeacon.

3

The CSR SDK allowed me to write a simple AltBeacon implementation in “C”. Here’s a fragment of the code that constructs the Advertisement Payload:

4

You can see where I specify the Advertising Frame payload in the red box above and then store it and instruct the device to start advertising using that payload. I’ve also used the BlackBerry Limited Manufacturer Id of 0x003c (encoded using little-endian as {0x3c, 0x00}) and fixed the Reference RSSI field as 0xc2 – a nice small negative number to represent a realistic dBm value. It was quite easy.

5

The next part was to modify the class in my BlackBerry 10 applications that parses the Advertisement data: BtleAdvertData. The code fragment above shows how the main elements of the AltBeacon payload are parsed in BlackBerry 10.

With just one or two other changes to display the different beacon data types on the handset, I fired up the CSR board and my updated WakeMeByBeacon application. Here’s a screenshot of it working:

6

You can see that it has detected an Estimote iBeacon™, which is somewhere nearby, as well as the AltBeacon running on the CSR board. Also notice that I was able to interpret the BlackBerry Limited Manufacturer Id field correctly in the BlackBerry 10 application.

That’s pretty much it!

Summary

I’ve released V1.1.0 of the WakeMeByBeacon and V2.1.0 of the WheresMyBeacon applications, which now contain the additional AltBeacon feature described in this article, so you can download, review and reuse the full source code. You can find the URLs in the “Resources” section below. I hope this has been interesting and will help set you on your way toward developing real-world beacon applications for Blackberry 10.

Please feel free to contact myself (@jcmrim via Twitter) if you need help on anything related to Bluetooth Low Energy.

Resources

BlackBerry Bluetooth LE Developer Resource Index Page

WakeMeByBeacon Application Project on GitHub

Wheres My Beacon? Using beacon technology in mobile app development – Blog Post 1

Beacon testing and configuration using Blackberry 10 – Blog Post 2

WheresMyBeacon Application Project on GitHub

BlackBerry 10 Headless Applications

Annual Leave Application Exhibiting a Common Enterprise Mobile Architecture

Contacts

John Murray – @jcmrim

About jcmurray2012