This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Issue when ble_connectivity has pending packets

Hi Support Team,

I used SDK14.1 with nrf52840 on PCA10056. I have a controller which was based on pc-ble-driver running on the host, and a target which was based on ble_connectivity/uart_hci example running on the PDK. I will write verbose details about my problem here and try to let you understand it more clearly, thank you for your time.

I made slightly changes in my ble_connectivity application, I noticed every time when pc-ble-driver connects to the ble_connectivity app over uart, pc-ble-driver will send reset command to my target to let it do NVIC_SystemReset() first. Because of some limitations, I have to keep the target memory while the target app was running, so I cannot do NVIC_SystemReset() in my target app which will directly reset it and lose memory, and I used nrf_sdh_disable_request() / nrf_sdh_enable_request() to reset softdevice instead of reset system. Due to some hardware requirements, I also have to add an internal communication protocol to my ble_connectivity application, all the traffic will be encoded/decoded before and after go into uart_hci transport layer. The internal protocol used a couple of input/out queues for data in and out.

My pc-ble-driver and ble_connectivity application could mostly work well, however, when I tested them for lots of times, I did find a certain issue. In my test, host will send scan_start command to target after they completed handshaking and setup connection(such as sync and ack, state machine change in hci_link_control). The target will start scan and send received advertising packets back to host immediately. The host will trigger scan stop to target after a few seconds and then the target will stop scan.

I found that when host send scan stop command to target, targets will stop scan, and host will also tell target to close the internal queue which means the connection has being closed. (The queue will be setup again in the next time test). However, if there has pending packets (such as a lot of advertising packets) at target after target stop scan and close the queue, target will not be able to send the pending packets to host because the queue has been closed. When the queue was established again in the next time host run the test, target will try to resend the pending packets again but host won't accept them and won't send ack response to target, thus a failure occurred eventually.

I tried to debug the failure, and I found that the root cause was HCI TX state machine was wait for ACK for the pending packets last time, but host will never send ack back.

The difficulty was that I cannot use NVIC_SystemReset() in my ble_connectiviy application to clear the pending packets and reset the system. I also think that even if I could be able to reset HCI state machine and reset HCI event queue, the issue won't be resolved, because the upper layer in softdevice was still waiting the ack packets, too, not only the HCI transport layer.

So could you give me some advice about this issue? Looking forward to your reply, thanks.

Best regards,

Tengfei.

Related