I'm new to Android and my app uses Bluetooth to receive data from a small load cell amplifier. While in some devices (Samsung ones) the BT signal strength (RSSI) vary as expected (from around -20, at short distance, to around -80, at 10m), in some others (one LG model, at least) the RSSI are quite weird, as around 200 (positive value!) at short distance. I'm supposing that LG phone is not giving RSSI values in dBm. In all cases Samsung tablets and LG phones were always connected to the same remote device (the amplifier sample that my customer is developing). Actually my question is if it is normal, in this case, that different Android devices (or different Android versions) answer differently to the same API call.
Bluetooth RSSI values are always in dBm in all Android devices?
The RSSI is an 8-bit signed two's complement integer(-128 to 127). If you read the value as a byte then you will get the correct value range for any device. If you read it as an integer or a string you might end up with correct values on some devices but incorrect on some other...
200 as an 8-bit signed two's complement integer equals -56
Great! I knew that RSSI is 8-bit signed, but I thought my code could convert RSSI to integer without problem: lastRssi = (int) intent.getShortExtra(BluetoothDevice.EXTRA_RSSI, Short.MIN_VALUE); –
Dishwater
I think your code is correct... i've seen it used like that all over the place... but: short is 16bit, try using getByteExtra instead of getShortExtra... I think that way it should work for all devices –
Pothole
Sorry Tiago, I am not used with StackOverflow. Answer accepted! Obrigado! –
Dishwater
© 2022 - 2024 — McMap. All rights reserved.