Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

onLeScan callback returns oddly positive RSSI values

using Bluetooth Low Energy (BLE) scan on Android, I noticed that sometimes RSSI values are incorrect. My code simply calls the start scan function:

mBluetoothAdapter.startLeScan(mLeScanCallback);

and then I read results in the callback and save results in a file:

 private static BluetoothAdapter.LeScanCallback mLeScanCallback =
        new BluetoothAdapter.LeScanCallback() {
            @Override
            public void onLeScan(final BluetoothDevice device, final int rssi, final byte[] scanRecord) {
                String objScanRec = bytesToHex(scanRecord);
                outStr =  rssi + ";" + objScanRec + ";" + device.getName() + ";" + beaconLocation + ";\n";
                    try {
                        Raw_log.write(outStr);
                        Raw_log.flush();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
//                }

            }
        };

the problem is that I read positive RSSI values, also if the beacon is at a fixed distance. E.g. I have the beacon 30 cm from the phone (or smartwatch) I read a values around -45 which are realistic, but also values around +80 or +100 (which are not realistic) those values are around 20% of measurements. Is there something that I'm missing? thanks

like image 659
Filartrix Avatar asked Dec 06 '25 19:12

Filartrix


1 Answers

thanks for your help I figured out it's a problem related only to Samsung Gear Live. I came up with this s solution:

if(rssi > 0){
  rssi = rssi - 128;
}

I've tested the solution and it works fine. (e.g. the obtained positive values after correction are now similar to negative values, for example I read -44 -45 -43 84 82 that after correctio become: -44 -45 -43 -44 -46)

like image 162
Filartrix Avatar answered Dec 08 '25 11:12

Filartrix



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!