Android IRC Office Hours Question About Android Bluetooth RSSI - android

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

Related

Connecting to bluetooth device with a best rssi

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

Bluetooth Low Energy - get RSSI for both sides?

I'm right now focusing on Android, but I believe the answers to these questions apply to any operating system, they just will use different functions to get the data.
Once I've established a BLE connection, I can BluetoothGatt.readRemoteRssi() to "Read the RSSI for a connected remote device."
First question: am I understanding this function correctly, it is returning to me the strength of the signal (transmitted from the remote BLE device) that my Android device is receiving, right? I think it's the function name that's throwing me off, shouldn't the name just be readRssi()? readRemoteRssi() makes me think there's a companion function readLocalRssi() somewhere.
Second question: assuming I am understanding the function correctly, is there anything built into Bluetooth that lets me ask "what is the remote BLE device seeing for RSSI?" In other words, of the signal that the Android device is transmitting, how much of that is reaching the remote BLE device?
ADDED LATER
Based on the answer I got, apparently I'm not explaining myself very well. Let me try again.
The remote BLE device is transmitting with a certain power, and those radio waves head out in all directions, and some of those waves are received by my mobile device. My mobile device measures how strong those waves are, and that's reported as RSSI. RSSI stands for "Received Signal Strength Indicator" and since it's the local mobile device that's doing the receiving, it seems strange to name the function "remote". Of course RSSI measures something coming from a remote transmitter - otherwise it wouldn't be very useful.
Similarly, the mobile device is transmitting with a certain power, and those radio waves head out in all directions, and some of those radio waves are received by the remote BLE device. That remote BLE device measures the strength of those waves, and that would be his RSSI. My second question is asking whether there's anything in the Bluetooth standard (a predefined characteristic, for example, like "Battery Level") that lets me mobile device query the remote BLE device and ask "Hey dude, how much signal you getting?"
am I understanding this function correctly, it is returning to me the strength of the signal
(transmitted from the remote BLE device) that my Android device is receiving, right?
 Actually rssi is calculated by ble chip based on the advertising packets that are received from the remote device. We don't directly get the rssi value from remote device.
I think it's the function name that's throwing me off, shouldn't the name just be readRssi()?
No. We are actually reading remote device's rssi.
readRemoteRssi() makes me think there's a companion function readLocalRssi() somewhere.
No there is no such method as rssi is determined at the other end to which the current device is connected to.
assuming I am understanding the function correctly, is there anything built into Bluetooth that lets me ask "what is the remote BLE device seeing for RSSI?" In other words, of the signal that the Android device is transmitting, how much of that is reaching the remote BLE device?
It is rssi. It is calculated based on how many advertising packets received against total packets.
Note: some of my answers are my guess based on my experience.

Read RSSI bluetooth value from paired device on API15 (no GATT available)

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 :)

Android App Bluetooth Determining distance between paired devices

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.

How to get bluetooth RSSI on android after discovery

I'm trying to write a program that can read the signal strength of a bluetooth device linked to my android 2.0 handset. Doesnt seem like android exposes anyway to get the RSSI unless it is during discovery. Is there any other way to get the signal strength of the device after the device has been detected? I read of a way to do it using NDK to access the underlying BlueZ API, but I dont know how to use that. Any help would be appreciated.
No. Only during discovery as a bundle extra (EXTRA_RSSI).

Categories

Resources