首页 > 解决方案 > 不定期从 Eddystone 信标获取 Android 信标库的测距更新

问题描述

当从带有 TLM 信标的 Eddystone UID 获取测距更新时,即使应该每秒调用一次 didRangeBeaconsInRegion(),更新也不定期。我偶尔会在日志上看到更新,有时甚至 8-10 秒没有更新,然后偶尔会再次出现。

下面的部分日志显示了从检测到信标的那一刻起 D/RangingActivity 的零星性质;

D/BluetoothLeScanner: onClientRegistered() - status=0 clientIf=7
D/BluetoothAdapter: STATE_ON
D/BluetoothAdapter: STATE_ON
D/BluetoothLeScanner: Stop Scan
D/BluetoothLeScanner: Start Scan
D/BluetoothAdapter: STATE_ON
D/BluetoothAdapter: STATE_ON
D/BluetoothAdapter: STATE_ON
    STATE_ON
D/BluetoothLeScanner: onClientRegistered() - status=0 clientIf=7
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
I/ScanHelper: Non-distinct packets detected in a single scan.  Restarting scans unecessary.
D/RangingActivity: I see a beacon transmitting namespace id: 0x00010203040506070809 and instance id: 0x04514000b000 approximately 16.9709421436514 meters away.
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/RangingActivity: I see a beacon transmitting namespace id: 0x00010203040506070809 and instance id: 0x04514000b000 approximately 37.302382194318774 meters away.
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/RangingActivity: I see a beacon transmitting namespace id: 0x00010203040506070809 and instance id: 0x04514000b000 approximately 31.25429550588763 meters away.
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/RangingActivity: I see a beacon transmitting namespace id: 0x00010203040506070809 and instance id: 0x04514000b000 approximately 28.936042431918796 meters away.
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/RangingActivity: I see a beacon transmitting namespace id: 0x00010203040506070809 and instance id: 0x04514000b000 approximately 26.86915572611937 meters away.
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/RangingActivity: I see a beacon transmitting namespace id: 0x00010203040506070809 and instance id: 0x04514000b000 approximately 18.93489852744025 meters away.
D/RangingActivity: Lux value is 12544 The above beacon is sending telemetry version 0, has been up for : 398 seconds, has a battery level of 3320 mV, and has transmitted 77 advertisements.
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/RangingActivity: I see a beacon transmitting namespace id: 0x00010203040506070809 and instance id: 0x04514000b000 approximately 18.93489852744025 meters away.
D/RangingActivity: Lux value is 12544 The above beacon is sending telemetry version 0, has been up for : 419 seconds, has a battery level of 3320 mV, and has transmitted 81 advertisements.
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes
D/RangingActivity: I see a beacon transmitting namespace id: 0x00010203040506070809 and instance id: 0x04514000b000 approximately 35.47854961599127 meters away.
D/RangingActivity: Lux value is 12544 The above beacon is sending telemetry version 0, has been up for : 449 seconds, has a battery level of 3320 mV, and has transmitted 87 advertisements.
D/ScanRecord: parseFromBytes
D/ScanRecord: parseFromBytes

我的代码与以下文档中描述的相同:

https://developer.radiusnetworks.com/2015/07/14/building-apps-with-eddystone#

https://altbeacon.github.io/android-beacon-library/eddystone-how-to.html

我尝试了不同的信标广告时段,但问题仍然存在。有没有办法定期更新测距,即每秒?

提前致谢...

标签: androidbeaconeddystone

解决方案


我怀疑问题出在 Eddystone-TLM 框架本身。遥测帧是交错帧,其发送频率不如 UID 或主要 Eddystone 信标类型。遥测仅在新的 TLM 帧出现时更新,如您所描述的,这可能很少见。库的扫描间隔对此无法控制——这正是 TLM 的工作方式,并且是硬件交错率的函数。

不管上述情况如何,库总是定期发送 didRangeBeacons 回调,尽管如果没有检测到,检测到的信标列表可能是空的。您的 Eddystone-UID 检测率应该更加规律。尝试在您的 didRangeBeacons 回调中添加更多日志记录,包括时间戳和信标计数,以查看发生了什么。

您可以尝试使用我修改过的 Android Beacon 库进行测试以确认,并在必要时查找您的代码中的任何差异。

添加 beaconManager.setDebug(true); 可以获得内部调试日志。


推荐阅读