2

I'm a beginner of android development and I'm currently under a project of doing some proximity work. Our aim is to measure the distance between an Android phone and an object using bluetooth technology. I did find some sample codes on stack overflow, and here is the link, but it doesn't really work on my device (android 5.0). It can be installed but it cannot open bluetooth and return back RSSI values when I click on the button.

I'm wondering if there is any good sample codes that would detect the distance between a phone and an object (bluetooth enabled) It will be better if the codes can start the bluetooth pairing user interface then pair with the object, and then return the distance indicator values (like RSSI) of the specifically paired object.

Thank you sincerely for the help.

Community
  • 1
  • 1
Ray
  • 160
  • 1
  • 13
  • Getting the RSSI is easy. However, keep in mind that RSSI doesn't actually directly relate to distance, it is the received signal strength which can vary depending on several environmental factors and components. Take a look at this for further research: http://electronics.stackexchange.com/questions/83354/calculate-distance-from-rssi – DigitalNinja Nov 10 '15 at 20:03
  • Thank you for ur suggestion and the link is very helpful for me to relate the distance and RSSI together. And do u have any other suggestions on how to keep getting RSSI as a service of a paired device? (the coding I am using can detect every bluetooth signal but I just want the paired one)My another big problem lies on coding actually. – Ray Nov 11 '15 at 01:16
  • It really depends on the device. Most devices will only send the RSSI when it's advertising/being asked for it, and once paired will stop sending this data. It's possible you could ask for it from the device or if you are working with a specific device that you have control over then you can write the code to make it send continuously. The service that the RSSI comes from is the Tx Power Service, https://developer.bluetooth.org/TechnologyOverview/Pages/TPS.aspx. – DigitalNinja Nov 11 '15 at 01:43
  • Additionally, you can see from the link that reading from the TPS is mandatory (if conforming to the Bluetooth SIG spec), which means any device that you are able to see this from is probably being asked for it, which means your Android app should be able to continuously ask for it and the device should send it. – DigitalNinja Nov 11 '15 at 01:47
  • Thank you, that's really helpful for my learning. – Ray Nov 11 '15 at 12:38
  • May I ask one additional question? Everytime I use startdiscovery attribute of bluetooth adapter and receive the signal by broadcast receiver, the period of one scanning is very long about at least 5s that I can only start next scanning and get value after that. That makes my detecting process very slow. Is there any way to get it fast or just scanning some specific device and then stopdiscovery? – Ray Nov 20 '15 at 01:11

0 Answers0