Android蓝牙:丢弃数据包

时间:2017-06-05 16:37:20

标签: android bluetooth-lowenergy gatt nrf51

我们已经构建了一个可穿戴设备,可以测量并通过BLE将结果每20毫秒发送到Android设备。我们得到了奇怪的结果,其中前270个数据包按时收到并且没有丢失,但在271个事情变得奇怪。我们将给出五个数据包(按时),然后丢弃32个数据包,然后重复 这款手机是搭载Android 7.1.1的Nexus 5X。该设备运行的是带有BLE 4.2的nRF51。我们正在使用基于Template应用程序的Android nRF工具箱v2.4.0。 我们得到的一个假设是ConnectionPriority错误,我们需要设置更高的优先级。我们尝试在BleManager中添加以下内容: mBluetoothGatt.requestConnectionPriority(BluetoothGatt.CONNECTION_PRIORITY_HIGH); 但是没有区别。奇怪的是,系统似乎可以找到前270个数据包。 有任何想法如何调试这个?

以下示例logcat。请注意,数据包编号是Android端收到的数据包编号,来自设备端的数据包编号:

Packet #258; SensorTime = 256.175sec; Delta = 018.8msec
Packet #259; SensorTime = 256.200sec; Delta = 025.0msec
Packet #260; SensorTime = 256.213sec; Delta = 012.5msec
Packet #261; SensorTime = 256.238sec; Delta = 025.0msec
Packet #262; SensorTime = 256.256sec; Delta = 018.8msec
Packet #263; SensorTime = 256.275sec; Delta = 018.8msec
Packet #264; SensorTime = 256.300sec; Delta = 025.0msec
Packet #265; SensorTime = 256.319sec; Delta = 018.8msec
Packet #266; SensorTime = 256.338sec; Delta = 018.8msec
Packet #267; SensorTime = 256.356sec; Delta = 018.7msec
Packet #268; SensorTime = 256.375sec; Delta = 018.8msec
Packet #269; SensorTime = 256.394sec; Delta = 018.8msec
Packet #270; SensorTime = 256.419sec; Delta = 025.0msec
Packet #271; SensorTime = 256.438sec; Delta = 018.8msec
=== Time Fault :: Time   256.656sec : Time delta = 218.8 msec; mTime since last fault = 0.000 sec
Packet #272; SensorTime = 256.656sec; Delta = 218.8msec
=== Time Fault :: Time   257.294sec : Time delta = 637.5 msec; mTime since last fault = 0.001 sec
Packet #273; SensorTime = 257.294sec; Delta = 637.5msec
Packet #274; SensorTime = 257.313sec; Delta = 018.8msec
=== Time Fault :: Time   257.938sec : Time delta = 625.0 msec; mTime since last fault = 0.639 sec
Packet #275; SensorTime = 257.938sec; Delta = 625.0msec
=== Time Fault :: Time   258.594sec : Time delta = 656.3 msec; mTime since last fault = 0.003 sec
Packet #276; SensorTime = 258.594sec; Delta = 656.3msec
Packet #277; SensorTime = 258.613sec; Delta = 018.8msec
Packet #278; SensorTime = 258.638sec; Delta = 025.0msec
Packet #279; SensorTime = 258.650sec; Delta = 012.5msec
Packet #280; SensorTime = 258.675sec; Delta = 025.0msec
=== Time Fault :: Time   259.231sec : Time delta = 556.2 msec; mTime since last fault = 0.639 sec
Packet #281; SensorTime = 259.231sec; Delta = 556.2msec
Packet #282; SensorTime = 259.256sec; Delta = 025.0msec
Packet #283; SensorTime = 259.275sec; Delta = 018.8msec
Packet #284; SensorTime = 259.294sec; Delta = 018.7msec
Packet #285; SensorTime = 259.313sec; Delta = 018.8msec
=== Time Fault :: Time   259.875sec : Time delta = 562.5 msec; mTime since last fault = 0.657 sec
Packet #286; SensorTime = 259.875sec; Delta = 562.5msec
Packet #287; SensorTime = 259.894sec; Delta = 018.8msec
Packet #288; SensorTime = 259.913sec; Delta = 018.8msec
Packet #289; SensorTime = 259.931sec; Delta = 018.8msec
Packet #290; SensorTime = 259.956sec; Delta = 025.0msec
=== Time Fault :: Time   260.513sec : Time delta = 556.2 msec; mTime since last fault = 0.636 sec
Packet #291; SensorTime = 260.513sec; Delta = 556.2msec
Packet #292; SensorTime = 260.531sec; Delta = 018.8msec
Packet #293; SensorTime = 260.550sec; Delta = 018.8msec
Packet #294; SensorTime = 260.569sec; Delta = 018.8msec
Packet #295; SensorTime = 260.594sec; Delta = 025.0msec
=== Time Fault :: Time   261.169sec : Time delta = 575.0 msec; mTime since last fault = 0.645 sec
Packet #296; SensorTime = 261.169sec; Delta = 575.0msec
Packet #297; SensorTime = 261.188sec; Delta = 018.8msec
Packet #298; SensorTime = 261.213sec; Delta = 025.0msec
Packet #299; SensorTime = 261.231sec; Delta = 018.7msec
Packet #300; SensorTime = 261.250sec; Delta = 018.8msec
=== Time Fault :: Time   261.806sec : Time delta = 556.3 msec; mTime since last fault = 0.645 sec
Packet #301; SensorTime = 261.806sec; Delta = 556.3msec
Packet #302; SensorTime = 261.831sec; Delta = 025.0msec
Packet #303; SensorTime = 261.850sec; Delta = 018.8msec
Packet #304; SensorTime = 261.869sec; Delta = 018.8msec
Packet #305; SensorTime = 261.894sec; Delta = 025.0msec
=== Time Fault :: Time   262.456sec : Time delta = 562.5 msec; mTime since last fault = 1.283 sec
Packet #306; SensorTime = 262.456sec; Delta = 562.5msec
Packet #307; SensorTime = 262.469sec; Delta = 012.5msec
Packet #308; SensorTime = 262.488sec; Delta = 018.8msec
Packet #309; SensorTime = 262.506sec; Delta = 018.8msec
Packet #310; SensorTime = 262.525sec; Delta = 018.8msec
=== Time Fault :: Time   263.106sec : Time delta = 581.2 msec; mTime since last fault = 0.658 sec
Packet #311; SensorTime = 263.106sec; Delta = 581.2msec
=== Time Fault :: Time   263.750sec : Time delta = 643.8 msec; mTime since last fault = 0.631 sec
Packet #312; SensorTime = 263.750sec; Delta = 643.8msec
=== Time Fault :: Time   264.388sec : Time delta = 637.5 msec; mTime since last fault = 0.003 sec
Packet #313; SensorTime = 264.388sec; Delta = 637.5msec

1 个答案:

答案 0 :(得分:0)

使用BLE嗅探器跟踪数据包后,我们发现在设备端有一对坏常数:

Traceback (most recent call last):
  File "/usr/local/bin/mayavi2", line 7, in <module>
    from mayavi.scripts.mayavi2 import main
  File "/usr/local/lib/python2.7/dist-packages/mayavi/scripts/mayavi2.py",
line 494, in <module>
    raise ImportError(msg)
ImportError: No module named envisage.ui.workbench.api
Could not load envisage. You might have a missing dependency.

这些更正如下:

#define MIN_CONN_INTERVAL  MSEC_TO_UNITS(400, UNIT_1_25_MS)      
#define MAX_CONN_INTERVAL  MSEC_TO_UNITS(650, UNIT_1_25_MS)      

一旦纠正,连接率就解决了我们的罚款。最离奇的部分是一些设备和一些电话全速工作,但其他设备会陷入上述错误的连接优先级。 谢谢您的帮助。嗅探器是关键!