2

I would like to know if its possible to use a signal strength between iOS devices to determine what is nearer and list them in that manner? By signal stength, we are looking at either Bluetooth, wifi or cellular. Basically the final objective is to get the nearest 3 devices to the user. Is it possible? and if yes, can someone point me to the right direction of which technology to use with some reference/documentation links if any.

Thanks in advance

2 Answers2

4

The GameKit framework provides functionality for communicating with nearby iOS devices via Bluetooth. Unfortunately the GKSession class which mediates connections between devices doesn't expose any properties related to signal strength. If this functionality would be helpful, I would recommend filing a bug report with Apple requesting this feature.

GameKit Programming Guide - Peer to Peer Connections

Mark Adams
  • 30,776
  • 11
  • 77
  • 77
  • Even if the info was available, I don't think signal strength would be useful, because it's effected by other unrelated things, such as the proximity and material composition of other objects nearby to each device. A steel re-inforced concrete wall close to a device will either reduce the signal strength or increase the signal strength. – Abhi Beckert Dec 08 '11 at 00:04
0

You can use communication latency to determine which devices are the closest.

Send a message to the other device, record how many milliseconds (nanoseconds?) it took to respond. The quickest response will be the closest device.

Almost all of the communication protocols travel at (approximately) the speed of light. Therefore you can divide the amount of time taken to get a communication response by the speed of light to calculate the distance.

It's not perfectly accurate due performance overhead created by error correction algorithms, but if you perform this measurement many times and calculate an average latency, it will be accurate enough for what you want to do here (the more times you repeat the test, the more accurate it will be).

Note that if your communication is going via some other device, such as a cell phone tower or wifi access point, then you are calculating the distance between that access point and each device, not between your device and the other devices. Keeping this in mind, you may only be able to use protocols like bluetooth or wifi over the personal hotspot feature built into iOS.

EDIT: Another possibility is to play a sound on one device, and listen for that same sound on the other devices. The speed of sound is much slower than the speed of light, so it may work better. I'm not sure how good an iPhone's microphone is though.

Abhi Beckert
  • 32,787
  • 12
  • 83
  • 110
  • 1
    This is not even a remotely feasible approach. Many factors cause uncertainty in processing times for generating responses and timestamping results that would prevent you from getting a useful answer. – TJD Dec 08 '11 at 00:56
  • I suspect that at bluetooth ranges (~10 meters perhaps?) the effect of the speed of light on response time is going to be dominated by other factors (such as variability in how long it takes the OS on your device & the other device to get around to scheduling your application) – David Gelhar Dec 08 '11 at 01:04
  • The asker did not specify bluetooth, we don't know what ranges he's after. The iPhone's 1GHz CPU is able to perform simple operations in 1 nanosecond, I ***think*** it may have an accurate enough clock to record **estimate** short distances. Especially if you average it out over 20 or 30 messages (and you can do all 30 messages in in a hundredth of a second), it could work. You shouldn't vote me down and say it doesn't work without actually trying it out first. It's worth a try. – Abhi Beckert Dec 08 '11 at 03:39
  • The other guys are right - there are way too many variables to even consider this as a possibility. – sosborn Dec 08 '11 at 03:52
  • I searched it, and Apple actually has a patent application for finding lost devices using bluetooth by measuring communication latency with the device. It takes 1 nanosecond for a radio wave to travel about 30cm, so if you use a CPU's internal cycle counter to measure the latency, you should be able to calculate positions with well better than 1m accuracy. Especially if you *average it out over multiple tests*. Presumably a patent application means they have actually done it in a research lab. – Abhi Beckert Dec 08 '11 at 04:32
  • Sure, you can find one phone that way. What we are saying is that if you have two devices, there are too many variable between the devices to reliably tell which one is closer to you. Will a 3GS reply to your message at the same speed as a 4S? What if the 3GS is playing music at the same time and the 4S is idle? Does the bluetooth chipset process with the same speed between the 3GS and 4S? – sosborn Dec 08 '11 at 08:42
  • 1
    A further complication to this approach, see the answer to: http://stackoverflow.com/questions/8378169/gksession-peer-disconnect-causes-other-peers-to-appear-disconnected – iPadDeveloper2011 Feb 12 '13 at 06:19
  • I like it, and the edit for sound is a good one. I've been pleasantly surprised by the few acoustic ruler apps on the store. And if you can [measure a heartbeat with the iPhone's camera](https://itunes.apple.com/us/app/instant-heart-rate-heart-rate/id409625068?mt=8), why wouldn't you be able to make some rough guesses from the Bluetooth or speaker/mic responses? – Slipp D. Thompson Mar 28 '13 at 16:31