door: Vincent Hoogendoorn - gepubliceerd op 25-4-2014
Note that there is no Windows Phone in this picture. This is because the brand-new Bluetooth Low Energy (BLE) support in Windows Phone 8.1, which became publicly available last week as a developer preview, does not include BLE beacon support (and neither does Windows Store 8.1).
In this post I will show the why, with what and how of building iBeacon functionality in iOS and Android Apps, and what I have learned along the way – including how I verified the current limitations of the Bluetooth Low Energy support in Windows Phone & Store 8.1.
iBeacons provide real-world context for your apps with micro-location information – outdoors and indoors.
Since the introduction of iBeacons by Apple in mid-2013, more and more companies see opportunities for using Bluetooth Low Energy (BLE) beacon technology in mobile apps. iBeacon is both a brand and a standard for BLE beacons by Apple; BLE beacons from most manufacturers are iBeacon compatible. BLE beacons allow apps on iPhones, Android phones and other mobile devices to respond automatically when a user gets close by – even when the app is not running in the foreground or when the phone is locked.
Most BLE beacons are small, cheap ($5 - $30), battery or USB powered devices. BLE beacons typically have a maximum range of 50-70 meter (in reality half that) and work well indoors as well as outdoors. This complements the capabilities of other proximity and location technologies: NFC has a range of only 4-20 cm (and is not supported on Apple devices), while GPS is less accurate and does not work well indoors.
BLE beacons provide two types of functionality: geofencing aka region monitoring to signal an app when someone enters or leaves a geographic area, and proximity aka ranging to determine how close someone is to a beacon. Ranging only works when an app is running in the foreground, while region monitoring also works when an app is not running (on iOS 7.1, the app does not even have to run in the background, which means that once the app has run once it will never stop responding until the user uninstalls it, revokes the Bluetooth permission for the app, or turns off Bluetooth altogether).
The combination of greater indoor range, accuracy, low energy usage in apps, mobile or stationary beacons and cheap hardware enables many new real-world scenarios. Common scenarios are for retail stores, restaurants, gyms, events and other situations where consumers visit (indoor) locations.
Typical applications are marketing (combining online behavior with detailed on premise behavior, sending special offers on entering a store), customer service (provide detailed information on-site; e.g. how do I work this machine in the gym?), waiting times (know how many people are in line before I go there?), social (automatic check-in), payment (with PayPal or mobile wallets)… and then there are the scenario's where the beacons themselves are also mobile (on people, pets, key chains, cars…).
Beacons that are compatible with Apple's iBeacon standard will work with devices that have Bluetooth 4.0 and iOS 7.0+ (e.g. iPhone 4S+, iPad 3+), Android 4.3+ (e.g. Samsung Galaxy S3/S4/S4 Mini, Samsung Galaxy Note 2/3, HTC One, Google/LG Nexus 7 2013 version/Nexus 4/Nexus 5, HTC Butterfly), or OS X Mavericks 10.9+ (e.g. a MacBook Pro).
There are many brands of beacons, differing widely in size, looks, features and price. However the actual hardware specs and cost is just part of the decision which beacon(s) to use.
Other important considerations are the backend services that serve as a beacon 'content management system', where you can manage beacons, define regions, analyze visitor behavior etc. The app is just part of the story – often you also need some sort of backend.
Then there is the client-side SDK, which determines what beacons feature are available on which platforms and platform versions.
And last but not least, there is the ability of the manufacturer to deliver reliably and in quantity, and the likelihood of the manufacturer surviving beyond the short term.
Here is an overview of some well-known beacons; below you can find which manufacturers I think are the strongest contenders.
For battery powered beacons, Qualcomm is a relatively new player on the beacon field with its Gimbal beacons, but a very strong contender. Qualcomm is a major player on the wireless semiconductor market ($24.9 billion revenue in 2013); its offering has raised the bar for the entire beacon industry.
Gimbal has several beacon types, with the smallest ones very cheap: $5 (most beacons are $30 or more). Gimbal beacons can be configured in a standard iBeacon mode (iOS 7+, Android 4.3+), but also in a custom mode for which the Gimbal SDK supports iOS 7+ (87% runs on iOS 7+) and Android 2.2+. Given the amount of older (pre 4.3) Android devices out there, that is something to consider: (14% runs on 4.3+, while 2.2+ means 100% coverage).
The Gimbal backend services offer proximity, geofencing and interest sensing (an e-commerce analytics service for brick and mortar locations). And they are accessible through a REST API. If you use the Gimbal backend services, tracking up to 10000 users per month is free; after that it costs $0.06 down to $0.04 per user per month. You can also roll your own services, or use the beacons in iBeacon mode with other existing services.
Battery-powered beacons have to strike a careful balance between signal strength, advertising interval and battery life. USB-powered beacons do not have these limitations; they can transmit at full power and with a low advertising interval all the time, resulting in better range, faster response times and better accuracy. Plus you do not have to perform ongoing battery level monitoring and battery replacement every few months or years.
On a side note, there are currently some concerns about battery-powered beacons and how Apple is going to handle their iBeacon brand compatibility requirements: Apple reportedly requires a fixed 100 ms interval, which would severely limit the battery life of most battery-powered beacons. For details, see Apple iBeacon Specification: Why Power Matters.
The RadBeacon USB is a tiny $29 - $21 iBeacon compatible USB-powered beacon. It uses USB for power only; you do not need a computer (except when you want to reconfigure the beacon). You can stick the beacon in a cash register or in any cheap USB outlet adapter, plug it in an outlet (e.g. above your store ceiling tiles), and just skip battery maintenance and tweaking of send power level/rate settings.
Radius Networks offers backend services for configuring geofences and iBeacons, and an SDK to access the services from Android and iOS. Radius Networks also maintains an open source version of their Android Beacon Service Library, as well as several handy tools and apps for beacon app development on iOS and Android.
The GemTot USB iBeacon is a similar $25 - $17.50 USB powered beacon. In contrast to other parties, the backend services and API offered by PassKit are focused on integrating mobile wallets; they support Passbook, Samsung Wallet and Google Wallet.
Any iOS 7+ device with Bluetooth 4.0 can also be configured to act as an iBeacon, e.g. with the MacBeacon for OSX or the Locate for iBeacon iOS apps, which comes in handy for testing and development purposes. If you have no suitable iOS device handy, you can also use Radius' Networks free Linux virtual machine to turn a cheap BLE USB dongle into a beacon (if for some reason you can't get your hands on a real USB iBeacon quickly enough).
The first thing to do is to put the Gimbal beacons in iBeacon mode (this is not the default). To do this, you need to install the Gimbal Beacon Manager app on an iPhone (note: the app is in the USA store so you may need to switch to a USA account on your iPhone) and follow these steps (source):
Note that even if you only target Android for your app, you still need an iPhone to configure Gimbal beacons.
Here is what you need to develop an iBeacon app for iOS with Xamarin:
Here are the steps to get the example Xamarin iOS iBeacon app Find the monkey working with an iBeacon-mode Gimbal:
So there you have it, a Gimbal beacon working in C# in an iOS iBeacon app. A good starting point to experiment!
In a next post, I'll describe the possibilities, strengths and limitations of the iOS iBeacon API's.
Here is what you need to develop an iBeacon app for Android with Xamarin:
After playing around with both platforms, it became clear that even when using the same beacon, Android can give very different results from iOS. Apart from hardware differences in phones, the Android BLE API currently has some limitations which result in lower beacon accuracy.
As described here, the algorithm in the Radius Networks Android iBeacon Library is not the same as in iOS CoreLocation, because the iOS CoreLocation implementation is closed source. The intention is that they behave in a similar way. However, currently some Android limitations exist that cannot be overcome by a library:
"On Android, the Bluetooth LE Scan API only allows a single signal strength measurement per scan. On iOS, it is possible to get a different measurement for each advertisement broadcasted. By default, the Android iBeacon Library does one bluetooth scan every 1.1 seconds when it is in the foreground, therefore allowing one measurement every 1.1 seconds. So if you have an iBeacon that is transmitting 30 times per second (as iOS devices acting as iBeacons do), iOS will be able to get 300 samples in a 10 second period, and Android only 9. This explains why the estimate has higher noise on Android."
Combined with the known Android bug, this confirms that even though iBeacons do work and are usable with some workarounds on Android 4.3+, the OS support is less mature than on iOS. Currently both Android and iOS are moving targets, although iOS still seems to be improving faster.
Which brings us to the current state of BLE beacon support in the 'third' mobile OS: Windows Phone 8.1 and Windows Store 8.1.
When BLE support was announced for Windows Phone 8.1 at the Microsoft Build 2014 conference, I assumed that BLE beacon support would be included. However, in the session Building Great Bluetooth Apps for Windows Phone two limitations were mentioned:
The last point obviously is a real disappointment. Since there is a lot of interest in beacon apps right now, I set out to verify both points and to see if I could find a way to get beacons working on Windows Phone 8.1 though a lower-level BLE API.
A fundamental difference between BLE beacons and other types of BLE devices is pairing. Pairing establishes a one on one relation between the BLE device and your phone, so that only your phone will be able to read e.g. your BLE heart rate sensor. BLE beacons by definition establish no relation to a device, except for encrypted functions. Since the Gimbal beacons used in this test can receive firmware and settings updates from the Gimbal Beacon Manager iPhone app, I expected that the procedure used to pair beacons to the Gimbal app would just be regular BLE pairing.
So I took a Microsoft Surface Pro tablet with Windows 8.1, which has BLE enabled, selected Add a Device and then rebooted the beacon by removing and inserting the battery. Sure enough, the Gimbal beacon was detected for a few seconds (after which it goes into regular beacon mode):
I took out my trusted Nokia Lumia 920 running on the Lumia Black update (which adds BLE support) and Windows Phone 8.1 Developer Preview, and repeated the procedure. The Gimbal was not detected. Ergo, BLE disabled is confirmed.
This is the big one. Is there a way to use beacons with the BLE support in Windows Phone 8.1?
"Bluetooth Classic and Bluetooth Smart devices must be first discovered and paired via the Windows 8.1 PC settings UI (PC & devices>Bluetooth) before being accessible via the Windows Runtime APIs for Bluetooth"
Here Bluetooth Smart is another term used for BLE devices. Determined to get to the bottom of this, I set out to verify this limitation and to see if a lower-level API might offer a workaround.
Starting at the bottom, the raw Bluetooth packets for iBeacons are described here (again, thanks to research by Radius Networks). This told me that I was looking for a Bluetooth Generic Attribute Profile (GATT) API to get access to the beacon advertisement packets. Keeping that in mind, I started out with the code used in the Building Great Bluetooth Apps for Windows Phone Build session to find a BLE device:
As it turns out, the BluetoothLEDevice class is only supported on Windows Phone 8.1, not on Windows Store 8.1. However, BluetoothLEDevice.GetDeviceSelector() is only used here to obtain a limiting filter on which devices we want. Since the DeviceInformation class is supported on both Windows Store 8.1 and Windows Phone 8.1, I could simply omit the filter and call DeviceInformation.FindAllAsync() in a Windows Store 8.1 App on my Surface Pro, which I verified has working BLE:
This returned over 300 entries – but none of them the Gimbal beacon that was detected on the same device earlier (I never paired it though – pairing the Gimbal beacon fails). Just to be sure, I tried the GattDeviceService Bluetooth Generic Attribute Profile (GATT) API that is supported on Windows Phone 8.1 and Windows Store 8.1:
Same result. Upon inspecting the GATT API in the Windows.Devices.Bluetooth.GenericAttributeProfile namespace, it quickly became clear that the only way to discover devices is through the DeviceInformation class, which currently only returns paired devices.
So again, no BLE beacons in Windows Phone 8.1 and Windows Store 8.1 is confirmed. We will just have to wait until Microsoft provides BLE beacon functionality in a post-Windows Phone 8.1 update (hopefully before Windows Phone 9).
BLE beacons enable many interesting real-world scenario's, based on indoors as well as outdoors micro-location information, with cheap stationary or mobile beacons, where apps can react to proximity without running in the foreground or requiring action from the user.
BLE Beacon hardware and backend service offerings are maturing rapidly, as is support for the iBeacon standard in iOS devices (87% runs on iOS 7+). Support for iBeacons in Android devices is also there but still has limitations on accuracy, on the percentage of devices in use that support it (14% runs on 4.3 or later), although beacons that are not iBeacon compatible allow full Android device coverage. Android also has a stability issue that needs a workaround. Windows Phone 8.1 cannot support BLE beacons yet; beacon support is expected in an update within 3 to 12 months.
Last but not least, Xamarin once again proves to enable quick and full access to new native capabilities such as Bluetooth Low Energy beacons on iOS and Android, while also enabling code sharing across both platforms.
(This post was republished from VincentH.NET with permission)