Beacons with Mobile App

Beacon-with-mobile-app

Hello there!

In this blog, we will talk about insights to beacons and its integration with iOS & Android apps for precise location tracking. I’ll also highlight the different challenges that we faced while its integration and how we tackled them in the POC app. Let’s get started!

What is a beacon?

In simple terms, the beacon is a hardware device which broadcasts signals and tells its exact position which is mapped to it. Traditional beacons use the Wifi (ANT Protocol) to operate and there are new ones which works with Bluetooth Low Energy as well. Recently we did a POC with location beacon which uses a combination of Wifi and Bluetooth.

Beacon-communication

What’s new with beacons in the industry

Now a days beacons are widely used in many industries. It can be in healthcare for tracking patients or sending out alerts when room temperature changes or retail industry for giving suggestions to the user if s/he misses to buy a product from the grocery store. There are a lot of examples in security, Internet of Things (IoT), tourism etc domains where beacons are used in real time tracking. Recently Amazon introduced its checkout-free grocery service Amazon Go which internally works with censors (sort of beacons), artificial intelligence & machine learning.  

What is the use of beacon when we have GPS & other location services?

As we are surrounded by a number of satellites and there are live GPS tracking techniques from which we get the exact location. But consider that if you are in a building which has multiple floors in it, so by using GPS it will only point out the overall building not the accurate floor in which you are standing right now. This can be important for the lone workers who works in mines or at the construction site. If there are in some sort of trouble then the precise location using beacons will be handy for the rescue team.

How it get location using the beacons?

First, you have to set up the beacons in particular areas like at every corners of the floor or in a corporate office, we can install beacons at conference rooms, server rooms, pantry area etc. It totally depends on how much precise location you want in an area & number of beacons that you add to it. Once your setup is done, each beacon will have the exact location details and it will start broadcasting the signals. Now you will only need an app to capture those signals and get beacon ID while it is in range of a specific mobile phone. When there are multiple beacons within an area then the most accurate location is determined by the beacon which has the best RSSI level.

Challenges with beacon integration with app

Beacon are pretty strightwords as a hardware things which continuously broadcasts the signals. But when we try to integrate those with the application then we might face below challenges:

  • Protocols that beacon is using for transmission of data – The most challenging thing is to get familiar with the protocols that are used by the beacons for communication. It might be a Wifi beacon which is using ANT protocol or Bluetooth enabled beacon (iBeacon/Eddystone) or some custom beacon (Wifi + Bluetooth). It requires proper documentation and hands-on in order to read the data that is coming from the beacons.
  • Extract necessary information from beacon signals – When you understands the beacon data, next thing is to get the required data from the beacon signals. It might be Beacon ID, its signal strength (or range), battery updates, some custom payload containing company specific information etc. Reading beacon data is challenging as it comes in bytes and with the specific order. Also, you need to convert some part of data into HEX so as to get relevant information.
  • Get continuous background app updates from beacon – As you are done with reading beacon data while your app is in the foreground, next big thing is to get the same updates when the app is in the background. Normally with iOS and Android platforms, it restricts any Bluetooth communication when your phone is asleep. In order to get background updates, you need to create a scanning channel and need to scan for a specific UUID which is nothing but service ID of the Bluetooth beacon, that way the mobile OS treats your requests and you can get updates even your app in the background.
  • Beacon Range and Its Management – There are limitations of beacons in terms of its limited range and the industry need to look for more & more beacons to cover a specific monitoring area. Most of the beacons have cell batteries so it maintenance adds to the cost. As we move ahead with progressive technology there is always an enhancement Wifi and Bluetooth version. While these version are upgraded, already installed beacons needs to support those changes otherwise it becomes obsolete.

How we got beacon listed in our app

We had a goal to get beacon listed in the app and read information that was coming from Bluetooth byte stream from the beacons. There are standard frameworks like Apple iBeacon, Google Eddystone etc which can detect the beacons and get its information. While in our case, it was the custom Bluetooth payload which is developed for specific beacons. These beacons are not searchable with normal Bluetooth search, it requires specific Bluetooth channel and mapping of data bytes that are coming from the broadcast signal.  

The most challenging thing with Bluetooth beacon was reading through the BLE data bytes and understand each byte information and its significance with the order in which it comes. First, we were getting raw data bytes from the Bluetooth scan and it wasn’t making any sense with respect to beacon data. Later when we dig more into specific bytes, we observed a few things:

  • The byte data was of specific length and its HEX conversion was crucial. First, the scanning channel was returning data from all available Bluetooth devices like fitness bands, Bluetooth speakers and other BLE devices. It was hard to find out which is the data that we should target for Bluetooth beacon
  • Beacon data was very specific and it has some vendor company ID, custom start bytes, beacon ID, battery and much more.
  • We added a specific filter in scanning channel so now we were getting only beacon data. One more challenge was to find out the beacon ID. It was somewhere between 0-10 of total bytes of data. After debugging we could analyze the data and found out that it was a combination of 5-8 bytes. But there was a twist here. When we were converting these bytes to HEX then the combined beacon ID wasn’t the one we were expecting. It was the combination of 5-8 bytes but in reverse order. Phew! And that is how we could read beacon ID.
  • Talking about beacon search while your app is in the background, you need to register your device to Bluetooth and get a service UUID. This is important as you need specific UUID of a Bluetooth device in order to get continuous updates in the background.
  • We also worked on few addon things like sorting the beacon list with respect to RSSI so that we get accurate beacon location and we are planning to send this beacon ID to the server end when the location is needed in the app.

This was it. We successfully integrated the Bluetooth beacon with iOS and Android app. Hope you got some pointers from this. Let me know if you have any concerns.

Thanks!