Search code examples
iosios7bluetooth-lowenergyibeacon

Calculating the distance between two or more iPhones using Bluetooth


Let's say I have 2 or more iPhones, each a 4s or later, and Bluetooth 4.0 enabled.

Is it possible to turn each phone into a iBeacon, where every other phone can receive updates from said phone, and calculate the distance from themselves to this phone transmitting it's location.

The reason being, i'd like to be able to be quite accurate in location, within 5m perhaps. So if two (or more) phones are within GPS mininmum accuracy of each other (~17m?) they switch to iBeacon mode.

Thoughts?


Solution

  • In theory this is possible, but there are three practical challenges:

    1. You must somehow wake up the app periodically to check if it is in GPS range of other devices. You could use a major location change callback, but this is typically only provided on location changes of 2000 meters or more. So you may need full location background modes to get regular updates. Requesting location background mode may make it harder to get in the AppStore unless you are making a dedicated navigation app.

    2. You must get the user to bring the app to the foreground once you determine the user is in a rough location where other users are around. This is because beacon transmission is only possible in the foreground.

    3. You must accept that beacon ranging is not super accurate due to radio signal fluctuations and noise. At 2 meter distance, you may get estimates +/- 1 meter. At larger distances, say 20 meters, the variance is much higher, say +/- 10 meters.

    You must decide if your use case can work with the above limitations.