15

I need to know the signal strength of a Bluetooth connection to a remote device that I make with my Android 2.1 phone. From the SDK, I can see that I can determine the RSSI at the time I discover the remote device. But I can't see how to update that RSSI value over time.

Can someone give me a hand? Thanks!!

Philipp
  • 181
  • 1
  • 2
  • 4
  • There is an entry in the bug tracker at the Android project, which addresses this issue. If you want to subscribe (and push) for proceedings on this issue you should star https://code.google.com/p/android/issues/detail?can=1&start=0&num=100&q=rssi&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars&groupby=&sort=&id=6707 – Martze Mar 07 '13 at 15:24

2 Answers2

16

From the SDK it is the only way to obtain RSSI. It is a little bit inconvenient, since it is not useful if you only want to periodically monitor the strength of the signal of a paired device.

However there is a way, but out of SDK. You can use native API (by means of NDK) and call functions provided by Bluez API, the underlying bluetooth framework in Android (and almost any linux system). The function in question is hci_read_rssi() provided by libbluetooth.so (part of Bluez stack). In order to learn how to use it, you can take a look at Hcidump tool sources (that comes with Bluez). You could write a JNI wrapper code to your function, so you could get the signal strength of paired device.

There are two drawbacks of using this method:

  • To measure RSSI you must first connect to remote device, at least at low level (no authentication is required for this connection) and release connection after calling hci_read_rssi(). This is slower than just measuring RSSI from beacons, as other wireless communication means provide (GSM or WIFI)
  • Low level connection to remote bluetooth devices requires on Android superuser rights. So forget about writing and application that can be run on non hacked phones (they usually come with no root access, and some like Motorola Droid/Milestone even void warranty if you try to gain it).
Abdul Rahman
  • 2,097
  • 4
  • 28
  • 36
Fernando Miguélez
  • 11,196
  • 6
  • 36
  • 54
  • 3
    Note, this won't work on 4.2, as the stack has changed from bluez to broadcom. – Thomas Dignan Jun 03 '13 at 09:05
  • It's not clear that `hci_read_rssi()` is the right function for obtaining the RSSI - according to this answer: http://stackoverflow.com/questions/30025139/bluez-bluetooth-api-and-distance-calibration-precision/30043437#30043437 – Pierz May 14 '15 at 11:42
1

Sadly not for Android 2.1, but have a look at this API for level 18 (Android 4.3) which you could poll:

BluetoothGatt.readRemoteRssi()

Read the RSSI for a connected remote device.

See Android docs here

gndean
  • 340
  • 2
  • 6
ben_lize
  • 107
  • 9