<?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>Reset during connection setup</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/33445/reset-during-connection-setup</link><description>Hello, 
 i asked this quastion once in this thread: https://devzone.nordicsemi.com/f/nordic-q-a/32444/reset-on_ble_connect-when-button-event I accepted the given answer but later i found out that the solution does not work. I rejected the answer, but</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 23 Apr 2018 08:37:39 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/33445/reset-during-connection-setup" /><item><title>RE: Reset during connection setup</title><link>https://devzone.nordicsemi.com/thread/129286?ContentTypeID=1</link><pubDate>Mon, 23 Apr 2018 08:37:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e7847867-ac39-4a76-8034-445ea18e6c38</guid><dc:creator>DanKA</dc:creator><description>&lt;p&gt;Thank you very much for your answer. The searching for 0x3401 helped me.&lt;/p&gt;
&lt;p&gt;I noticed that BLE_GATTS_EVT_SYS_ATTR_MISSING was already in on_ble_evt() and i never entered it: &amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;        case BLE_GATTS_EVT_SYS_ATTR_MISSING:
            // No system attributes have been stored.
            NRF_LOG_INFO(&amp;quot;System Attribute missing \r\n&amp;quot;);
            err_code = sd_ble_gatts_sys_attr_set(m_conn_handle, NULL, 0, 0);
            APP_ERROR_CHECK(err_code);
            break; // BLE_GATTS_EVT_SYS_ATTR_MISSING&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I added these lines at BLE_GAP_EVT_CONNECTED:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;        case BLE_GAP_EVT_CONNECTED:
            NRF_LOG_INFO(&amp;quot;Connected\r\n&amp;quot;);
            bsp_board_led_on(CONNECTED_LED_PIN);
            bsp_board_led_off(ADVERTISING_LED_PIN);
            m_conn_handle = p_ble_evt-&amp;gt;evt.gap_evt.conn_handle;
            
            // set system attributes
            NRF_LOG_INFO(&amp;quot;Set system attributes\r\n&amp;quot;);
            err_code = sd_ble_gatts_sys_attr_set(m_conn_handle, NULL, 0, 0);
            APP_ERROR_CHECK(err_code);
            
            err_code = app_button_enable();
            APP_ERROR_CHECK(err_code);
            break; // BLE_GAP_EVT_CONNECTED&lt;/pre&gt;Now, the scenario above results NRF_ERROR_INVALID_STATE because the CCCD was not written. But i can check for that with adding BLE_GATTS_EVT_WRITE to on_ble_evt():&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;        case BLE_GATTS_EVT_WRITE:
            on_write(p_ble_evt);
            NRF_LOG_INFO(&amp;quot;A Write Event \r\n&amp;quot;);
            break; // BLE_GATTS_EVT_WRITE&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;With on_write(..) to indicate that everything is set up and to enable the app_button:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static void on_write(ble_evt_t * p_ble_evt)
{
    ble_gatts_evt_write_t * p_evt_write = &amp;amp;p_ble_evt-&amp;gt;evt.gatts_evt.params.write; // Pr&amp;#252;fen, ob CCCD beschrieben ist
    if ((p_evt_write-&amp;gt;handle == m_lbs.button_char_handles.cccd_handle)){
        bsp_board_led_on(CONNECTED_LED_PIN);
        bsp_board_led_off(ADVERTISING_LED_PIN);
        err_code = app_button_enable();
        APP_ERROR_CHECK(err_code);
    }
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Reset during connection setup</title><link>https://devzone.nordicsemi.com/thread/129191?ContentTypeID=1</link><pubDate>Fri, 20 Apr 2018 18:44:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b5d4b9a7-e4c7-49ea-9f11-27ae5f8e111a</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Hi Dan,&lt;/p&gt;
&lt;p&gt;This error is well documented and there is a thread here in devzone that will explain more about it.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You can read more about it &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/3338/error-code-0x3401/12163#12163"&gt;here&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;You need to add the below code in the ble event handler to fix this problem&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;case BLE_GATTS_EVT_SYS_ATTR_MISSING:
        err_code = sd_ble_gatts_sys_attr_set(m_conn_handle, NULL, 0);
        APP_ERROR_CHECK(err_code);&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Reset during connection setup</title><link>https://devzone.nordicsemi.com/thread/128767?ContentTypeID=1</link><pubDate>Wed, 18 Apr 2018 10:25:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e5a0d8c3-2de9-4090-a3d2-054e28121440</guid><dc:creator>DanKA</dc:creator><description>&lt;p&gt;Hi Aryan,&lt;/p&gt;
&lt;p&gt;i am afraid i misunderstand you and/or need a&amp;nbsp;little help. I started the project in debug mode (defined DEBUG and no optimazations) and&amp;nbsp;set the breakpoint &amp;nbsp;app_error_handler() / app_error_save_and_stop in the app_error.c file.&lt;/p&gt;
&lt;p&gt;I get:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;p_file_name = &amp;quot;main.c&amp;quot;&lt;/li&gt;
&lt;li&gt;line_num = 501 --&amp;gt; that&amp;#39;s the line where APP_ERROR_CHECK is called within the button_event_handler()&lt;/li&gt;
&lt;li&gt;err_code = 13313 (0x3401):&lt;br /&gt;NRF_ERROR_STK_BASE&amp;nbsp;(0x3000) + 0x400 --&amp;gt;&lt;br /&gt;NRF_GATTS_ERR_BASE (0x3400) + 1 --&amp;gt;&lt;br /&gt;BLE_GATTS_SYS_ATTR_MISSING (0x3401)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So these are no new Information compared to NRF_LOG. Here is a screenshot:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/0564.error_5F00_info.PNG" /&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Could you please guide me where to place the breakpoints correctly?&lt;/li&gt;
&lt;li&gt;How do i check for BLE_GATTS_SYS_ATTR_MISSING&amp;nbsp;equivalent to as we did&amp;nbsp;for the invalid handle with&amp;nbsp;if(m_conn_handle != BLE_CONN_HANDLE_INVALID)*?&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;*even if i do not check for invalid handle, i get err_code = 13313.&lt;/p&gt;
&lt;p&gt;Thank your very much in advance&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Reset during connection setup</title><link>https://devzone.nordicsemi.com/thread/128632?ContentTypeID=1</link><pubDate>Tue, 17 Apr 2018 12:28:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a1d485bc-7edc-4ed8-9519-8d60a27b2546</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Hi Dan,&lt;/p&gt;
&lt;p&gt;It is quite easy to debug set a breakpoint at the app_error_handler and see which line caused this error.&lt;/p&gt;
&lt;p&gt;The answer I gave you in my last post is a fix for one bug we saw. And I realized it within few minutes of setting the breakpoint at everyplace in project that has&amp;nbsp;NVIC_SystemReset();&lt;/p&gt;
&lt;p&gt;Please start your project in debug mode and see why the call stack when you see that your breakpoint is hit.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>