【发布时间】:2023-03-26 22:55:02
【问题描述】:
我必须计算任何 ble 设备(不仅仅是信标)的距离。我正在使用 devloper android 网站上提供的 BluetoothLeGatt 示例应用程序,这是链接 http://developer.android.com/downloads/samples/BluetoothLeGatt.zip。我正在用这种方法打印日志
// Device scan callback.
private BluetoothAdapter.LeScanCallback mLeScanCallback =
new BluetoothAdapter.LeScanCallback() {
@Override
public void onLeScan(final BluetoothDevice device, int rssi, final byte[] scanRecord) {
runOnUiThread(new Runnable() {
@Override
public void run() {
mLeDeviceListAdapter.addDevice(device);
mLeDeviceListAdapter.notifyDataSetChanged();
Log.e("scanrecord", Arrays.toString(scanRecord));
}
});
}
};
这是我的日志
05-05 13:58:35.811 8034-8051/com.example.android.bluetoothlegatt D/BluetoothLeScanner: onScanResult() - ScanResult{mDevice=08:7C:BE:49:7D:9E, mScanRecord=ScanRecord [mAdvertiseFlags=6, mServiceUuids=[0000fee8-0000-1000-8000-00805f9b34fb, 0000fff0-0000-1000-8000-00805f9b34fb], mManufacturerSpecificData={}, mServiceData={}, mTxPowerLevel=-2147483648, mDeviceName=Safety15HA006634], mRssi=-80, mTimestampNanos=2601215802991397}
05-05 13:58:35.816 8034-8034/com.example.android.bluetoothlegatt E/scanrecord: [2, 1, 6, 17, 8, 83, 97, 102, 101, 116, 121, 49, 53, 72, 65, 48, 48, 54, 54, 51, 52, 5, 3, -24, -2, -16, -1, 5, 18, 6, 0, -128, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0].
在搜索时,我找到了计算此链接 Understanding ibeacon distancing 上的距离的公式。我的问题是如何从scanRecord 获取传输功率。还有什么是mTxPowerLevel,我怎样才能得到它,因为这是从 android ble 类记录的。
【问题讨论】:
标签: android distance bluetooth-lowenergy rssi