3

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

ligi
  • 39,001
  • 44
  • 144
  • 244
Filartrix
  • 157
  • 1
  • 10
  • I might be wrong but this is how electromagnetics work? You can't get exact reading because they are interfered by a lot of things. – dominik4142 Oct 17 '14 at 00:14
  • Hi, no, you're not wrong at all, RSSI value by its nature is an approximate measure and is not stable. But what I expect are oscillations around the nominal value let's say from -45dBm to -35dBm, and not positive values, I also got 100dBm (positive) which is not possible in a smartphone (the power of the signal would be hundreds of KW) [link]http://www.rapidtables.com/convert/power/dBm_to_Watt.htm but thanks for your comment – Filartrix Oct 17 '14 at 01:00
  • Thanks for the link! I just checked on wikipedia details about rssi: it shows power absorbed from antenna. Maybe readings come from wifi/mobile antennas interfering with bluetooth? I know these are different frequencies but after bouncing around or anything else that can happen, maybe they affect how bluetooth antenna works? – dominik4142 Oct 17 '14 at 01:07
  • @dominik4142 - no, that is not possible. It is clearly a software / register interpretation error, not a valid signal strength report from the radio hardware. – Chris Stratton Oct 23 '14 at 19:19

2 Answers2

1

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)

Filartrix
  • 157
  • 1
  • 10
0

This is definitely not normal. I have never seen a rssi value in that callback be positive. Typical values are from -30 to -120.

I suspect there is something wrong with the way the data are written out to the log, or read back. What happens if you just do a regular Log.d(TAG, "rssi="+rssi); Do you ever see positive values? If so, can you share an excerpt, along with the device model you are using to detect and the device you are detecting?

davidgyoung
  • 63,876
  • 14
  • 121
  • 204
  • Hi, actually I thought that too, but I see the positive values also in the debugger and LogCat: 10-16 18:49:07.615: D/RSSI SERVICE(1680): Rssi = -45 10-16 18:49:07.725: D/RSSI SERVICE(1680): Rssi = -45 10-16 18:49:07.825: D/RSSI SERVICE(1680): Rssi = 77 10-16 18:49:07.925: D/RSSI SERVICE(1680): Rssi = 77 10-16 18:49:08.035: D/RSSI SERVICE(1680): Rssi = 79 10-16 18:49:08.135: D/RSSI SERVICE(1680): Rssi = -53 10-16 18:49:08.245: D/RSSI SERVICE(1680): Rssi = -43 10-16 18:49:08.345: D/BluetoothAdapter(1680): stopLeScan() the device is Samsung Galaxy Gear, but i have that on Nexus 5 too – Filartrix Oct 17 '14 at 01:57
  • Are all these readings above from the same detected device? What operating system versionn is doing the detecting? Can you reproduce these results with a different Android device doing the scan? – davidgyoung Oct 17 '14 at 12:01
  • Hi, That's the log of one device only. The os is Android Wear 4.4W.1, Build:KGW42N. I tried the same code on Nexus 5 with Android L (preview) and on Galaxy S4 with Android 4.4. But I was able to reproduce the issue only on the smartwatch. The two phones returns only negative values for RSSI – Filartrix Oct 17 '14 at 18:51
  • OK, unfortunately, this sounds like a hardware or driver problem on the smartwatch. – davidgyoung Oct 17 '14 at 21:27