22

Target is not to have the real distance. It is something simpler.
Target is to check whether another device is very very close. True or false. Let's say 10 or 15 cms is close so our check is true and any device further away fails the check and it is false.

My first approach was to use api's method fetchUuidsWithSdp() but it failed!
Latency seemed the same whether the devices where a couple of cms away or at the other end of a large room!

Any solution even without bluetooth is acceptable. For instance, I am totally unfamiliar with the wifi direct p2p protocol. Maybe there could be something in there useful to have a rough estimation of distance.

Edit: I am reading about Received Signal Strength Indicator(RSSI). This could be used for our particular case, a rough estimation of distance between devices. But maybe there could be something to combine in order to improve the accuracy.

Edit: I put Ralgha's answer to the test. I did established a connection and had a minor protocol to ping-pong among devices.
When ping-ponged with 1 byte average latency was 22.6000 msec when very close and 22.6087 msec when on the other corner of the room.
When ping-ponged with 1024 bytes average latency was 40.3173 msec when very close and even smaller, 32.3138 msec, when on the other corner of the room.
After all, indeed, latency does not carry any information about distance!

Thanks!

George Pligoropoulos
  • 2,919
  • 3
  • 33
  • 65

4 Answers4

13

You can measure distance with sound.

Kornel
  • 97,764
  • 37
  • 219
  • 309
  • This is a nice implementation. Do you have any knowledge on how does the principles behind it work? – George Pligoropoulos Jan 02 '13 at 17:35
  • I presume it measures time it takes for emitted sound to bounce and return to the device (plays sound via speaker and listens to it via microphone), but maybe there's something smarter going on, like [interferometry](http://en.wikipedia.org/wiki/Interferometry). – Kornel Jan 02 '13 at 17:46
  • There must be some sound processing included because it is clear that the sound itself carries some information about distance but I am not sure if the time of bouncing back is enough because this means that a single beep would be sufficient. Furthermore when the master device finishes playing the sound there is a delay (of processing and etc.) until the slave device responses, but in the same time a very good measurement of distance is achieved!! – George Pligoropoulos Jan 02 '13 at 19:10
  • 1
    I believe in this link are the basics with which someone could start: [How to Measure the Distance Between Two Locations Using Sound](http://www.ehow.com/how_6075947_measure-two-locations-using-sound.html) – George Pligoropoulos Jan 02 '13 at 23:34
6

I've looked into bluetooth positioning and it istn' quite as easy as detecting the signal strength. For really accurate results you also need to take into account the types of phone your using, the battery type and the condition of the battery. You also have to take into account the environment and how it might efffect the signal strength, and also obstacles that may interfere with the signal, such as people, walls, tables, etc.

To determine the distance you would also need to use triangulation techniques to determine the position of a mobile. You can also set up a number transmitters in your environment and measure against each one. Knowing the positions of these transmitters you can then work out the position of the phone.

However, the signal strengths will vary and you will have to do a lot of calibration. There a number of scientific papers that give some insight into the algorythms required. There are also a couple of companies that provide this as a service, used in malls, museums etc.

That said, if you can get the signal strength then you should be able to work out a basic near or far result, it just won't be fully accurate, and in this case i still think having a number of transmitters would still help a lot.

Paper, some of the pitfalls PDF(download), another paper

THere are loads of papers i've read from googling bluetooth positioning that will give you some pointers.

Emile
  • 11,451
  • 5
  • 50
  • 63
4

The only feasible way to do it that I can think of is with NFC. To use Bluetooth or Wi-Fi you'd have to do it via signal strength, but every transmitter is different so that wouldn't be reliable at all.

Latency is rather useless since the radio waves travel at the speed of light and the time difference between traveling an inch and a mile is essentially zero. To measure that difference you'd need a much higher resolution than you have in a phone.

Khantahr
  • 8,156
  • 4
  • 37
  • 60
  • This was almost a good answer until you put in the grossly inaccurate "mile" comment. – Chris Stratton Dec 24 '12 at 03:54
  • You stand correct. It is not a matter of speed but only a matter of strength. How strong is the signal at the receiver. The receiver knows that. The data or the latency of the data do not carry any information about distance. Please correct me if I am wrong! (I will edit my question now) – George Pligoropoulos Dec 26 '12 at 18:25
  • +1 The OP says is use case is for file transfer. NFC is designed for that, although not on all devices yet… – rds Jan 02 '13 at 10:14
  • I was under the impressions that whilst NFC can transfere data that it is suggested that you use NFC for establishing a secure connection and then defere high transfere rates to wifi of something more suitable. – Emile Jan 02 '13 at 14:41
  • You can safely assume that for the purposes of my app if the NFC was ubiquitous then I wouldn't need bluetooth.But this will only happen in more than one year I guess – George Pligoropoulos Jan 02 '13 at 14:56
3

You are not specifying the objective for this distance detection, but if you could add some additional requirements to that (i.e phone orientation and flash light), a totally different approach could probably be used.

If both devices are oriented in a way that both cameras face each other, the flash light could be used to validate the correct phone and distance. The size of the white spot generated in the camera image decreases rapidly with distance, and a specific flash sequency could differentiate between the other phone flash light and other light sources.

This could require some tweaking to work outdoors, as for the same distance the spot size will be much smaller ...

Regards.

Luis
  • 11,978
  • 3
  • 27
  • 35
  • Objective is as simple as transfering a file :) Users approach devices and the file is transferred. I am afraid that the whole thing with the flashlight does not tell which device is it. Ok so let's say you have an algorithm that sees a bright spot. So two people have mobiles back to back. The state is "I am on" and "I see a bright spot". Request is, "Are you on and seeing a bright spot" ? Then two other people closeby do the same thing. So the device that requested (via bluetooth for example) the "Are you on and seeing a bright spot" gets two responses! Please correct if I got it wrong. – George Pligoropoulos Dec 28 '12 at 08:35
  • 1
    The suggestion of a specific flash sequency was exactly to address that. The request would be something like: "flash this randon length sequency, if you are the correct phone" and the answer confirmed reading the bright spot changes if the correct phones were aligned, and would fail for any other phones nearby. Just to be clear, this is just one idea and I've never tried it :-) – Luis Dec 28 '12 at 10:52