Search code examples
androidibeaconibeacon-androidaltbeaconandroid-ibeacon

Monitor non-beacon BLE devices (Android Beacon Library)


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?


Solution

  • 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
            }
        });