<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Connection failure - device gets stuck sending a notification in an infinite loop</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/39762/connection-failure---device-gets-stuck-sending-a-notification-in-an-infinite-loop</link><description>I am working on an nRF52832 BLE peripheral prototype which sends bulk data to a central as bursts of large notifications. I am encountering an error where the connection gets stuck - the peripheral keeps trying to send the same notification forever in</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 11 Mar 2019 08:19:00 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/39762/connection-failure---device-gets-stuck-sending-a-notification-in-an-infinite-loop" /><item><title>RE: Connection failure - device gets stuck sending a notification in an infinite loop</title><link>https://devzone.nordicsemi.com/thread/175251?ContentTypeID=1</link><pubDate>Mon, 11 Mar 2019 08:19:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3025ddb8-b778-4627-99e5-053f107bbfde</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;I tried to run your example again and I can see that 50k bytes of data has been transferred by your send_notify_task_func. Look at the PC value that came out of the while(n &amp;gt; 0) loop below&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-c68b122628834b14a18e0a98360056d6/pastedimage1552293273736v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;Doesn&amp;#39;t this mean that the data is being sent by notifications?&lt;/p&gt;
&lt;p&gt;The connection does not fail either.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Connection failure - device gets stuck sending a notification in an infinite loop</title><link>https://devzone.nordicsemi.com/thread/174895?ContentTypeID=1</link><pubDate>Thu, 07 Mar 2019 19:07:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a2375b78-e1f4-4203-8e54-265f685c519c</guid><dc:creator>Paolo D</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I did apply the nrf_sdh_freertos.c bug fix to the SDK and that did not fix the problem.&lt;/p&gt;
&lt;p&gt;I have also encountered the same problem again, this is what has changed since my previous report:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Running my application on a custom nRF52832 board instead of PCA10040&lt;/li&gt;
&lt;li&gt;Application is sending actual data read out of external flash memory instead of dummy data like my simplified error_demo example&lt;/li&gt;
&lt;li&gt;SDK is updated to nRF5_SDK_15.3.0_59ac345 (now includes the nrf_sdh_freertos.c bug fix)&lt;/li&gt;
&lt;li&gt;SoftDevice is S132 v6.1.1&lt;/li&gt;
&lt;li&gt;Toolchain is GCC ARM Embedded 7 2018-q2-update running on Windows 10&lt;/li&gt;
&lt;li&gt;pc-ble-driver-js is v2.5.1 running under nodejs 64-bit v10.15.1&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The problem still only occurs when the debugger is disconnected. Connecting the J-Link and launching the RTT Viewer fixes the problem.&lt;/p&gt;
&lt;p&gt;I have attached two more nRF Sniffer logs that show the link layer getting into a bad state:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/fail1.pcapng"&gt;devzone.nordicsemi.com/.../fail1.pcapng&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;In fail1.pcapng, everything is working properly until packet 11003. Before that point there are a lot of lost packets being re-sent but they always get through eventually.&lt;/p&gt;
&lt;p&gt;Packet 11004 is the first time the slave sends the packet (notification whose payload starts with 0x3a) which will eventually be re-sent in an infinite loop. It has SN=1 and NESN=0.&lt;/p&gt;
&lt;p&gt;In packet 11005 the master NACKs it by responding with SN=1 and NESN=1.&lt;/p&gt;
&lt;p&gt;In packet 11006 the slave resends it with SN=1 and NESN=0.&lt;/p&gt;
&lt;p&gt;In packet 11007 the master ACKs it by responding with SN=0 and NESN=1.&lt;/p&gt;
&lt;p&gt;In packet 11008 the slave resends it again even though the master just ACKed, and from this point onwards the slave just keeps sending the same notification again in an infinite loop.&lt;/p&gt;
&lt;p&gt;The slave keeps sending the same packet, with SN=1 and NESN toggling between 0 and 1. The master will not ACK the packet by responding with NESN=0. It always responds with NESN=1 indicating that it wants the slave to resend the packet.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/fail2.pcapng"&gt;devzone.nordicsemi.com/.../fail2.pcapng&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;In fail2.pcapng everything works until packet 3106.&lt;/p&gt;
&lt;p&gt;Packet 3106 is the first time the slave sends the notification (payload begins with 0x0e) which will be re-sent in an infinite loop.&lt;/p&gt;
&lt;p&gt;In packet 3107 the master NACKs it.&lt;/p&gt;
&lt;p&gt;The sniffer shows packet 3108 as invalid CRC. It looks like a bit got flipped in the ATT opcode changing it from 0x1b to the invalid value 0x1a.&lt;/p&gt;
&lt;p&gt;In packet 3109 the master NACKs packet 3108 (?)&lt;/p&gt;
&lt;p&gt;In packet 3110 the slave retransmits packet 3106 again and from this point onwards the devices are stuck in an infinite loop.&lt;/p&gt;
&lt;p&gt;From packet 3110 onwards the slave keeps sending the same packet over and over again, always with SN=0 and toggling NESN between 0 and 1. The master keeps responding, each time with its SN matching the previous slave packet&amp;#39;s NESN. But it never acknowledges the packet by changing its NESN to 1, it always sends NESN=0 telling the slave to re-send it.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;In both these cases it looks like the problem exists within the master, not the slave. The slave keeps sending the same packet over and over again, which looks valid according to the sniffer. And in the packets it sends, the master is correctly setting its SN bit according to the last NESN bit from the slave, so it seems like the master must be seeing the packets from the slave. But the master will not acknowledge the packet by setting its NESN bit to the opposite of the SN bit in the packet the slave keeps sending repeatedly.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Maybe the problem is similar to this one? &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/17797/sniffer-detects-ll-infinite-loop"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/17797/sniffer-detects-ll-infinite-loop&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Connection failure - device gets stuck sending a notification in an infinite loop</title><link>https://devzone.nordicsemi.com/thread/154798?ContentTypeID=1</link><pubDate>Mon, 29 Oct 2018 07:37:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:52998248-30f1-4a4c-bb6d-701c5f4fb173</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;In the post i mentioned to replace&amp;nbsp;xTaskResumeFromISR/vTaskSuspend in softdevice_task with&amp;nbsp;vTaskNotifyGiveFromISR/ulTaskNotifyTake. Did you do that? Because I cannot reproduce any disconnects with this.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Connection failure - device gets stuck sending a notification in an infinite loop</title><link>https://devzone.nordicsemi.com/thread/154340?ContentTypeID=1</link><pubDate>Wed, 24 Oct 2018 16:54:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:41ed93a3-0eb4-4951-8241-0c6783731951</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;OK, if&amp;nbsp; you get a disconnected event, then this is definitely different. I still recommend you not to use suspend/resume as there is definitely a corner case there and you should not take chances.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I will give it a try with your project to see if i can reproduce it, if I did, then it is easier for me to debug.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Connection failure - device gets stuck sending a notification in an infinite loop</title><link>https://devzone.nordicsemi.com/thread/154308?ContentTypeID=1</link><pubDate>Wed, 24 Oct 2018 14:17:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:06e22a31-5e3b-4bec-8ee0-2e060264700c</guid><dc:creator>Paolo D</dc:creator><description>&lt;p&gt;It still behaves exactly the same with that fix. When I was experimenting yesterday I had also tried replacing vTaskSuspend(NULL) with vTaskDelay(1) in softdevice_task and that also didn&amp;#39;t make any difference.&lt;/p&gt;
&lt;p&gt;The application isn&amp;#39;t deadlocked, because even after it gets into the bad state where the connection is stuck, if the connection is lost the application does get the BLE_GAP_DISCONNECTED_EVT event from the stack.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Connection failure - device gets stuck sending a notification in an infinite loop</title><link>https://devzone.nordicsemi.com/thread/154297?ContentTypeID=1</link><pubDate>Wed, 24 Oct 2018 13:16:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5247c9af-f063-46c9-b037-a1a9971f8794</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;just found one race condition that could cause deadlock in the application.&lt;/p&gt;
&lt;p&gt;Looking at your description it seems possible that this case is hit by it if we manage to loose one softdevice notifying an event.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Please apply the solution given in &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/39459/observer-under-freertos-events-stop-coming-after-a-few-minutes"&gt;this&lt;/a&gt; post and see if the race condition is removed.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>