Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iBeacon region monitoring AND proximity for >20 beacons?

Tags:

ios

ibeacon

I have been working on a prototype iOS app utilizing iBeacons to provide location-relevant information to office employees depending on where in the office they are. The ideal use case is that whenever an employee enters or exits their office, a callback is fired which provides them some information in the form of a notification (it might make a server query to get information first, etc - that sort of thing). We also want to be able to do this when the app is backgrounded or terminated; fortunately, we already know that beacon region boundary crossings trigger the appropriate CoreLocation callbacks even if the app is backgrounded or suspended.

From looking around, I understand that broadly, I have two options for how to approach the beacon region monitoring:

  1. Give each iBeacon its own CLBeaconRegion, and monitor for each of these regions independently.
  2. Monitor for CLBeaconRegions that correspond to multiple iBeacons - for example, each iBeacon has the same UUID and only monitor for a CLBeaconRegion corresponding to that UUID - then try to determine which beacon triggered the boundary crossing using ranging.

Thus far, I had chosen option #1. The advantage of this approach is that I get didEnterRegion: and didExitRegion: calls for each individual beacon and immediately know which beacon I have entered/exited. Also, I only get one enter call and one exit call, which is exactly what I want. Unfortunately, I just realized that this approach also limits me to 20 beacons (since each beacon gets its own region).

I'm not as familiar with the exact implementation details of #2, so correct me if I'm wrong. But it seems that this approach has more drawbacks:

  • Apple discourages ranging when the app is in the background because the results may not be as accurate.
  • The ranging calls fire once every second, while I only want to have "enter/exit" callbacks.
  • If the beacons have region overlap, the ranging calls might continually flip which one is "closest", which would further complicate things.

Basically, I'm wondering if there is a way to utilize option #2, but still have the benefits of option #1 - a quick and easy way to immediately determine which beacon triggered the region change with only one enter or exit callback?

I hope this question is clear enough. It's not all entirely clear in my own head, especially how ranging works.

like image 642
UberJason Avatar asked Aug 19 '14 15:08

UberJason


People also ask

What is the range of iBeacon?

The maximum range of an iBeacon transmission will depend on the location and placement, obstructions in the environment and where the device is being stored (e.g. in a leather handbag or with a thick case). Standard beacons have an approximate range of 70 meters. Long range beacons can reach up to 450 meters.

What is iBeacon a guide to beacons?

iBeacon technology is a protocol devised by Apple that aims to standardize the data broadcast by Bluetooth beacons. In other words, iBeacon is an Apple flavour, running on top of core Bluetooth Low Energy technology and beacons.

What is beacon region?

In contrast, a beacon region is an area defined by the device's proximity to Bluetooth low-energy beacons. Beacons themselves are simply devices that advertise a particular Bluetooth low-energy payload—you can even turn your iOS device into a beacon with some assistance from the Core Bluetooth framework.

What is the function of Apple's iBeacon?

What is iBeacon? iBeacon is a Bluetooth Low Energy (BLE) system and framework that Apple has included in all of its iOS devices running iOS 7. It essentially uses Bluetooth to allow the phone to interact with regional-based devices, called Beacons.


1 Answers

The drawback of the second approach is detecting the entry of a particular beacon will be purely based on ranging, that will not work if the application is killed. The reason is we will get didEnterRegion only once, because we are monitoring only one region with a particular UID. The next beacon with same UID will not be detected again if the application is terminated or if the background ranging stopped.

I recommend a combination of the mentioned approaches ,

  • Use same UID for all the beacons.

  • A beacon is uniquely identified using major/minor value that is collected when ranging.

  • As mentioned in apple doc, always keep number of monitoring regions below 20 by removing and adding beacons when the user moves from beacon to beacon (better to keep a beacon neighbour relationship graph in the server.)

  • Start ranging when entering the region ... and identify major/minor and calculate proximity.

  • Stop ranging when exiting the region.
  • Find the closest beacon from ranging method (need to skip unknown range beacons).
  • Monitor only the neighbours of the closest beacon in a given time.

When implementing both options, We should consider one fact, An iBeacon will be detected in 200feet distance. There may be multiple beacons in 200feet range.

like image 187
Shihab Avatar answered Sep 29 '22 16:09

Shihab