我正在尝试在 android 中使用 ble 设备(信标)做室内定位系统。它在程序开始时找到最近的信标。它会在几秒钟内检测到位置变化,但几秒钟后它对变化的反应为时已晚。
现在我只打印信标的 id(我给了这个 id)
我认为问题与记忆有关。可能是什么问题呢?
LeScanCallback 和 Handler 函数:
@Override
public void onLeScan(BluetoothDevice device, int rssi, byte[] scanRecord) {
List<AdRecord> records = AdRecord.parseScanRecord(scanRecord);
beaconScan = new BluetoothBeacon(records, device.getAddress(), rssi);
mHandler.sendMessage(Message.obtain(null, 0, beaconScan));
}
private Handler mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
beaconHandler = (BluetoothBeacon) msg.obj;
mBeacons.put(beaconHandler.getAddress(), beaconHandler);
rssiVal = getRssiString(beaconHandler);
dbHelper.insertDevice(beaconHandler.getName(), beaconHandler.getAddress(),
rangeValue,rssiVal,currentTime);
rssiID = model.findNear(beaconHandler.getAddress(),beaconHandler.getSignal());
Log.i("id", "Nearest beacon id: " + rssiID);
}
};