<?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 timeout at central</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/78720/connection-timeout-at-central</link><description>Hi, 
 I&amp;#39;m using the example &amp;quot;ble_central/ble_app_uart_c&amp;quot; of nRF5_SDK_17.0.2. Connection to peripheral workes fine. 
 If the central re-starts while a connection is established, the peripheral get a &amp;quot;disconnect&amp;quot; event and wait for a new connection. 
 If</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 27 Aug 2021 12:37:52 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/78720/connection-timeout-at-central" /><item><title>RE: Connection timeout at central</title><link>https://devzone.nordicsemi.com/thread/326998?ContentTypeID=1</link><pubDate>Fri, 27 Aug 2021 12:37:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f7b0fe7e-0ee9-450b-ae3f-ff545bdfa64b</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello Andi,&lt;/p&gt;
[quote user="Andi_Frueh"]If I&amp;#39;m right, the connection intervall is defined in sdk_config.h with 7.5...30 ms. So we can decrease the disconnection timeout, as you suggested.[/quote]
&lt;p&gt;Great! Yes, you could also set the two values to be equal, this will make the only possible connection interval whatever you define them too be. So long as this is fine with the peer (the central always decides, but the peripheral may be configured to disconnect if it does not support it), then this will always be the used connection interval. This also gives you a better predictability for how often the messages will be coming in.&lt;br /&gt;It also seems to me that you are here still using the 4000 ms connection supervision timeout, is this intentional or will you be lowering it later on?&lt;/p&gt;
[quote user="Andi_Frueh"]In main.c the uart buffer size is defined by 256 Byte. Increasing or decreasing this size has no effect to the disconnection detection. If the connection is broken, it takes around 4 seconds and the central runs into the error handle, before to detect disconnection.[/quote]
&lt;p&gt;Does this means that it takes around 4 seconds for the UART buffer to overflow?&lt;br /&gt;Because if it is the 4 s connection timeout event will not cause it to enter the error handler, because a disconnection (for whatever reason) is not an application layer error. It is expected that a link may be broken at whatever time.&lt;br /&gt;If you decrease the connection supervision timeout to something much smaller, say 200 ms (with 7.5 ms connection interval this still gives you ~26 connection event tries to get your packets through before disconnecting), this would let you get the disconnected event much sooner.&amp;nbsp;&lt;/p&gt;
[quote user="Andi_Frueh"]&lt;p&gt;What would be an adequate error handling for&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;APP_UART_COMMUNICATION_ERROR while initialization&lt;/li&gt;&lt;/ol&gt;[/quote]
&lt;p&gt;This depends a little, but you could likely just ignore it during initialization unless this means that you are missing out on some critical / unique information. For example, you could ignore it until the UART peripheral is ready, clear the RX buffer, and then begin normal operation.&lt;br /&gt;&lt;br /&gt;Does your heartbeats contain any information, such as a timestamp or status?&lt;br /&gt;If they do not, you could for example just discard the information that is received during startup and wait for the next one.&lt;/p&gt;
[quote user="Andi_Frueh"]NRF_ERROR_RESOURCES while sending cyclic data with a broken connection[/quote]
&lt;p&gt;This could also just be ignored in the case that you do not have any additional information contained in the heartbeat signal.&lt;br /&gt;For example if your hvn tx queue size is 1, there can only be queued a single heartbeat for sending at any one time. If the heartbeats come in every 250 ms, and you have a supervision timeout of &amp;lt; 250 ms, you will keep trying to send the same heartbeat notification up until either it goes through (and you then are ready for the next heartbeat) or until the connection is declared broken once the supervision timeout runs out.&lt;br /&gt;&lt;br /&gt;The important part for the error handling in both of these cases is that you do not use the default error handling, since this is to reset the device, which here would terminate the link and do no good.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Connection timeout at central</title><link>https://devzone.nordicsemi.com/thread/326900?ContentTypeID=1</link><pubDate>Fri, 27 Aug 2021 07:33:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9bf3ed1a-27fa-4978-99c2-4af5a2054c07</guid><dc:creator>Andi_Frueh</dc:creator><description>&lt;p&gt;Good Morning Karl,&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/78720/connection-timeout-at-central/326759#326759"]What connection interval are you using currently?[/quote]
&lt;p&gt;If I&amp;#39;m right, the connection intervall is defined in sdk_config.h with 7.5...30 ms. So we can decrease the disconnection timeout, as you suggested.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#define NRF_BLE_SCAN_MIN_CONNECTION_INTERVAL   7.5
#define NRF_BLE_SCAN_MAX_CONNECTION_INTERVAL    30
#define NRF_BLE_SCAN_SUPERVISION_TIMEOUT      4000&lt;/pre&gt;&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/78720/connection-timeout-at-central/326759#326759"]The size of the queue, are you here talking about the &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fps_nrf52833%2Fuarte.html&amp;amp;anchor=register.RXD.PTR"&gt;UARTE RX buffer&lt;/a&gt;, or the &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.s140.api.v7.2.0%2Fstructble__gatts__conn__cfg__t.html&amp;amp;anchor=ae2a1156d8b06a6ccc70696f2372226cc"&gt;hvn_tx_queue_size&lt;/a&gt;?[/quote]
&lt;p&gt;In main.c the uart buffer size is defined by 256 Byte. Increasing or decreasing this size has no effect to the disconnection detection. If the connection is broken, it takes around 4 seconds and the central runs into the error handle, before to detect disconnection.&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/78720/connection-timeout-at-central/326759#326759"]Is it a possibility for you to use flow control?[/quote]
&lt;p&gt;Using flow control is not desired. Is there a way to disable / enable uart interrupts by application, without changing SDK code? If so, we could disable the uart irq while initialization phase.&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/78720/connection-timeout-at-central/326304#326304"]You could implement specific error handling for specific errors. [/quote]
&lt;p&gt;What would be an adequate error handling for&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;APP_UART_COMMUNICATION_ERROR while initialization&lt;/li&gt;
&lt;li&gt;NRF_ERROR_RESOURCES while sending cyclic data with a broken connection&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Regards,&lt;br /&gt;Andi&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Connection timeout at central</title><link>https://devzone.nordicsemi.com/thread/326759?ContentTypeID=1</link><pubDate>Thu, 26 Aug 2021 11:45:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9ac265e0-8a81-471d-8fc6-cc4901954f14</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello again Andi,&lt;br /&gt;&lt;br /&gt;Thank you for your patience.&lt;/p&gt;
[quote user="Andi_Frueh"]&lt;span&gt;&lt;span&gt;We found the place where the dosconnection time can be set.&lt;/span&gt;&lt;/span&gt; &lt;span&gt;&lt;span&gt;If we reduce this time (from 4000ms to 1000ms), a disconnection will be recognized before the queue overflows.&lt;/span&gt;&lt;/span&gt;[/quote]
&lt;p&gt;Yes, the connection timeout can be adjusted to fit the specific application.&amp;nbsp;&lt;br /&gt;You should also consider the environment that the device will be working in when configuring this, because packet loss or corruption happens more frequently in a 2.4 GHz noisy environment, or in an environment in which the peripheral and central moves behind obstacles and further away from each other. What connection interval are you using currently?&lt;br /&gt;The connection interval is what determines how often there is scheduled communication between the two devices, so for example if you need your central to stop a machine as fast as possible if a heartbeat is not received you can likely set the connection timeout even lower if you are using a low connection interval, such as 7.5 ms.&lt;/p&gt;
[quote user="Andi_Frueh"]&lt;span&gt;&lt;span&gt;Unfortunately we have not found the place where to adjust the size of the queue.&lt;/span&gt;&lt;/span&gt; &lt;span&gt;&lt;span&gt;Can this also be found in the sdk_config?&lt;/span&gt;&lt;/span&gt;[/quote]
&lt;p&gt;The size of the queue, are you here talking about the &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fps_nrf52833%2Fuarte.html&amp;amp;anchor=register.RXD.PTR"&gt;UARTE RX buffer&lt;/a&gt;, or the &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.s140.api.v7.2.0%2Fstructble__gatts__conn__cfg__t.html&amp;amp;anchor=ae2a1156d8b06a6ccc70696f2372226cc"&gt;hvn_tx_queue_size&lt;/a&gt;?&lt;/p&gt;
[quote user="Andi_Frueh"]What better solution here than just changing the initialization order?[/quote]
&lt;p&gt;Is it a possibility for you to use flow control?&lt;br /&gt;This should negate this issue all together.&lt;br /&gt;Alternatively, perhaps your STM could wait until it receives some kind of go-ahead signal before it starts sending the heartbeats. This could for example be a start command sent over UART,&amp;nbsp;or similar.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Connection timeout at central</title><link>https://devzone.nordicsemi.com/thread/326586?ContentTypeID=1</link><pubDate>Wed, 25 Aug 2021 13:45:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d03c06a7-7554-4566-9d34-0f98ece99436</guid><dc:creator>Andi_Frueh</dc:creator><description>&lt;p&gt;Hello again,&lt;/p&gt;
&lt;p&gt;the other issue with the APP_UART_COMMUNICATION_ERROR while initialization seems also to be fixed (by a workaround): We have changed the order of the initialization sequence and have moved uart_init() behind the ble_stack_init().&lt;/p&gt;
&lt;p&gt;While doing so, we have no APP_UART_COMMUNICATION_ERROR&amp;nbsp; anymore. &lt;/p&gt;
&lt;p&gt;While initialization the uart interrupts are already enabled, although the BLE stack has not yet been initialized. This obviously leads to this error.&lt;br /&gt;&lt;br /&gt;What better solution here than just changing the initialization order?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Connection timeout at central</title><link>https://devzone.nordicsemi.com/thread/326581?ContentTypeID=1</link><pubDate>Wed, 25 Aug 2021 13:40:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6ec9a4dd-bc5f-438f-a411-c4dd866bb4f5</guid><dc:creator>Andi_Frueh</dc:creator><description>&lt;p&gt;Hi Karl,&lt;/p&gt;
&lt;p&gt;we tried something to find out the interacting of&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;heartbeat cycle&lt;/li&gt;
&lt;li&gt;disconnection time and&lt;/li&gt;
&lt;li&gt;queue size.&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="DVHrxd"&gt;
&lt;div&gt;
&lt;div class="J0lOec"&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="VIiyi" lang="en"&gt;&lt;span class="JLqJ4b ChMk0b"&gt;&lt;span&gt;We found the place where the dosconnection time can be set.&lt;/span&gt;&lt;/span&gt; &lt;span class="JLqJ4b ChMk0b"&gt;&lt;span&gt;If we reduce this time (from 4000ms to 1000ms), a disconnection will be recognized before the queue overflows.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="J0lOec"&gt;&lt;span class="VIiyi" lang="en"&gt;&lt;span class="JLqJ4b"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="J0lOec"&gt;&lt;span class="VIiyi" lang="en"&gt;&lt;span class="JLqJ4b"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="JLqJ4b ChMk0b"&gt;&lt;span&gt;Unfortunately we have not found the place where to adjust the size of the queue.&lt;/span&gt;&lt;/span&gt; &lt;span class="JLqJ4b ChMk0b"&gt;&lt;span&gt;Can this also be found in the sdk_config?&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Connection timeout at central</title><link>https://devzone.nordicsemi.com/thread/326368?ContentTypeID=1</link><pubDate>Tue, 24 Aug 2021 12:15:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:933a21cf-faa4-4c78-86f0-f9d609b32d6d</guid><dc:creator>Andi_Frueh</dc:creator><description>&lt;p&gt;Hello again,&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/78720/connection-timeout-at-central/326332#326332"]APP_UART_COMMUNICATION_ERROR[/quote]
&lt;p&gt;When this error occurs, I see in call stack, that the initialization of application code isn&amp;#39;t finished. The application code is still handling the function &lt;em&gt;ble_stack_init().&lt;/em&gt; While executing this function, &lt;em&gt;nrf_sdh_enable_request()&lt;/em&gt; will be called, where a critical section ist entered and exited. While exit this critical section, the &lt;em&gt;UARTE0_UART0_IRQHandler()&lt;/em&gt; is called immideatelly, which ends in the &lt;em&gt;APP_UART_COMMUNICATION_ERROR&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1629806044013v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="VIiyi" lang="en"&gt;&lt;span class="JLqJ4b ChMk0b"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="JLqJ4b ChMk0b"&gt;&lt;span&gt;Even if the dedicated STM32 sends its 250ms heartbeat via UART while the Nordic chip is starting its firmware (start debug session): how can it be that an overflow occurs immediately at this point every time? How can I prevent this overflow? &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="VIiyi" lang="en"&gt;&lt;span class="JLqJ4b ChMk0b"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/78720/connection-timeout-at-central/326332#326332"]It seems to me that you are queueing the writes faster than they are being written, leading to an overflow of the queued writes buffer.[/quote]
&lt;div class="DVHrxd"&gt;
&lt;div id="ow42"&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="dePhmb"&gt;
&lt;div class="eyKpYb"&gt;
&lt;div class="J0lOec"&gt;&lt;span class="VIiyi" lang="en"&gt;&lt;span class="JLqJ4b ChMk0b"&gt;&lt;span&gt;This&lt;/span&gt;&lt;/span&gt;&lt;span class="JLqJ4b ChMk0b"&gt;&lt;span&gt;is quite possible. The Central needs approx. 4 seconds until it detects that the connection to the Peripheral has been broken. During this time the heartbeat continues to be sent every 250ms.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="J0lOec"&gt;&lt;span class="VIiyi" lang="en"&gt;&lt;span class="JLqJ4b ChMk0b"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="J0lOec"&gt;&lt;span class="VIiyi" lang="en"&gt;&lt;span class="JLqJ4b ChMk0b"&gt;&lt;span&gt;Is it possible that the interplay between the &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li class="J0lOec"&gt;&lt;span class="VIiyi" lang="en"&gt;&lt;span class="JLqJ4b ChMk0b"&gt;&lt;span&gt;heartbeat cycle (250ms), &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="J0lOec"&gt;&lt;span class="VIiyi" lang="en"&gt;&lt;span class="JLqJ4b ChMk0b"&gt;&lt;span&gt;the duration for detecting the disconnection (approx. 4 Sec.) and &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="J0lOec"&gt;&lt;span class="VIiyi" lang="en"&gt;&lt;span class="JLqJ4b ChMk0b"&gt;&lt;span&gt;the size of the message queue (?)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="VIiyi" lang="en"&gt;&lt;span class="JLqJ4b ChMk0b"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span class="VIiyi" lang="en"&gt;&lt;span class="JLqJ4b ChMk0b"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="VIiyi" lang="en"&gt;&lt;span class="JLqJ4b ChMk0b"&gt;&lt;span&gt;has been selected as &amp;quot;unfavorable&amp;quot;? Can I adjust disconnection time?&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Connection timeout at central</title><link>https://devzone.nordicsemi.com/thread/326332?ContentTypeID=1</link><pubDate>Tue, 24 Aug 2021 10:47:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:00997139-e828-4bca-837a-654ad95d40af</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello again, Andi&lt;/p&gt;
[quote user="Andi_Frueh"]In Debug-Build I get following error message:[/quote]
&lt;p&gt;Thank you for clarifying.&lt;/p&gt;
&lt;p&gt;There is a issue with the logging of the UART communication error in the default error handler. It assumes that the error code is a standard nRF error code, but in fact the error code you get in case of a&amp;nbsp;&lt;code&gt;APP_UART_COMMUNICATION_ERROR&lt;/code&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;is the content of the&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/uarte.html?cp=2_1_0_34_9_4#register.ERRORSRC"&gt;ERRORSRC&lt;/a&gt;&amp;nbsp;register. So value 1 is not&amp;nbsp;&lt;code&gt;NRF_ERROR_SVC_HANDLER_MISSING&lt;/code&gt;, but rather an&amp;nbsp;overrun error (1, i.e. the least significant bit is the&amp;nbsp;OVERRUN field in ERRORSRC: &amp;quot;A start bit is received while the previous data still lies in RXD&amp;quot;).&lt;/p&gt;
&lt;p&gt;It would seem that for some reason you are not able to process the data fast enough in some cases. Perhaps you get a interrupt at a &amp;quot;bad time&amp;quot;, or something else. The best way to handle this is probably to use flow control if possible.&lt;/p&gt;
[quote user="Andi_Frueh"]&lt;p&gt;in file &lt;em&gt;nrf_ble_gq.c&lt;/em&gt; the function &lt;em&gt;sd_ble_gattc_write&lt;/em&gt; returnesthe NRF_ERROR_RESOURCES.&lt;/p&gt;
&lt;p&gt;Could you handle with that informations?&lt;/p&gt;[/quote]
&lt;p&gt;You can check returned error messages against the function API to read why this particular error message was returned.&lt;br /&gt;In the case of &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.s132.api.v7.2.0%2Fgroup___b_l_e___g_a_t_t_c___f_u_n_c_t_i_o_n_s.html&amp;amp;anchor=ga90298b8dcd8bbe7bbe69d362d1133378"&gt;sd_ble_gattc_write&lt;/a&gt;, the description for the NRF_ERROR_RESOURCES reads:&lt;/p&gt;
&lt;table&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;a title="Not enough resources for operation." href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.api.v7.2.0/group__nrf__error.html#gac94383171545e604e8347a044e8be13f"&gt;NRF_ERROR_RESOURCES&lt;/a&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;Too many writes without responses queued. Wait for a&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.api.v7.2.0/group___b_l_e___g_a_t_t_c___e_n_u_m_e_r_a_t_i_o_n_s.html#ggafd9b8b42eeb832d688e33f4561f97efca69bce270587ac00d7a1c3bd976cfd902"&gt;BLE_GATTC_EVT_WRITE_CMD_TX_COMPLETE&lt;/a&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;event and retry.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;It seems to me that you are queueing the writes faster than they are being written, leading to an overflow of the queued writes buffer.&lt;br /&gt;Please read the note section of the function&amp;#39;s API to see how you may use the CMD_TX_COMPLETE event to queue more write without responses.&lt;br /&gt;How fast are you queueing writes, compared to how fast they are being sent? What connection interval are you using?&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Connection timeout at central</title><link>https://devzone.nordicsemi.com/thread/326317?ContentTypeID=1</link><pubDate>Tue, 24 Aug 2021 10:02:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:399e3202-f971-449e-ba3a-b0ead1d541ec</guid><dc:creator>Andi_Frueh</dc:creator><description>&lt;p&gt;Hi Karl,&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/78720/connection-timeout-at-central/326304#326304"]Exactly which APP_ERROR_CHECK is at line 305?[/quote]
&lt;p&gt;&lt;img height="328" src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1629798018344v2.png" width="262" alt=" " /&gt;&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/78720/connection-timeout-at-central/326304#326304"]Could it here be that you have unitialized the UART peripheral while not in a connection without having disabled related UART functionality in the application, or similar?[/quote]
&lt;p&gt;Since call stack shows, that the program counter has started in function &lt;em&gt;ble_stack_init&lt;/em&gt;, uart would be already initialized:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;int main(void)
{
    // Initialize.
    log_init();
    timer_init();
    uart_init();
    buttons_leds_init();
    db_discovery_init();
    power_management_init();
    ble_stack_init();
    gatt_init();
    nus_c_init();
    scan_init();

    // Start execution.
    printf(&amp;quot;BLE UART central example started.\r\n&amp;quot;);
    NRF_LOG_INFO(&amp;quot;BLE UART central example started.&amp;quot;);
    scan_start();

    // Enter main loop.
    for (;;)
    {
        idle_state_handle();
    }
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/78720/connection-timeout-at-central/326304#326304"]Which function returned the NRF_ERROR_RESOURCES passed to the APP_ERROR_CHECK on line 119?[/quote]
&lt;p&gt;&lt;img height="306" src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1629799149451v4.png" width="485" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;in file &lt;em&gt;nrf_ble_gq.c&lt;/em&gt; the function &lt;em&gt;sd_ble_gattc_write&lt;/em&gt; returnesthe NRF_ERROR_RESOURCES.&lt;/p&gt;
&lt;p&gt;Could you handle with that informations?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Andi&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Connection timeout at central</title><link>https://devzone.nordicsemi.com/thread/326304?ContentTypeID=1</link><pubDate>Tue, 24 Aug 2021 08:56:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d2550033-58fa-494d-afb5-ad67fad0fd0f</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello Andi,&lt;/p&gt;
[quote user="Andi_Frueh"]sorry for the late response.[/quote]
&lt;p&gt;No problem at all - we continue whenever you have the time, no worries.&lt;/p&gt;
[quote user="Andi_Frueh"]In line 305 of main.c is the following function:[/quote]
&lt;p&gt;Exactly which APP_ERROR_CHECK is at line 305?&lt;br /&gt;Could it here be that you have unitialized the UART peripheral while not in a connection without having disabled related UART functionality in the application, or similar?&lt;/p&gt;
[quote user="Andi_Frueh"]If I reset the peripheral while there is a BLE connection and the cyclic heartbeat is being sent, I get the following error:[/quote]
&lt;p&gt;Which function returned the NRF_ERROR_RESOURCES passed to the APP_ERROR_CHECK on line 119?&lt;/p&gt;
[quote user="Andi_Frueh"]Since we use the default APP_ERROR_HANDLER, application stopps and has to be reset! How should we handle this error?[/quote]
&lt;p&gt;You could implement specific error handling for specific errors. The default error handling is to reset the device - no matter which error has occurred - this is not always necessary, but depends on your application. For example when the NRF_ERROR_RESOURCES is returned by the sd_ble_gatts_hvx call, that only means that the queue for notifications to send is already full. This is therefore then not a good reason to reset the application.&lt;br /&gt;In this case, a more fitting error handling would be to note which data was not successfully queued, and instead try to queue it again later, after having received a hvn tx event (notification successfully sent event). This way, you make sure not to restart the device unnecessarily, and not to loose any data that is not immediately queued, for example.&lt;/p&gt;
[quote user="Andi_Frueh"]&lt;p&gt;&lt;span lang="en"&gt;&lt;span&gt;&lt;span&gt;The project we are working on is a safety application.&lt;/span&gt;&lt;/span&gt; &lt;span&gt;&lt;span&gt;The only message sent via BLE is a heartbeat (every 250 ms).&lt;/span&gt;&lt;/span&gt; &lt;span&gt;&lt;span&gt;If this heartbeat does not occur, the machine must be switched off immediately.&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span lang="en"&gt;&lt;span&gt;&lt;span&gt;If there is a corresponding error, the Central no longer sends a heartbeat and thus wants to force shutdown of the machine.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span lang="en"&gt;&lt;span&gt;&lt;span&gt;If we handle messages in a queue, heartbeats could accumulate in the event of a disturbed transmission and lead to a delayed shutdown.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; &lt;span lang="en"&gt;&lt;span&gt;&lt;span&gt;That would be unacceptable!&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;[/quote]
&lt;p&gt;Thank you for elaborating on the requirements and constraints of the project - this makes it much easier for me to understand your issues and help you resolve them.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Connection timeout at central</title><link>https://devzone.nordicsemi.com/thread/326145?ContentTypeID=1</link><pubDate>Mon, 23 Aug 2021 10:28:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a0acdcd4-ec81-47e4-8e09-f9e67d7b1e99</guid><dc:creator>Andi_Frueh</dc:creator><description>&lt;p&gt;Hello Karl,&lt;/p&gt;
&lt;p&gt;sorry for the late response.&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/78720/connection-timeout-at-central/325883#325883"]The initialization and enabling of the BLE stack does not take very long, and the nRF52833 can still receive over UART regardless of the BLE stack status. Which error is generated, and from which function, when the STM32 sends data too soon?[/quote]
&lt;p&gt;In Debug-Build I get following error message:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1629712798463v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1629712821082v2.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;In line 305 of main.c is the following function:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void uart_event_handle(app_uart_evt_t * p_event)
{
    static uint8_t data_array[BLE_NUS_MAX_DATA_LEN];
    static uint16_t index = 0;
    uint32_t ret_val;

    switch (p_event-&amp;gt;evt_type)
    {
        /**@snippet [Handling data from UART] */
        case APP_UART_DATA_READY:
            ...
            break;

        /**@snippet [Handling data from UART] */
        case APP_UART_COMMUNICATION_ERROR:
            index = 0;
            NRF_LOG_ERROR(&amp;quot;Communication error occurred while handling UART.&amp;quot;);

/* line 305 */
            APP_ERROR_HANDLER(p_event-&amp;gt;data.error_communication);

            break;

        case APP_UART_FIFO_ERROR:
            index = 0;
            NRF_LOG_ERROR(&amp;quot;Error occurred in FIFO module used by UART.&amp;quot;);
            APP_ERROR_HANDLER(p_event-&amp;gt;data.error_code);
            break;

        default:
            break;
    }
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Whe I stopp the debugger before entering the APP_ERROR_HANDLER, the call stack changes to&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1629713225822v4.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="VIiyi" lang="en"&gt;&lt;span class="JLqJ4b ChMk0b"&gt;&lt;span&gt;Since the error occurs while function &lt;em&gt;&amp;quot;ble_stack_init()&amp;quot;&lt;/em&gt; is running, I suspected that the problem was in the area of initialization.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="VIiyi" lang="en"&gt;&lt;span class="JLqJ4b ChMk0b"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="VIiyi" lang="en"&gt;&lt;span class="JLqJ4b ChMk0b"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/78720/connection-timeout-at-central/325883#325883"]I am sorry, but I do not understand what you mean to say here fully. Are you saying that you do not see the DISCONNECTED event when a APP_ERROR_HANDLER execution has just finished? [/quote]
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="VIiyi" lang="en"&gt;&lt;span class="JLqJ4b ChMk0b"&gt;&lt;span&gt;If I reset the peripheral while there is a BLE connection and the cyclic heartbeat is being sent, I get the following error: &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="VIiyi" lang="en"&gt;&lt;span class="JLqJ4b ChMk0b"&gt;&lt;span&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1629714347410v5.png" alt=" " /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="VIiyi" lang="en"&gt;&lt;span class="JLqJ4b ChMk0b"&gt;&lt;span&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1629714392867v6.png" alt=" " /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="VIiyi" lang="en"&gt;&lt;span class="JLqJ4b ChMk0b"&gt;&lt;span&gt;Since we use the default APP_ERROR_HANDLER, application stopps and has to be reset! How should we handle this error?&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="VIiyi" lang="en"&gt;&lt;span class="JLqJ4b ChMk0b"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/78720/connection-timeout-at-central/325883#325883"]I do not understand what you mean by this. Why can you simply not increase the queue, if this is what is causing your NRF_ERROR_RESOURCES?[/quote]
&lt;p&gt;&lt;span class="VIiyi" lang="en"&gt;&lt;span class="JLqJ4b ChMk0b"&gt;&lt;span&gt;The project we are working on is a safety application.&lt;/span&gt;&lt;/span&gt; &lt;span class="JLqJ4b ChMk0b"&gt;&lt;span&gt;The only message sent via BLE is a heartbeat (every 250 ms).&lt;/span&gt;&lt;/span&gt; &lt;span class="JLqJ4b ChMk0b"&gt;&lt;span&gt;If this heartbeat does not occur, the machine must be switched off immediately.&lt;/span&gt;&lt;/span&gt;&lt;span class="JLqJ4b"&gt;&lt;span&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="VIiyi" lang="en"&gt;&lt;span class="JLqJ4b ChMk0b"&gt;&lt;span&gt;If there is a corresponding error, the Central no longer sends a heartbeat and thus wants to force shutdown of the machine.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="VIiyi" lang="en"&gt;&lt;span class="JLqJ4b ChMk0b"&gt;&lt;span&gt;If we handle messages in a queue, heartbeats could accumulate in the event of a disturbed transmission and lead to a delayed shutdown.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; &lt;span class="VIiyi" lang="en"&gt;&lt;span class="JLqJ4b ChMk0b"&gt;&lt;span&gt;That would be unacceptable!&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="VIiyi" lang="en"&gt;&lt;span class="JLqJ4b ChMk0b"&gt;&lt;span&gt;Kind regards,&lt;br /&gt;Andi&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Connection timeout at central</title><link>https://devzone.nordicsemi.com/thread/325883?ContentTypeID=1</link><pubDate>Fri, 20 Aug 2021 09:15:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:028e18ed-3d39-4025-8108-e528d2278eb5</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello again Andi,&lt;/p&gt;
[quote user="Andi_Frueh"]the BLE stack is not yet fully set up while the STM32 is already trying to send data via UART. This leads to an APP_ERROR_HANDLER.[/quote]
&lt;p&gt;The initialization and enabling of the BLE stack does not take very long, and the nRF52833 can still receive over UART regardless of the BLE stack status. Which error is generated, and from which function, when the STM32 sends data too soon?&lt;/p&gt;
[quote user="Andi_Frueh"]The disconnect event is generally recognized. However, an APP_ERROR_HANDLER was previously executed. We have to intercept this troubleshooting in a different way than has been done up to now. When we do this, it works to disconnect and reconnect the two devices.[/quote]
&lt;p&gt;I am sorry, but I do not understand what you mean to say here fully. Are you saying that you do not see the DISCONNECTED event when a APP_ERROR_HANDLER execution has just finished? Have you implemented specific error handling in the APP_ERROR_HANDLER, or are you using the default which is to reset the device?&lt;br /&gt;Please elaborate on what you mean with this paragraph so I may better advice you on how to resolve the issue.&amp;nbsp;&lt;/p&gt;
[quote user="Andi_Frueh"]It may be that our queue is too small, but we currently cannot simply increase it.[/quote]
&lt;p&gt;I do not understand what you mean by this. Why can you simply not increase the queue, if this is what is causing your NRF_ERROR_RESOURCES?&lt;br /&gt;The only alternative to increasing the queue to avoid the NRF_ERROR_RESOURCES would be to queue notifications less frequently. For example, only after receiving a&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s140.api.v7.2.0/group___b_l_e___g_a_t_t_s___e_n_u_m_e_r_a_t_i_o_n_s.html#ggae537647902af1b05c1e32f12d6b401c7afab96bfa9918017082235f7664919f9d"&gt;BLE_GATTS_EVT_HVN_TX_COMPLETE&lt;/a&gt;&amp;nbsp;event.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Connection timeout at central</title><link>https://devzone.nordicsemi.com/thread/325675?ContentTypeID=1</link><pubDate>Thu, 19 Aug 2021 09:34:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:da345ccb-15a6-4d69-8433-71eb639904f8</guid><dc:creator>Andi_Frueh</dc:creator><description>&lt;p&gt;Hi Karl,&lt;/p&gt;
&lt;p&gt;we had different problems.&lt;br /&gt;&lt;br /&gt;One of them was that our controller sends data cyclically - regardless of whether there is a BLE connection or not. When we debug the BLE module, the situation arises that the BLE stack is not yet fully set up while the STM32 is already trying to send data via UART. This leads to an APP_ERROR_HANDLER.&lt;br /&gt;&lt;br /&gt;The disconnect event is generally recognized. However, an APP_ERROR_HANDLER was previously executed. We have to intercept this troubleshooting in a different way than has been done up to now. When we do this, it works to disconnect and reconnect the two devices.&lt;/p&gt;
&lt;p&gt;&lt;span class="VIiyi" lang="en"&gt;&lt;span class="JLqJ4b ChMk0b"&gt;&lt;span&gt;It may be that our queue is too small, but we currently cannot simply increase it.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Many thanks for your support!&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Andi&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Connection timeout at central</title><link>https://devzone.nordicsemi.com/thread/325562?ContentTypeID=1</link><pubDate>Wed, 18 Aug 2021 15:28:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8395eb3d-531a-49b7-ba0e-079cc912629e</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
[quote user="Andi_Frueh"]So, the reason for the error seem to be clear: the BLE stack knows, that the connection has broken. Unfortunatelly there is no BLE_GAP_EVT_DISCONNECTED event to invalidate the connection handle![/quote]
&lt;p&gt;No, I do not think that this is the right conclusion. &lt;br /&gt;In the case you describe - trying to call ble_nus_data_send when not in a connection - you would be getting an NRF_ERROR_INVALID_STATE error. In your error log you are getting NRF_ERROR_RESOURCES, which I think stems from &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.s140.api.v7.2.0%2Fgroup___b_l_e___g_a_t_t_s___f_u_n_c_t_i_o_n_s.html&amp;amp;anchor=ga313fe43c2e93267da668572e885945db"&gt;too many notifications being queued for sending&lt;/a&gt;. The explanation of the error code from the function&amp;#39;s API reads:&lt;/p&gt;
&lt;table&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;a title="Not enough resources for operation." href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s140.api.v7.2.0/group__nrf__error.html#gac94383171545e604e8347a044e8be13f"&gt;NRF_ERROR_RESOURCES&lt;/a&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;Too many notifications queued. Wait for a&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s140.api.v7.2.0/group___b_l_e___g_a_t_t_s___e_n_u_m_e_r_a_t_i_o_n_s.html#ggae537647902af1b05c1e32f12d6b401c7afab96bfa9918017082235f7664919f9d"&gt;BLE_GATTS_EVT_HVN_TX_COMPLETE&lt;/a&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;event and retry.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;To fix this you could for example increase your &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.s140.api.v7.2.0%2Fstructble__gatts__conn__cfg__t.html&amp;amp;anchor=ae2a1156d8b06a6ccc70696f2372226cc"&gt;hvn queue size&lt;/a&gt;&amp;nbsp;and connection event length to send multiple notifications each connection event.&lt;br /&gt;How many notifications are you attempting to queue per connection event?&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Connection timeout at central</title><link>https://devzone.nordicsemi.com/thread/325536?ContentTypeID=1</link><pubDate>Wed, 18 Aug 2021 14:04:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b4a6e601-aaea-4a5e-abef-3b2215966fb8</guid><dc:creator>Andi_Frueh</dc:creator><description>&lt;p&gt;The function which passed this error is&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void nus_error_handler(uint32_t nrf_error)
{
    APP_ERROR_HANDLER(nrf_error);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;In the call stack I see, that function &amp;quot;ble_nus_c_string_send&amp;quot; was called prior, which is called by the funtion &amp;quot;uart_event_handle(app_uart_evt_t * p_event)&amp;quot;. So, the reason for the error seem to be clear: the BLE stack knows, that the connection has broken. Unfortunatelly there is no BLE_GAP_EVT_DISCONNECTED event to invalidate the connection handle!&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void uart_event_handle(app_uart_evt_t * p_event)
{
    static uint8_t data_array[BLE_NUS_MAX_DATA_LEN];
    static uint16_t index = 0;
    uint32_t ret_val;

    
    if (m_ble_nus_c.conn_handle != BLE_CONN_HANDLE_INVALID)
    {
        switch (p_event-&amp;gt;evt_type)
        {
            /**@snippet [Handling data from UART] */
            case APP_UART_DATA_READY:
                UNUSED_VARIABLE(app_uart_get(&amp;amp;data_array[index]));
                index++;
    
                if ((data_array[index - 1] == &amp;#39;\n&amp;#39;) ||
                    (data_array[index - 1] == &amp;#39;\r&amp;#39;) ||
                    (index &amp;gt;= (m_ble_nus_max_data_len)))
                {
                    NRF_LOG_DEBUG(&amp;quot;Ready to send data over BLE NUS&amp;quot;);
                    NRF_LOG_HEXDUMP_DEBUG(data_array, index);
    
                    data_array[index - 1] = &amp;#39;\r&amp;#39;;
    
                    do
                    {
/*******************/
                        ret_val = ble_nus_c_string_send(&amp;amp;m_ble_nus_c, data_array, index);
/*******************/
                        if ( (ret_val != NRF_ERROR_INVALID_STATE) &amp;amp;&amp;amp; (ret_val != NRF_ERROR_RESOURCES) )
                        {
                            APP_ERROR_CHECK(ret_val);
                        }
                    } while (ret_val == NRF_ERROR_RESOURCES);
    
                    index = 0;
                }
                break;
    
            /**@snippet [Handling data from UART] */
            case APP_UART_COMMUNICATION_ERROR:
                NRF_LOG_ERROR(&amp;quot;Communication error occurred while handling UART.&amp;quot;);
                APP_ERROR_HANDLER(p_event-&amp;gt;data.error_communication);
                break;
    
            case APP_UART_FIFO_ERROR:
                NRF_LOG_ERROR(&amp;quot;Error occurred in FIFO module used by UART.&amp;quot;);
                APP_ERROR_HANDLER(p_event-&amp;gt;data.error_code);
                break;
    
            default:
                break;
        }
    }
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Connection timeout at central</title><link>https://devzone.nordicsemi.com/thread/325516?ContentTypeID=1</link><pubDate>Wed, 18 Aug 2021 12:50:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dea54a1c-9375-4afd-a91a-7b328ba58531</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
[quote user="Andi_Frueh"]thank you for your soon response.[/quote]
&lt;p&gt;No problem at all, I am happy to help!&lt;/p&gt;
[quote user="Andi_Frueh"]Here is some background information:[/quote]
&lt;p&gt;Thank you for the elaboration, this is helpful for me to know.&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;lt;error&amp;gt; app: ERROR 19 [NRF_ERROR_RESOURCES] at C:\Projekte\MyCompany\0288_TT_BLE_Modul\nRF5_SDK_17.0.2_d674dde\examples\ble_central\ble_app_uart_c\main.c:123
PC at: 0x0002F57D
&amp;lt;error&amp;gt; app: End of error report&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Which function returned the error code passed to the APP_ERROR_CHECK on line 123 of main.c?&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Connection timeout at central</title><link>https://devzone.nordicsemi.com/thread/325507?ContentTypeID=1</link><pubDate>Wed, 18 Aug 2021 12:36:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9fa31434-8e30-431e-9e3d-6f23995bb05c</guid><dc:creator>Andi_Frueh</dc:creator><description>&lt;p&gt;Hello Karl,&lt;/p&gt;
&lt;p&gt;thank you for your soon response. First the error message:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;lt;info&amp;gt; app_timer: RTC: initialized.
&amp;lt;info&amp;gt; app: BLE UART central example started.
&amp;lt;info&amp;gt; app: Connecting to target 340D3750ACE0
&amp;lt;info&amp;gt; app: ATT MTU exchange completed.
&amp;lt;info&amp;gt; app: Ble NUS max data length set to 0xF4(244)
&amp;lt;info&amp;gt; app: Discovery complete.
&amp;lt;info&amp;gt; app: Connected to device with Nordic UART Service.
&amp;lt;error&amp;gt; nrf_ble_gq: SD GATT procedure (1) failed on connection handle 0 with error: 0x00000013.
&amp;lt;error&amp;gt; app: ERROR 19 [NRF_ERROR_RESOURCES] at C:\Projekte\MyCompany\0288_TT_BLE_Modul\nRF5_SDK_17.0.2_d674dde\examples\ble_central\ble_app_uart_c\main.c:123
PC at: 0x0002F57D
&amp;lt;error&amp;gt; app: End of error report&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I have made some &amp;quot;small&amp;quot; changes in main.c:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;set ECHOBACK_BLE_UART_DATA to 0&lt;/li&gt;
&lt;li&gt;in void uart_event_handle(app_uart_evt_t * p_event): &lt;br /&gt;Check connection state befor sending data&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;    if (m_ble_nus_c.conn_handle != BLE_CONN_HANDLE_INVALID)
    {
        switch (p_event-&amp;gt;evt_type)
        {
            case APP_UART_DATA_READY:
                ...
        }
    }&lt;/pre&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span class="VIiyi" lang="en"&gt;&lt;strong&gt;&lt;span class="JLqJ4b ChMk0b"&gt;Here is some background information:&lt;/span&gt;&lt;/strong&gt;&lt;span class="JLqJ4b"&gt;&lt;span&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="VIiyi" lang="en"&gt;&lt;span class="JLqJ4b ChMk0b"&gt;&lt;span&gt;The BLE module is connected to our &amp;micro;C (STM32) via UART.&lt;/span&gt;&lt;/span&gt; T&lt;span class="JLqJ4b ChMk0b"&gt;&lt;span&gt;his STM32 sends a heartbeat every 250ms via uart -&amp;gt; BLE to the peripheral - indipending of a BLE connection state.&lt;/span&gt;&lt;/span&gt; &lt;span class="JLqJ4b ChMk0b"&gt;&lt;span&gt;If there is no connection established, the central runs into a fatal error.&lt;/span&gt;&lt;/span&gt; &lt;span class="JLqJ4b ChMk0b"&gt;&lt;span&gt;Therefore we have checked the connection handle before sending the data via BLE.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Connection timeout at central</title><link>https://devzone.nordicsemi.com/thread/325479?ContentTypeID=1</link><pubDate>Wed, 18 Aug 2021 12:01:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:77b627ce-17d0-424b-8c19-a48051c5db47</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
[quote user=""]I&amp;#39;m using the example &amp;quot;ble_central/ble_app_uart_c&amp;quot; of nRF5_SDK_17.0.2.[/quote]
&lt;p&gt;Have you made any changes to the central example? If so, what changes have you made?&lt;/p&gt;
[quote user=""]the central get no &amp;quot;disconnect&amp;quot; event and runs into fatal error.[/quote]
&lt;p&gt;That sounds strange - the central should resume scanning for a peripheral device when a link is broken.&lt;br /&gt;Could you make sure to have DEBUG defined in your preprocessor defines, like shown in the included image?&lt;br /&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/8015.enabling_5F00_debug_5F00_SES.PNG" /&gt;&lt;br /&gt;This will make a detailed error message be outputted to your logger whenever a non-NRF_SUCCESS error code is passed to an APP_ERROR_CHECK. Please do this, and let me know what this error message says when the device resets.&lt;br /&gt;&lt;br /&gt;Looking forward to resolving this issue together!&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>