监控非信标 BLE 设备(Android 信标库)
Monitor non-beacon BLE devices (Android Beacon Library)
使用Android Beacon Library,是否可以监控非Beacon BLE 设备?如果是,我如何在没有 txPower 的情况下使用 rssi 估计他们的距离?
是的,可以使用库检测非信标 BLE 设备。如果您首先在一米处测量设备的已知 RSSI,您还可以计算到设备的估计距离。
下面的代码展示了如何做到这一点:
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
}
});
使用Android Beacon Library,是否可以监控非Beacon BLE 设备?如果是,我如何在没有 txPower 的情况下使用 rssi 估计他们的距离?
是的,可以使用库检测非信标 BLE 设备。如果您首先在一米处测量设备的已知 RSSI,您还可以计算到设备的估计距离。
下面的代码展示了如何做到这一点:
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
}
});