Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reading RSSI value of connected Bluetooth Low Energy device in Android Studio

I am working on a BLE project in Android Studio and would like to read the RSSI value of a device which I have already connected to. So far I was able to discover new devices via LE Scan and get their RSSI from there. However, once I connect to a device I can no longer run a scan and get the RSSI.

This is the code for discovering new devices before connecting to one of them. Not sure how relevant it is to my question though:

private BluetoothAdapter.LeScanCallback mLeScanCallback =
        new BluetoothAdapter.LeScanCallback() {

    @Override
    public void onLeScan(final BluetoothDevice device,final int rssi, byte[] scanRecord) {
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                mLeDeviceListAdapter.addDevice(device, rssi);
                //mLeDeviceListAdapter.notifyDataSetChanged();
                try {
                    mLeDeviceListAdapter.notifyDataSetChanged();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }
};

Thanks in advance

like image 593
dorsef Avatar asked Oct 22 '15 08:10

dorsef


People also ask

How do I read my RSSI Bluetooth?

Bluetooth signal strength is measured by the Received Signal Strength Indicator (RSSI). You can access the device's RSSI by accessing the Bluetooth device settings and then reading the RSSI. An ideal RSSI is between -40 and -55.

How can I get Bluetooth signal strength in Android?

If your phone is running on Android 4.3 or above, then you can check your Bluetooth signal strength by going to Settings –> About Phone –> Status.


1 Answers

You have to use the readRemoteRssi() Async Call and then get the RSSI value using the Callback. https://developer.android.com/reference/android/bluetooth/BluetoothGatt.html#readRemoteRssi()

As detailed here, https://stackoverflow.com/a/20236561

like image 98
Nowa Concordia Avatar answered Oct 12 '22 01:10

Nowa Concordia