连接稳定性问题

14个职位/0个新职位
Last post
zwang308
离线
Last seen:4 years 4 months ago
Master
加入:2014-07-02 14:15
连接稳定性问题

嗨,对话,

我正在开发一对基于DA14580的BLE设备,包括服务器和从机。在相互连接之后,即使我让这些处理器处于空闲状态(没有BLE读/写/通知,没有i2c,gpio。。。但它们仍然随机断开。看起来其中一个在链接层损坏了,因为断开连接后它们无法再次重新连接。下面是我为这个连接设置的参数和一些wireshark捕获。

msg->nb_peers = 1;
memcpy((void*)&msg->peers[0].addr,(void*)peer\u addr,BD\u addr\u LEN);
msg->peers[0]。addr\u type=peer\u addr\u 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捕获:

9796 61.273854000 Master Slave BLE Data 26 Empty Data PDU
9797 61.275295000从主机BLE数据26空数据PDU
9798 61.286603000主从BLE数据26空数据PDU
9799 61.287569000 Slave Master BLE Data 26 Empty Data PDU
9800 61.298855000 Master Slave BLE Data 26 Empty Data PDU
9801 61.299789000从主机BLE数据26空数据PDU
9802年62.320227000 ab_mat5 BLE ADV 48 ADV_IND
9803 62.321788000资产负债表48资产负债表

Server and client keep the connection for 60s and could not connect to each other anymore.

我仍然可以看到从机端的广告,但即使使用带有LightBlue应用程序的Iphone,我也无法再连接到从机。
Wireshark捕获:
25 6.273182000资产负债表48资产负债表
26 6.274736000 50:0b:f8:18:ac:29 80:ea:ca:00:00:41 BLE ADV 60 CONNECT_REQ
27 6.276461000 Master Slave BLE Data 26 Empty Data PDU
28 6.303327000 Master Slave BLE Data 26 Empty Data PDU
29 6.333342000 Master Slave BLE Data 26 Empty Data PDU
30 6.363329000 Master Slave BLE Data 26 Empty Data PDU
31 6.393384000 Master Slave BLE Data 26 Empty Data PDU
32 6.423327000 Master Slave BLE Data 26 Empty Data PDU
33 6.453367000 Master Slave BLE Data 26 Empty Data PDU
34 6.483385000 Master Slave BLE Data 26 Empty Data PDU
35 6.513421000 Master Slave BLE Data 26 Empty Data PDU
36 6.543378000 Master Slave BLE Data 26 Empty Data PDU
37 6.573448000 Master Slave BLE Data 26 Empty Data PDU
38 6.603361000主从BLE数据26空数据PDU
39 6.633361000主从BLE数据26空数据PDU
40 7.640482000 ab_mat4 BLE ADV 48 ADV_IND
41 7.642505000 ab_mat4 BLE ADV 48 ADV_IND

在这个测试中,我将连接间隔设置为12.5毫秒。在这种情况下,服务器和客户端将在连接60秒到45分钟后随机断开连接。

In my latter test, I change the connection interval to be 30ms. They could keep the connection much longer(more than 10 hours), but still they disconnect.

我假设如果我让处理器处于空闲状态,所有的事情都应该由BLE堆栈自动处理,发送空的来保持连接应该与我的应用程序代码无关。另外,在它们断开连接时,我没有任何应用程序活动。

Please help me to find the reason why the disconnect and how to improve the stability of the connection.

Thanks a lot.

Keywords:
Device:
zwang308
离线
Last seen:4 years 4 months ago
Master
加入:2014-07-02 14:15
一些更新,

一些更新,

从我的夜间测试来看,ble计时器似乎工作不正常。
Firstly, it works okey for about 3 hours(probably more). We could see master sends an empty PDU to slave every 30ms as the value I set.
726216 10926.699285000 Master Slave BLE Data 26 Empty Data PDU
726217 10926.699861000 Slave Master BLE Data 26 Empty Data PDU
726218 10926.729275000 Master Slave BLE Data 26 Empty Data PDU
726219 10926.729815000 Slave Master BLE Data 26 Empty Data PDU
726220 10926.759274000主从BLE数据26空数据PDU
726221 10926.760253000 Slave Master BLE Data 26 Empty Data PDU
726222 10926.789250000 Master Slave BLE Data 26 Empty Data PDU
726223 10926.790219000 Slave Master BLE Data 26 Empty Data PDU
726224 10926.818524000主从BLE数据26空数据PDU
I guess the sniffer lost one capture here..
726225 10926.848719000主从BLE数据26空数据PDU
726226 10926.850223000 Slave Master BLE Data 26 Empty Data PDU
To some reason, I lost the capture for about 10 hours. Luckily, just before they disconnect, the sniffer get the signal again. But at this time, master side seems to behave crazy, it sends a empty PDU to client every about 2ms or maybe as soon as it receives an empty PDU from the slave.
726227 47816.865216000 Master Slave BLE Data 26 Empty Data PDU
726228 47816.866244000 Slave Master BLE Data 26 Empty Data PDU
726229 47816.867143000主从BLE数据26空数据PDU
726230 47816.868015000 Slave Master BLE Data 26 Empty Data PDU
726231 47816.868887000主从BLE数据26空数据PDU
726232 47816.869742000从主机BLE数据26空数据PDU
726233 47816.870613000 Master Slave BLE Data 26 Empty Data PDU
726234 47816.871492000从主机BLE数据26空数据PDU
.......
726560 47817.196839000 Master Slave BLE Data 26 Empty Data PDU
726561 47817.197927000 Slave Master BLE Data 26 Empty Data PDU
726562 47817.198787000 Master Slave BLE Data 26 Empty Data PDU
726563 47817.199657000从主机BLE数据26空数据PDU
726564 47817.201497000 ab_mat5 BLE ADV 48 ADV_IND
726565 47817.202433000 ab_mat5 BLE ADV 48 ADV_IND

我希望这些信息能让你们对这个问题有更多的了解,非常感谢。

Thanks!

MT_dialog
离线
Last seen:2个月1周前
工作人员
加入:2015-06-08 11:34
您好,zwang308,

您好,zwang308,

您在当前实现中使用的SDK是什么?您有什么开发工具包?据我所知,您使用的连接参数与DSPS项目几乎相同。您的假设是正确的,当您与设备连接时,堆栈将通过交换空数据包来保持连接的活动性,而不要求应用程序执行任何操作。

From the 1st log i can see that your master stops sending empty packets in order to keep the connection alive so there is no response for the slave side, timeout occurs and the connection is lost when this happens perhaps you should check the state of your host.

From the 2nd log seems the slave doesn't respond to the connection request from the host, check how you are handling the connection request in your peripheral code, and check if the device reaches the connection confirmation.

关于第三个日志,这似乎很奇怪,我无法想象为什么中央会以如此高的速率发送空数据包,特别是如果没有数据要发送,中央本身或设备。

Thanks MT_dialog

zwang308
离线
Last seen:4 years 4 months ago
Master
加入:2014-07-02 14:15
I am using SDK 3.0.10.1.

I am using SDK 3.0.10.1.

The problem is the connection breaks randomly.

对于12ms的连接间隔,有时连接正常超过一小时;但有时两分钟后就断开了。

After I change the connection interval to 30ms, the average connected time gets much longer. But they still disconnect randomly,

When they get disconnect, there is really no application activity. I assume the BLE stack will take care of the connection, send/ack empty PDU automatically during that time.
而且,即使它们断开连接,也应该能够重新连接。但一旦它们断开连接,我就无法再连接到从属设备,无论我使用主应用程序还是使用一些标准设备,例如IPhone。

To me, it looks like part of slave's BLE stack is screwed up: slave could receive the connection request from master(it stops advertising) but it could not send an ack. So, the both side just disconnect after 1s. Afert that, slave begin to advertise again.

这些都是我测试的结果。

Thanks a lot for the help!

zwang308
离线
Last seen:4 years 4 months ago
Master
加入:2014-07-02 14:15
By the way, I use the same

顺便说一下,我对所有测试都使用相同的代码库。我确信从端发送了连接请求确认,否则他们不会连接。同样,问题是连接——随机保持连接一段时间——断开连接,再也无法重新连接。

谢谢,

MT_dialog
离线
Last seen:2个月1周前
工作人员
加入:2015-06-08 11:34
您好,zwang308,

您好,zwang308,

I ve implemented a central and a peripheral on the SDK 3.0.10.1 (no profiles included) i ve set the connection parameters to the host identical with your's with a connection interval equal to 12.5 ms between a pro and a basic kit. So far everything seems correct and the connection lasts as long as i could watch (more than two hours) also i am able to reconnect to host, (in extended sleep mode yet). Have you implemented any profile or any other functionallity in order to try and reproduce your issue?

Thanks MT_dialog

zwang308
离线
Last seen:4 years 4 months ago
Master
加入:2014-07-02 14:15
Hi MT_dialog,

Hi MT_dialog,

我所做的和你的DSPS项目差不多。

我开发了一个I2C驱动程序,当我收到一个包时,我把数据放进nvram。在app\u asynch\u trim函数中,我提取缓冲区并通过BLE发送数据。

但在我的测试中,我禁用了I2C驱动程序和app\u asynch\u trim中的pull函数。在测试中,两个DA14580在断开连接时实际上什么也没做。

据我观察,他们不断发送空PDU有一段时间,突然主停止发送空PDU。我们有办法知道为什么主机停止发送空的PDU吗?我们能从内核得到一个消息来知道它们为什么断开连接吗。

在我看来,它们好像是随机断开的。上周我们做了很多测试,有时连接良好超过16小时;有时两分钟后就会断开。

我真的很困惑。

谢谢!

MT_dialog
离线
Last seen:2个月1周前
工作人员
加入:2015-06-08 11:34
您好,zwang308,

您好,zwang308,

Can you run your master form keil and check when this issue occurs, what is the state of your master ? Also are your handlers indicate that there is a disconnection either by the master or at least by your slave when he stops receiving data by your host. You can place a break point to your device and check what you get as a disconnection reason. There is no way to check why the master doesn't send any data, an error indication or something like that since this should not happen the stack should always keep the connection.

Thanks MT_dialog

zwang308
离线
Last seen:4 years 4 months ago
Master
加入:2014-07-02 14:15
Hi MT_Dialog,

Hi MT_Dialog,

For the first time they disconnect. The error code on peripheral is 0x13(REMOTE USER TERMINATED CONNECTION) while the error code on central side is 0x08(CONNECTION TIMEOUT).

After that, the error code on peripheral side is always 0x08 and central side as 0x3e(CONNECTION FAILED TO BE ESTABLISHED).

I don't think the code actually stops at a point because both side is keep switching between advertising/scanning and connected state.

我们知道为什么会这样吗?

Do we have a method to soft reset the chip(run firmware from the beginning without reload the firmware or just reset BLE stack)?

Thanks a lot.

MT_dialog
离线
Last seen:2个月1周前
工作人员
加入:2015-06-08 11:34
您好,zwang308,

您好,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.

You can try to either issue a reset by using the SW_RESET field of the SYS_CTRL_REG and set the starting address to the sysram (please check the datasheet) although its not a good idea and reboot from the original image is prefered (download the code in the 580 using the bootloader) also you can try to send a GAPM_RESET command in order to reset the stack.

另外,由于我们无法复制问题,是否可以共享一些代码(中央和设备)以便查看?

Thanks MT_dialog

zwang308
离线
Last seen:4 years 4 months ago
Master
加入:2014-07-02 14:15
嗨,MT\u dialog,

嗨,MT\u dialog,

Could you please provide me a e-mail address for sending the code? You could reach me in person through e-mail.

Thanks a lot,

MT_dialog
离线
Last seen:2个月1周前
工作人员
加入:2015-06-08 11:34
您好,zwang308,

您好,zwang308,

问题是由过时的SDK造成的。

Thanks MT_dialog

menson
离线
Last seen:3 years 5 days ago
加入:2018-01-16 08:09
Hi, MT_dialog.

Hi, MT_dialog.
I am suffering the same error as Mr zwang308's. I am using the sdk version V3.0.8. You said it was due to an obsolete SDK, please tell me which sdk is ok. Thanks.

MT_dialog
离线
Last seen:2个月1周前
工作人员
加入:2015-06-08 11:34
Hi menson,

Hi menson,

The latest SDK is the 5.0.4 for the 580 device.

Thanks MT_dialog