Using Android Beacon Library, is it possible to monitor non-beacon BLE devices ? if yes, how can I estimate their distance using rssi without txPower?
Asked
Active
Viewed 959 times
1 Answers
4
Yes, it is possible to detect non-beacon BLE devices with the library. You can also calculate the estimated distance to the devices if you first measure the known rssi at one meter for the device.
The code below shows how to do this:
final DistanceCalculator distanceCalculator = new ModelSpecificDistanceCalculator(this, null);
final int rssiAtOneMeter = -59;
mBeaconManager.setNonBeaconLeScanCallback(new NonBeaconLeScanCallback() {
@Override
public void onNonBeaconLeScan(BluetoothDevice bluetoothDevice, int rssi, byte[] bytes) {
Double estimatedDistnaceInMeters = distanceCalculator.calculateDistance(rssiAtOneMeter, rssi);
// TODO: do something with estimatedDistanceInMeters
}
});

davidgyoung
- 63,876
- 14
- 121
- 204
-
Thanks, I see that setNonBeaconLeScanCallback was added in the latest release. – Droider Nov 26 '15 at 11:58
-
Very nice feature. However the callback is just fired once although the non-beacon BLE device is still advertising, and the beaconManager still gets callbacks from beacon devices. Is there any trick to do on the beaconManager setup? (for example on iOS we can tell if we want to discover only once each device or getting notified on each scan round… could such a rule happen in this case?) – JBA Jul 23 '17 at 13:38
-
More info: the issue I just described above is occuring on a Samsung S4 mini with Android 4.4.2. On a Nexus 5x with Android 7.1.2 the callback works as expected (notifying multiple times the presence). Any clue on what Android 7 has/does that 4.4 does not... ? – JBA Jul 23 '17 at 15:29
-
Please open a new question as it is hard to give a detailed answer in comments. Please also try library version 2.9 to. See if it has different behavior than the latest library version as there was a change in 2.10 that may affect this. – davidgyoung Jul 23 '17 at 19:59
-
+JBA can you please link the new question here. Thank you. – Mr. Unnormalized Posterior Aug 21 '17 at 05:53