Calculate time of flight of BLE message between 2 Android phones

牧云@^-^@ 提交于 2019-12-24 07:12:34

问题


Maybe to general for SO, feel free to move to any other SO clone when needed.

I would like calculate the distance between 2 android smartphones based on how long it takes for a message send over Bluetooth Low Energy to travel back and forth.

Like:

  1. Device A connects over BLE to device B.
  2. Device A sends message
  3. Device A stores current nanoseconds (T0)
  4. Device B receives message on bluetooth radio (BT0)
  5. Device B process message
  6. Device B raises "message received" event (BT1)
  7. Device B stores current nanoseconds
  8. Device B send acknowledge message back to A with value BT1 - BTO
  9. Device A receives message on bluetooth radio (AT0)
  10. Device A process message
  11. Device A raises "message received" event (AT1)
  12. Device A stores current nanoseconds (T1)

Total travel time = distance covered = T1 - T0 - (BT1 - BT0) - (AT1 - AT0)

Is it all possible to calculate (BT1 - BT0) and (AT1 - AT0) on Android?

Thank you


回答1:


No. The clock inaccuracy is allowed to be as much as 50 ppm. Also, packets are allowed to be sent within a 4 microseconds window. These reasons are enough to say your proposal doesn't work.

A bigger reason is that the messages have to be processed by a Bluetooth stack in a non-realtime OS (Android) and must also be transferred over UART to the Bluetooth controller in the phone, which then schedules to transmit the message at the next connection event.

If you could program the firmware for a general microcontroller radio and time the radio with the accuracy of a 16 MHz clock, then you might be able to get some good enough results to measure longer ranges. With the introduction of BLE Long Range in BT5, the controller now have to take the distance into account when calculating the receiver window (which was +-2 microseconds in BT 4).



来源:https://stackoverflow.com/questions/44397982/calculate-time-of-flight-of-ble-message-between-2-android-phones

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!