Hi Dialog,
I am developing a pair of BLE device, both server and slave, base on DA14580. After connected to each other, even I leave these processor to be idle(no BLE read/write/notify, no i2c, gpio... active ) but they still disconnect randomly. It looks like one of them corrupts in link layer, because after disconnect they could not reconnect again. Below are the parameters I set for this connection and some wireshark captures.
msg-> nb_peers = 1;
memcpy((void *) &msg->peers[0].addr, (void *)peer_addr, BD_ADDR_LEN);
msg->peers[0].addr_type = peer_addr_type;
msg-> con_intv_max = 10;
msg-> con_intv_min = 10;
msg-> ce_len_max = 0x20;
msg-> ce_len_min = 0x20;
msg-> con_latency = 0;
msg-> superv_to = 100;
msg-> scan_interval = 0x180;
msg-> scan_window = 0x160;
msg-> op.code = gapm_connection_direct;
wireshark capture:
9796 61.273854000主从机BLE数据26空数据PDU
9797 61.275295000 Slave Master BLE Data 26 Empty Data PDU
9798 61.286603000 Master Slave BLE Data 26 Empty Data PDU
9799 61.287569000从站主机BLE数据26空数据PDU
9800 61.298855000主从电池数据26空数据PDU
9801 61.299789000 Slave Master BLE Data 26 Empty Data PDU
9802 62.320227000 AB_MAT5 BLE ADV 48 ADV_IND
9803 62.321788000 ab_mat5 BLE ADV 48 ADV_IND
服务器和客户端保持60s的连接,无法相互连接。
I could still see slave side advertising, but even use an Iphone with LightBlue application, I could not connect to the slave anymore.
Wireshark capture:
25 6.273182000 ab_mat4 BLE ADV 48 ADV_IND
26 6.274736000 50:0B:F8:18:AC:29 80:EA:CA:00:00:41 BLE ADV 60 Connect_Req
27 6.276461000主从机BLE数据26空数据PDU
28 6.303327000主从机BLE数据26空数据PDU
29 6.333342000主从机BLE数据26空数据PDU
30 6.363329000主从机BLE数据26空数据PDU
31 6.393384000主从机BLE数据26空数据PDU
32 6.423327000主从机BLE数据26空数据PDU
33 6.453367000主从机BLE数据26空数据PDU
34 6.483385000主从机BLE数据26空数据PDU
35 6.513421000主从机BLE数据26空数据PDU
36 6.543378000主从机BLE数据26空数据PDU
37 6.573448000主从机BLE数据26空数据PDU
38 6.603361000 Master Slave BLE Data 26 Empty Data PDU
39 6.633361000 Master Slave BLE Data 26 Empty Data PDU
40 7.640482000 AB_MAT4 BLE ADV 48 ADV_IND
41 7.642505000 AB_MAT4 BLE ADV 48 ADV_IND
In this test, I set the connection interval to be 12.5 ms. In this case, sever and client will disconnect randomly after 60 s to 45 mins they connect.
在后一种测试中,我将连接间隔更改为30ms。他们可以保持连接更长(超过10小时),但仍然脱离了。
I would assume if I leave the processor in idle state, everything should handle by BLE stack automatically and sending empty to keep the connection should have nothing to do with my application code. Also, I not have any application activity at the time they disconnect.
请帮我找到断开连接和如何提高连接稳定性的原因。
非常感谢。
Some update,
From my overnight test, it looks like the ble timer is not working appropriately.
首先,它将OKEY工作约3小时(可能更多)。我们可以看到主机将空的PDU发送到从每30ms设置为从Alave作为我设置的值。
726216 10926.699285000主从池数据26空数据PDU
726217 10926.699861000从站主板数据26空数据PDU
726218 10926.729275000主从机BLE数据26空数据PDU
726219 10926.729815000从站主机BLE数据26空数据PDU
726220 10926.759274000 Master Slave BLE Data 26 Empty Data PDU
726221 10926.760253000从站主板数据26空数据PDU
726222 10926.789250000主从机BLE数据26空数据PDU
726223 10926.790219000从机主BLE数据26空数据PDU
726224 10926.818524000 Master Slave BLE Data 26 Empty Data PDU
我猜嗅探器丢失了一个捕获。
726225 10926.848719000 Master Slave BLE Data 26 Empty Data PDU
726226 10926.850223000从机主BLE数据26空数据PDU
出于某种原因,我丢失了大约10个小时的捕获。幸运的是,就在他们断开之前,嗅探器再次获得信号。但是此时,主侧似乎表现出疯狂,它每次约2ms向客户端发送一个空的PDU,或者一旦收到来自从机的空的PDU,就会向客户端发送。
726227 47816.865216000主从机BLE数据26空数据PDU
726228 47816.866244000从站主板数据26空数据PDU
726229 47816.867143000 Master Slave BLE Data 26 Empty Data PDU
726230 47816.868015000从机主机BLE数据26空数据PDU
726231 47816.868887000 Master Slave BLE Data 26 Empty Data PDU
726232 47816.869742000 Slave Master BLE Data 26 Empty Data PDU
726233 47816.8706106070主从电池数据26空数据PDU
726234 47816.871492000 Slave Master BLE Data 26 Empty Data PDU
.......
726560 47817.196839000主从机BLE数据26空数据PDU
726561 47817197000从机主BLE数据26空数据PDU
726562 47817.19878000主从机BLE数据26空数据PDU
726563 47817.199657000 Slave Master BLE Data 26 Empty Data PDU
726564 47817.201497000 AB_MAT5 BLE ADV 48 ADV_IND
726565 47817.202433000 AB_MAT5 BLE ADV 48 ADV_IND
我希望这些信息给你们更有意义about this problem, thanks a lot.
谢谢!
Hi zwang308,
Which SDK you are using in your current implementation and what is the development kit you have ? As far as i can tell the connection parameters you are using are the almost same with the DSPS project. Your assumptions are correct, when you are connected with a device the stack will keep the connection alive by exchanging empty packets without demanding from the application to do anything.
从第一个日志中,我可以看到您的主站停止发送空数据包,以便保持连接,因此对从侧没有响应,发生超时,并且当您应该检查主机时,连接丢失。
从第2个日志似乎从主机响应从主机的连接请求,检查如何在外围代码中处理连接请求,并检查设备是否达到连接确认。
About the 3rd log, this seems very odd, i cant imagine why the central would start sending empty packets in such a high rate especially if has no data to send, the central itself or the device.
谢谢mt_dialog.
我正在使用SDK 3.0.10.1。
问题是连接随机打破。
For 12ms connection interval, sometimes the connection goes well for more than an hour; but sometimes they just disconnect after 2 minutes.
在将连接间隔更改为30ms后,平均连接时间更长。但他们仍然随机断开连接,
当他们断开连接时,实际上没有应用程序活动。我假设BLE堆栈将处理连接,在此期间自动发送/ ACK空PDU。
Also, even they disconnected, they should be able to reconnect. But once they disconnect, I could not connect to the slave anymore, no matter I use my master application or use some standard device e.g. IPhone.
对我而言,它看起来像Slave的BLE堆栈的一部分搞砸了:从机可以接收来自Master的连接请求(它停止广告),但它无法发送ACK。所以,两侧刚刚在1秒后断开连接。奴隶开始再次宣传奴隶。
These are everything I got from my test.
非常感谢您的帮助!
顺便说一下,我使用相同的code base for all tests. I am sure the slave side send the connect request confirmation, otherwise they would not connect. Again, the problem is the connect-----keep the connection for a random time---disconnect and never able to reconnect anymore.
Thanks,
Hi zwang308,
I VE在SDK 3.0.10.1上实现了一个中心和外围设备(包括配置文件)I VE将连接参数设置为与您的主机相同的主机,其中连接间隔等于Pro和基本套件之间的12.5ms。到目前为止,一切似乎都是正确的,并且只要我能观看(超过两个小时),即可持续的连接也能够重新连接到主机,(尚未扩展睡眠模式)。您是否实施了任何配置文件或任何其他功能,以便尝试和重现您的问题?
谢谢mt_dialog.
嗨mt_dialog,
What I did is pretty much the same as your DSPS project.
I develop an I2C driver and put data into nvram when I receive a package. In app_asynch_trim function, I pull the buffer and send data through BLE.
But in my test, I disable the I2C driver and the pull function in app_asynch_trim. In the test, the two DA14580s are really doing nothing when they disconnect.
From my observation, they keep sending empty PDU for a while and suddenly the master stop to send empty PDU. Do we have method to know why master stop sending empty PDU? Could we get a message from the kernel to know why they disconnect.
To me, it seems like they disconnect randomly. We did lots of test last week, sometimes the connection is good for more than 16 hour; sometimes they disconnect after 2 minutes.
It really confused me.
非常感谢!
Hi zwang308,
您可以运行主表单keil并检查此问题时检查,您的主人是什么状态?您的处理程序也表明当您停止主机接收数据时,主站或至少由您的从站断开连接。您可以将休闲点放在您的设备上,并检查您作为断开连接的原因。没有办法检查主设备不会发送任何数据,错误指示或类似的东西,因为这不应该发生堆栈应该始终保持连接。
谢谢mt_dialog.
嗨mt_dialog,
他们第一次断开连接。外围设备上的错误代码为0x13(远程用户终止连接),而中心侧的错误代码为0x08(连接超时)。
之后,外设侧的错误代码始终为0x08,中心侧为0x3e(连接无法建立)。
我认为代码实际上停止在某种程度上,因为这两个方面都在广告/扫描和连接状态之间保持切换。
Do we have any idea why that happens?
我们是否有一个软复位芯片的方法(从开头运行固件而无需重新加载固件或仅重置BLE堆栈)?
非常感谢。
Hi zwang308,
We haven't observed anything similar in tests we performed (i.e. the central to just stop sending packets) although we managed to track a cornercase where the peripheral isn't able to connect under specific circumstances, the patch for the specific cornercase isn't yet released. For this kind of situations we propose either to perform a sw reset to the 580 or reset the stack.
您可以尝试使用sys_ctrl_reg的sw_reset字段发出重置,并将启动地址设置为sysram(请检查数据表)虽然它不是一个好主意,并优先从原始图像重新启动(下载代码580使用引导加载程序)也可以尝试发送GapM_Reset命令以重置堆栈。
Also is it possible to share some code (central and device) in order to have a look since we couldn't replicate the problem on our side?
谢谢mt_dialog.
HI MT_dialog,
您能否向我提供发送代码的电子邮件地址?你可以通过电子邮件亲自到达我。
非常感谢,
Hi zwang308,
Problem was due to an obsolete SDK.
谢谢mt_dialog.
嗨,mt_dialog。
我正在遭受与Zwang308先生的错误相同的错误。我正在使用SDK版本v3.0.8。你说这是由于一个过时的SDK,请告诉我哪个SDK没问题。谢谢。
嗨menson,
最新的SDK是580设备的5.0.4。
谢谢mt_dialog.