so I'm trying my hand at android developing this summer. I was trying to make a sort of alarm app when a pair of connected devices go out of range of each other.
From looking around on the internet / stack overflow, it seems that looking at the RSSI value will help me achieve this.
However, it seems that the RSSI value can only be read at the time of connection with the device, that is it doesn't update itself (or there is no method to do so).
Is the RSSI value the only way to achieve my goal?
Would it be possible to use RemoteDevice and RemoteDeviceHelper? Has anyone tried this?
Any other suggestions and hints would be much appreciated
You could establish a connection with the device and exchange heartbeat information with the device , you can use the reception of valid heartbeat information to detect device being in range and or going out of range..
Your algorithm can use this information in conjunction with the connection loss to detect device being out of range and set off the alarm.
RSSI in Android available via public APIs is only during the discovery process, the other non public means of reading the RSSI (like in RemoteDeviceHelper) should also be possible , but RSSI by itself is not a good indication of distance.
Related
I want my android device to pick a BT device in range with a best RSSI and connect to it. Is there a way to implement such thing?
Ex: I have 5 ESP32-based devices around my house and need my phone to reconnect to the closest device (with a strongest RSSI). Is there a way to make app automatically pick the best RSSI from the available list of devices, terminate previous connection and reconnect to the device with best RSSI?
Your help is greatly appreciated. Thanks.
Yes this is definitely doable. All your app needs to do is the following:-
Scan for devices for a specific interval (e.g. 5 seconds).
Filter the scanned devices based on their name (i.e. you want to make sure that you only have the ESP32 devices and not other random Bluetooth devices).
Find the device with the best RSSI.
Connect to the device with the best RSSI.
If you want the process to be continuous, then go back to step 1.
However, keep in mind that RSSI does not always equate to distance/range. The device with the best RSSI might actually be further than other devices. The links below go over this plus some other useful data that you might need for your application:-
The ultimate guide to Android Bluetooth Low Energy
Using BLE for indoor positioning
Bluetooth LE RSSI for proximity detection
I have created a bluetooth car that is controlled using a Galaxy Tab, from which I want to be able to frequentely (1-10 times per second) read the RSSI value to be able to always stay in range of the bluetooth, and if not the car is supposted to return to the last known place where the connection was within range.
My problem however, is that I am not able to read the RSSI value when paired to the bluetooth module in my car. Reading while discovering is not a problem, but does not help me in this case.
I have been looking around but can't find an answer how to make this possible using the API I am, which is 15, and therefore GATT is out of the question. Help would be greatly appreciated!
Cheers :)
I need to measure bluetooth signal between two or more mobile phones and detect nearest phone in range. After a lot of researching I came to idea to do periodically discovering for new bluetooth devices and measure rssi via EXTRA_RSSI that returned by ACTION_FOUND. All devices must be always in discovery mode and also must periodically scan for other devices.
Is this approach good or there are some better solution? What problems I can expect with this approach?
This solution Android 2.1: How do I poll the RSSI value of an existing Bluetooth connection? doesn't work for me because need phones to be rooted.
RSSI is a bad indicator for distance under real world conditions.
It could work under ideal conditions (free space propagation) but in reality you always have obstacles like walls, trees, etc. that affect the propagation.
See this article for more detailed information on propagation models.
RSSI doesn't indicate which phone is nearest, only which phone has the strongest signal.
I wanted to get the RSSI value to measure how far a device is from a handset...the problem I am currently facing is whether the RSSI value keeps on changing even after the devices are paired and also if can the value be directly used as short?
The RSSI value will fluctuate significantly.
It is proportional with distance, but it is affected by interference, and also by the 2 connected devices' power table (they might reduce their tx power if they are close).
That being said, RSSI will still appreciate with devices getting closer.
I preferred logging the RSSI data I receive on my other(embedded) device and sending it back to Android, showing it there. My embedded device has clear access to the Bluetooth stack, and so can get more accurate and more intense readings of the RSSI.
Ofc, getting the RSSI of the other device from Android should also work, but probably not so good (you have too many layers on top of the actual Bluetooth stack - linux bluez, then Android...).
I have my own graphing application for Bluetooth RSSI monitoring in Android, here are 2 printscreens from my app:
You can also look at Link Quality...this is another useful parameter(it it susceptible to duplications of the signal).
Here is a scientific paper on the subject.
I have a question about bluetooth RSSI functionality on the Android (either 2.0 or 2.1):
It's easy enough to get the RSSI value when a bluetooth connection is created, but how can you repeatedly get the RSSI value of a connection that is already active? It's really important to be able to do this, because this lets you determine if bluetooth devices are close to each other or far away, but I can't find any appropriate function calls in the Android API.
Could someone who understands Android RSSI please help me with this problem?
Thanks!
Alex
At the HCI level, there is a command to read a Bluetooth link RSSI from the Bluetooth chipset (Read_RSSI_Command). However its implementation can vary from Bluetooth chipset to Bluetooth chipset. And the value returned is not always useful, for example if there are no packets transmitted in the last few minutes, the Bluetooth chipset has no way to know the current RSSI.
So we don't expose this in any Android Java API at this time.
Nick Pelly
Android Bluetooth Team