Monday, 24 March 2014

iBeacon Scanner - Example Android App and Source Code

If you happened to be walking through Coventry's West Orchards Shopping Centre at lunchtime last Saturday, you may have found yourself wondering "who is this guy wandering up and down staring at his Nexus 4 rather than looking at the many fine bargains on display?"

I'm slightly embarrassed to admit that was me; I was obsessing over iBeacons again, rather than doing my bit to help the economic recovery with some weekend discretionary spending. Why was I staring at my phone? Well, I thought I'd see for myself whether the iBeacon wave had broken over my local provincial shopping mall.

So I fired up an app that I'd hacked together, by taking some code from a sample app and the open source Android SDK provided by Radius Networks to do the ranging, then tweaking the UI and adding some code to output the results.

Here's the screen that's displayed when the application is launched: the button to start scanning...

...and when you're ready press the button again to stop.

Note the toast pop up confirming that a file has been created; the file contains whatever data was displayed on screen during the scanning session.

Source code for the app and an Eclipse project are available here on GitHub. If you'd like to side load the app you'll find the IBeaconPoC.apk file in the /bin directory (here's a brief "how to" on side loading which should help if you've not tried side loading before).

The app can be easily modified or extended. You'll note just the major and minor IDs, RSSI and proximity are logged, along with a simple counter. This is done via hard coded concatenation right now but it would be simple enough to allow which items were logged, and in what order, to be selected by the user at run time. It would also be fairly trivial to push logged data off the device via a wireless connection, to a web service or ftp site for example. That's a couple more use cases added to my to do list...

So, back on the question I asked earlier: has the iBeacon wave broken over Coventry? least not at the time of writing. I'm afraid I didn't detect a single solitary iBeacon - not even from the local Apple retailer. ;-)
Post a Comment