views:

750

answers:

3

Hi, 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!!

A: 

Hi, i am also working on similar problem. But I can't even get the RSSI value when scanning. It just keep returning a default integer. Can you provide some sample code about how to get RSSI? Thanks a lot!

Zhenan
A: 

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 peridically 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 a 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 requieres 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).
Fernando Miguélez
A: 

Somebody can give an example of usage NDK for definition of Bluetooth signal strength?

Alex