<?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 Parameter Negotiation Using Tolerance Settings - Best Practices</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/125136/connection-parameter-negotiation-using-tolerance-settings---best-practices</link><description>Hello Nordic team, 
 I&amp;#39;m developing a BLE peripheral using nRF52833 and would like to validate that my approach for handling connection parameters aligns with Nordic&amp;#39;s best practices. 
 We were noticing some intermittent disconnects between our peripheral</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 27 Oct 2025 13:21:02 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/125136/connection-parameter-negotiation-using-tolerance-settings---best-practices" /><item><title>RE: Connection Parameter Negotiation Using Tolerance Settings - Best Practices</title><link>https://devzone.nordicsemi.com/thread/552489?ContentTypeID=1</link><pubDate>Mon, 27 Oct 2025 13:21:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b30230c1-4c7c-4ecd-b257-8c36784e2285</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Happy to help!&lt;/p&gt;
&lt;p&gt;Let me know if you run into any other, related issues.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Connection Parameter Negotiation Using Tolerance Settings - Best Practices</title><link>https://devzone.nordicsemi.com/thread/552187?ContentTypeID=1</link><pubDate>Wed, 22 Oct 2025 19:05:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0d28b8d1-1b5b-49f6-b839-321e3c81c0b7</guid><dc:creator>Robert Edmonston</dc:creator><description>&lt;p&gt;Thanks Edvin, this&amp;nbsp;is helpful. I removed the&amp;nbsp;&lt;span&gt;on_conn_params_evt&lt;/span&gt;&amp;nbsp;handler and now the peripheral stays connected even if the conn parameter update negotiations fail.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Connection Parameter Negotiation Using Tolerance Settings - Best Practices</title><link>https://devzone.nordicsemi.com/thread/552162?ContentTypeID=1</link><pubDate>Wed, 22 Oct 2025 12:47:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:274935c4-7a8a-4b9a-b6e9-cc73eeaeb8e8</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;You can use your preferred connection parameters as guiding lines for your central. If you want your peripheral to have a certain set of parameters, then you should set a range which you accept. If a central enters connection with any of the parameters outside this range, it will try to negotiate the parameters&amp;nbsp;MAX_CONN_PARAMS_UPDATE_COUNT (=3 by default) times. First one after 5 seconds, and the other two after 30 seconds each, I believe. These are also defined by some #defines in the application.&lt;/p&gt;
&lt;p&gt;If you, however, want your device to stay connected regardless of connection parameters, you should indeed set disconnect_on_fail = false. This should just ignore the 3rd fail, and remain connected using whatever connection parameters it currently has.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;If you are saying that the device disconnects even if disconnect_on_fail is set to false, then that sounds like a bug. What SDK version are you using?&lt;/p&gt;
&lt;p&gt;At least in SDK 17.1.0, in ble_conn_params.c, line 207 it says:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void update_timeout_handler(void * p_context)
{
    uint32_t                     conn_handle = (uint32_t)p_context;
    ble_conn_params_instance_t * p_instance  = instance_get(conn_handle);

    if (p_instance != NULL)
    {
        // Check if we have reached the maximum number of attempts
        if (p_instance-&amp;gt;update_count &amp;lt; m_conn_params_config.max_conn_params_update_count)
        {
            bool update_sent = send_update_request(conn_handle, &amp;amp;p_instance-&amp;gt;preferred_conn_params);
            if (update_sent)
            {
                p_instance-&amp;gt;update_count++;
            }
        }
        else
        {
            p_instance-&amp;gt;update_count = 0;

            // Negotiation failed, disconnect automatically if this has been configured
            if (m_conn_params_config.disconnect_on_fail)
            {
                ret_code_t err_code;

                err_code = sd_ble_gap_disconnect(conn_handle, BLE_HCI_CONN_INTERVAL_UNACCEPTABLE);
                if ((err_code != NRF_SUCCESS) &amp;amp;&amp;amp; (err_code != NRF_ERROR_INVALID_STATE)) // NRF_ERROR_INVALID_STATE means disconnect is already in progress.
                {
                    send_error_evt(err_code);
                }
            }

            // Notify the application that the procedure has failed
            if (m_conn_params_config.evt_handler != NULL)
            {
                ble_conn_params_evt_t evt;

                evt.evt_type = BLE_CONN_PARAMS_EVT_FAILED;
                evt.conn_handle = conn_handle;
                m_conn_params_config.evt_handler(&amp;amp;evt);
            }
        }
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote user="Robert Edmonston"]&lt;div&gt;&lt;span&gt;static&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;void&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;on_conn_params_evt&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;ble_conn_params_evt_t&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;*&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;p_evt&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;uint32_t&lt;/span&gt;&lt;span&gt; err_code;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;p_evt&lt;/span&gt;&lt;span&gt;-&amp;gt;&lt;/span&gt;&lt;span&gt;evt_type&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;==&lt;/span&gt;&lt;span&gt; BLE_CONN_PARAMS_EVT_FAILED)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt; err_code &lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;sd_ble_gap_disconnect&lt;/span&gt;&lt;span&gt;(m_conn_handle, BLE_HCI_CONN_INTERVAL_UNACCEPTABLE);&lt;/span&gt;&lt;/div&gt;[/quote]
&lt;p&gt;I do see this in some of the samples. This one is probably in main.c, as it is in the ble_app_uart example. But as you can see from it&amp;#39;s description:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt; * @note All this function does is to disconnect. This could have been done by simply setting
 *       the disconnect_on_fail config parameter, but instead we use the event handler
 *       mechanism to demonstrate its use.&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;So just remove this disconnect call, and it should work as you&amp;#39;d expect.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Connection Parameter Negotiation Using Tolerance Settings - Best Practices</title><link>https://devzone.nordicsemi.com/thread/552107?ContentTypeID=1</link><pubDate>Wed, 22 Oct 2025 00:23:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:396355a0-0ff2-425e-ae9b-b2786a57ed97</guid><dc:creator>Robert Edmonston</dc:creator><description>&lt;p&gt;Just after posting I noticed something that may be why I&amp;#39;m seeing a disconnect on fail even though&amp;nbsp;&lt;span&gt;disconnect_on_fail is set to false.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Do I need to modify this function in ble_handler.c to prevent the negotiation failures from causing a disconnect?&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;/**@brief Function for handling an event from the Connection Parameters Module.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt; *&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt; * @details This function will be called for all events in the Connection Parameters Module&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt; * which are passed to the application.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt; *&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt; * @note All this function does is to disconnect. This could have been done by simply setting&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt; * the disconnect_on_fail config parameter, but instead we use the event handler&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt; * mechanism to demonstrate its use.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt; *&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt; * @param[in] p_evt Event received from the Connection Parameters Module.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt; */&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;static&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;void&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;on_conn_params_evt&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;ble_conn_params_evt_t&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;*&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;p_evt&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;uint32_t&lt;/span&gt;&lt;span&gt; err_code;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;p_evt&lt;/span&gt;&lt;span&gt;-&amp;gt;&lt;/span&gt;&lt;span&gt;evt_type&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;==&lt;/span&gt;&lt;span&gt; BLE_CONN_PARAMS_EVT_FAILED)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt; err_code &lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;sd_ble_gap_disconnect&lt;/span&gt;&lt;span&gt;(m_conn_handle, BLE_HCI_CONN_INTERVAL_UNACCEPTABLE);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;if&lt;/span&gt;&lt;span&gt; (err_code &lt;/span&gt;&lt;span&gt;!=&lt;/span&gt;&lt;span&gt; NRF_ERROR_INVALID_STATE)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;MM_VERIFY&lt;/span&gt;&lt;span&gt;(err_code &lt;/span&gt;&lt;span&gt;==&lt;/span&gt;&lt;span&gt; NRF_SUCCESS, ERR_BLE_FAILED);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>