<?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>sd_ble_gap_conn_param_update error 8</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/19029/sd_ble_gap_conn_param_update-error-8</link><description>I have an application where my nrf52832 acts as a peripheral and I can connect to it without problems, but after some time like aprox 10 minutes when I try to connect to it again it doesn&amp;#39;t accept the connection until it resets and then the cycle restarts</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 19 Jan 2017 10:27:54 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/19029/sd_ble_gap_conn_param_update-error-8" /><item><title>RE: sd_ble_gap_conn_param_update error 8</title><link>https://devzone.nordicsemi.com/thread/73573?ContentTypeID=1</link><pubDate>Thu, 19 Jan 2017 10:27:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:207fa544-5c2f-41eb-a153-865e1e5e7a44</guid><dc:creator>Ole Bauck</dc:creator><description>&lt;p&gt;Great that you found the cause of the problem (and the solution)! I will tell the developers that this needs to be looked at.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: sd_ble_gap_conn_param_update error 8</title><link>https://devzone.nordicsemi.com/thread/73572?ContentTypeID=1</link><pubDate>Thu, 19 Jan 2017 07:49:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9cc34ea7-87b4-434f-9dc6-cfa2c248a8f8</guid><dc:creator>vea45</dc:creator><description>&lt;p&gt;Ok I tested the solution proposed by this post: &lt;a href="https://devzone.nordicsemi.com/question/67039/app_timer-expires-immediately-sdk-10/"&gt;devzone.nordicsemi.com/.../&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;And now it works! The problem was a timeout timer that executes inmediately after some time... I got my board running for 24h without any errors so I think that the timer library was the problem.&lt;/p&gt;
&lt;p&gt;This is the timer.c file with the proposed fixes by the other post applied on the SDK 12.2: &lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/4478.app_5F00_timer.c"&gt;app_timer.c&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: sd_ble_gap_conn_param_update error 8</title><link>https://devzone.nordicsemi.com/thread/73571?ContentTypeID=1</link><pubDate>Wed, 18 Jan 2017 14:35:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a77e9da6-8f8a-4dc3-9ac3-cdeb3e3a3a54</guid><dc:creator>vea45</dc:creator><description>&lt;p&gt;The timeout connection handler... The other times the timer works well...&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;static void connection_timeout_handler(void * p_context){
            UNUSED_PARAMETER(p_context);
        	  uint32_t err_code = sd_ble_gap_disconnect(m_conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
            APP_ERROR_CHECK(err_code);
        		timeout_timer_running=false;
        }
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: sd_ble_gap_conn_param_update error 8</title><link>https://devzone.nordicsemi.com/thread/73570?ContentTypeID=1</link><pubDate>Wed, 18 Jan 2017 14:34:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f9bbb2d7-8388-4a27-8ac7-1b89f14c06fc</guid><dc:creator>vea45</dc:creator><description>&lt;p&gt;Omg... Now I discovered that I have a connection timeout that executes instantly when someone establishes a connection. This timer is started when the connection starts (BLE_GAP_EVT_CONNECTED) and it kills the connection if the phone gets stuck with it... but is configured to kill the connection after &lt;strong&gt;50 sec&lt;/strong&gt; and this number is a constant so I don&amp;#39;t know why this timer randomly executes insantly, any ideas?&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#define TIMEOUT_CONNECTION	APP_TIMER_TICKS(50000, APP_TIMER_PRESCALER)

case BLE_GAP_EVT_CONNECTED:
m_conn_handle = p_ble_evt-&amp;gt;evt.gap_evt.conn_handle;
	if (first_time){
		err_code= app_timer_start(m_timeout_timer_id, FIRST_TIMEOUT_CONNECTION, NULL);
	}else{
		err_code= app_timer_start(m_timeout_timer_id, TIMEOUT_CONNECTION, NULL);
	}
	timeout_timer_running=true;
	APP_ERROR_CHECK(err_code);
	led_write_handler_led(1,LED_RED_CH);
break;
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: sd_ble_gap_conn_param_update error 8</title><link>https://devzone.nordicsemi.com/thread/73569?ContentTypeID=1</link><pubDate>Wed, 18 Jan 2017 14:21:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a67510fb-f52b-4bbd-93f9-b11337644383</guid><dc:creator>vea45</dc:creator><description>&lt;p&gt;doing this the parameters update timer never starts and it works as &amp;quot;normaly&amp;quot; I can connect to it without problems the first times... The only change is that now I&amp;#39;m facing exactly the same behaviour but the error appears on another function &amp;quot;sd_ble_gatts_exchange_mtu_reply()&amp;quot; inside the &amp;quot;BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST&amp;quot; event, also with error 8...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: sd_ble_gap_conn_param_update error 8</title><link>https://devzone.nordicsemi.com/thread/73568?ContentTypeID=1</link><pubDate>Wed, 18 Jan 2017 14:19:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:40fdc8b4-e4e1-4575-9e3c-eec1a18fe65f</guid><dc:creator>vea45</dc:creator><description>&lt;p&gt;I&amp;#39;m using the SDK library. The only modification is the one that I posted here (the added condition on the &amp;#39;if&amp;#39;).
Now I&amp;#39;m trying to find the source of the error and I blocked the parameters update (I read on another post that this can be done safely) commenting those lines on the same file inside the function &amp;quot;conn_params_negotiation(void)&amp;quot;&lt;/p&gt;
&lt;p&gt;if (m_update_count == 0){
// First connection parameter update
timeout_ticks = m_conn_params_config.first_conn_params_update_delay;
}else{
timeout_ticks = m_conn_params_config.next_conn_params_update_delay;
}&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;       /* err_code = app_timer_start(m_conn_params_timer_id, timeout_ticks, NULL);
        if ((err_code != NRF_SUCCESS) &amp;amp;&amp;amp; (m_conn_params_config.error_handler != NULL)){
            m_conn_params_config.error_handler(err_code);
        }*/
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;[...]&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: sd_ble_gap_conn_param_update error 8</title><link>https://devzone.nordicsemi.com/thread/73567?ContentTypeID=1</link><pubDate>Wed, 18 Jan 2017 14:04:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:31c9ac4e-0451-4772-8c56-8a99e8e8867e</guid><dc:creator>Ole Bauck</dc:creator><description>&lt;p&gt;Ok, I thought you used the sd_ble_gap_conn_param_update(..) directly in your code and not the SDK library.&lt;/p&gt;
&lt;p&gt;I checked and the only time sd_ble_gap_conn_param_update(..) will return error NRF_ERROR_INVALID_STATE (0x8) is if the device is not in a connection. The only explanation I can think of as to why you get this error code is that the peer has disconnected, but the application has yet not gotten the disconnected event or have not executed the code that is to be run on disconnect (the event is pending because other interrupts at equal or higher level has to be executed first). So the SoftDevice knows that the connection is lost, but the application don&amp;#39;t.&lt;/p&gt;
&lt;p&gt;I assume that you have not altered the SDK library code (ble_conn_params).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: sd_ble_gap_conn_param_update error 8</title><link>https://devzone.nordicsemi.com/thread/73566?ContentTypeID=1</link><pubDate>Tue, 17 Jan 2017 13:09:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:353f421b-e84d-4778-9f3d-e16f4e541e2d</guid><dc:creator>vea45</dc:creator><description>&lt;p&gt;Nope, inside ble_conn_params.c -&amp;gt; update_timeout_handler() I forced to check again the m_conn_handle but the error appears appears when the device is connected.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;static void update_timeout_handler(void * p_context)
{
    UNUSED_PARAMETER(p_context);

    if (m_conn_handle != BLE_CONN_HANDLE_INVALID)
    {
        // Check if we have reached the maximum number of attempts
        m_update_count++;
        if (m_update_count &amp;lt;= m_conn_params_config.max_conn_params_update_count)
        {
            uint32_t err_code;

            // Parameters are not ok, send connection parameters update request.
            err_code = sd_ble_gap_conn_param_update(m_conn_handle, &amp;amp;m_preferred_conn_params);
            if ((err_code != NRF_SUCCESS) &amp;amp;&amp;amp; (m_conn_params_config.error_handler != NULL)&amp;amp;&amp;amp; (m_conn_handle != BLE_CONN_HANDLE_INVALID))
            {
                m_conn_params_config.error_handler(err_code);///error here!
            }
        }
        else
[...]
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: sd_ble_gap_conn_param_update error 8</title><link>https://devzone.nordicsemi.com/thread/73565?ContentTypeID=1</link><pubDate>Tue, 17 Jan 2017 11:49:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:14a86803-876a-462f-bc32-c8f5dd8fa504</guid><dc:creator>Ole Bauck</dc:creator><description>&lt;p&gt;You probably get the invalid state error because you are not in a connection. Add a check for the connection handle:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;if (m_conn_handle != BLE_CONN_HANDLE_INVALID)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To check if you are in a connection, or disregard the error code returned from the function.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>