<?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>Device getting Hard Reset when it gets disconnected due to going out of range</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/83813/device-getting-hard-reset-when-it-gets-disconnected-due-to-going-out-of-range</link><description>Hello, 
 We are working on a product that contains nRF51822. The product sends continuous data (2 bytes) via NUS service to the mobile app at a frequency of 200ms. 
 When the device is in range, it works fine but when it goes out of range and gets disconnected</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 18 Feb 2022 07:51:45 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/83813/device-getting-hard-reset-when-it-gets-disconnected-due-to-going-out-of-range" /><item><title>RE: Device getting Hard Reset when it gets disconnected due to going out of range</title><link>https://devzone.nordicsemi.com/thread/353764?ContentTypeID=1</link><pubDate>Fri, 18 Feb 2022 07:51:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9e3dcf3c-d7b5-4a71-b826-97a0fe8b8a47</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hello Krish,&lt;/p&gt;
&lt;p&gt;Yes, NRF_ERROR_INVALID_STATE indicates that ble_nus_string_send() was called after the connection was lost.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You can either ignore the error like this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;err_code = ble_nus_string_send(..);
if (err_code != NRF_ERROR_INVALID_STATE)
{
        APP_ERROR_CHECK(err_code);
}

&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Or you can verify the connection state before sending the data.&lt;/p&gt;
&lt;p&gt;Documentation for the various return codes for ble_nust_string_send()::sd_ble_gatts_hvx() can be found here: &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s130.api.v2.0.1/group___b_l_e___g_a_t_t_s___f_u_n_c_t_i_o_n_s.html#ga313fe43c2e93267da668572e885945db"&gt;https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s130.api.v2.0.1/group___b_l_e___g_a_t_t_s___f_u_n_c_t_i_o_n_s.html#ga313fe43c2e93267da668572e885945db&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Vidar&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Device getting Hard Reset when it gets disconnected due to going out of range</title><link>https://devzone.nordicsemi.com/thread/353756?ContentTypeID=1</link><pubDate>Fri, 18 Feb 2022 07:24:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:54fff7e3-db6f-4d2e-94f4-ef102dc99ffb</guid><dc:creator>KrishNa</dc:creator><description>&lt;p&gt;Hello Vidar,&lt;/p&gt;
&lt;p&gt;Thanks for your reply. I tried debugging and found out that the reset was happening because of the following error&amp;nbsp;NRF_ERROR_INVALID_STATE returned by the function&amp;nbsp;&lt;strong&gt;ble_nus_string_send.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Do you have any idea why this issue is happening when going out of range?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Best Regards,&lt;/p&gt;
&lt;p&gt;Krish&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Device getting Hard Reset when it gets disconnected due to going out of range</title><link>https://devzone.nordicsemi.com/thread/348516?ContentTypeID=1</link><pubDate>Wed, 19 Jan 2022 13:20:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c3521b81-31ce-4fd2-9a17-f8f7368c35a5</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi Krish,&lt;/p&gt;
&lt;p&gt;Are you able to get UART/RTT logs from this device, or can you attach a debugger to read the error code? Note that you can read the error code that lead to the reset from the from the app fault handler if you add &amp;#39;DEBUG&amp;#39; to your preprocesor list (see&amp;nbsp;&lt;span&gt;&lt;a title="Error module" href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v12.3.0/lib_error.html?cp=8_5_10_3_10"&gt;Error module&lt;/a&gt;&lt;/span&gt;).&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Vidar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Device getting Hard Reset when it gets disconnected due to going out of range</title><link>https://devzone.nordicsemi.com/thread/348501?ContentTypeID=1</link><pubDate>Wed, 19 Jan 2022 12:51:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:23447dd7-2a7a-408e-ba56-541263a87af0</guid><dc:creator>KrishNa</dc:creator><description>&lt;p&gt;Hi Vidar,&lt;/p&gt;
&lt;p&gt;Thanks for the quick reply. unfortunately, i am not able to find the error code. I tried debugging by commenting the function, that send the data continuously and everything works fine. but when the function is enabled, it always resets on going out of range...&lt;/p&gt;
&lt;p&gt;Any insights from this will be of great help.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best,&lt;/p&gt;
&lt;p&gt;Krish&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Device getting Hard Reset when it gets disconnected due to going out of range</title><link>https://devzone.nordicsemi.com/thread/348458?ContentTypeID=1</link><pubDate>Wed, 19 Jan 2022 10:13:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:78a3f3c3-5641-4aca-9855-fc65a96e00f7</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hello Krish,&lt;/p&gt;
&lt;p&gt;My guess is that the send function is returning an error code which is then passed to the APP_ERROR_CHECK() macro and causing the error handler to reset the device (see &lt;span&gt;&lt;a title="Error module" href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v12.3.0/lib_error.html?cp=8_5_10_3_10"&gt;Error module&lt;/a&gt;&lt;/span&gt;).&amp;nbsp; Are you able to find out what the error code is?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Vidar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>