<?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>When cutting after bonding, I want to make it BONDED with nRF Connect.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/83988/when-cutting-after-bonding-i-want-to-make-it-bonded-with-nrf-connect</link><description>Hello. 
 I am developing nrf52832 (S132 v7.0.1, SDK v17.0.0) as a peripheral. 
 What I want to do is to connect to Central, then bond and then disconnect. 
 Therefore, sd_ble_gap_disconnect is put in PM_EVT_PEER_DATA_UPDATE_SUCCEEDED which seems to be</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 27 Jan 2022 04:23:53 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/83988/when-cutting-after-bonding-i-want-to-make-it-bonded-with-nrf-connect" /><item><title>RE: When cutting after bonding, I want to make it BONDED with nRF Connect.</title><link>https://devzone.nordicsemi.com/thread/349864?ContentTypeID=1</link><pubDate>Thu, 27 Jan 2022 04:23:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1e825001-208e-46ce-a009-2dcb1dfb4fbb</guid><dc:creator>sdi_kei</dc:creator><description>&lt;p&gt;Hello.&lt;/p&gt;
&lt;p&gt;By delaying the disconnection time by 1 second, nRF Connect can now be BONDED.&lt;/p&gt;
&lt;p&gt;It was very helpful. Thank you very much.&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: When cutting after bonding, I want to make it BONDED with nRF Connect.</title><link>https://devzone.nordicsemi.com/thread/349575?ContentTypeID=1</link><pubDate>Tue, 25 Jan 2022 14:22:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:06108151-9c5b-4ae1-a7c7-b56891d42512</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;The key exchange must be completed before receiving the PM_EVT_PEER_DATA_UPDATE_SUCCEEDED {.data_id == PM_PEER_DATA_ID_BONDING} event. This is purely speculation on my part, but maybe there is something internal on the Central stack that causes it to discard the bond if the link is terminated too soon. Either way, I think it would be a good idea to delay the disconnect a bit to allow other less critical bonding data to be stored as well&amp;nbsp; (CCCD&amp;#39;s, etc).&lt;/p&gt;
&lt;p&gt;E.g.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void disconnect(void * p_context)
{
    uint32_t err_code = sd_ble_gap_disconnect(conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
    APP_ERROR_CHECK(err_code);
}

static void timers_init(void)
{
    ret_code_t err_code;

    // Initialize timer module.
    err_code = app_timer_init();
    APP_ERROR_CHECK(err_code);
    err_code = app_timer_create(&amp;amp;m_disconnect_timer_id,
                                APP_TIMER_MODE_SINGLE_SHOT,
                                disconnect);
     APP_ERROR_CHECK(err_code);
     ....
}

....
case PM_EVT_PEER_DATA_UPDATE_SUCCEEDED:
    if (p_evt-&amp;gt;params.peer_data_update_succeeded.data_id == PM_PEER_DATA_ID_BONDING) {

        /* Disconnect in 2000 ms */
        err_code = app_timer_start(m_disconnect_timer_id, APP_TIMER_TICKS(1000), NULL);
        APP_ERROR_CHECK(err_code);
    }            
    break;
 ...  
    
&lt;/pre&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></channel></rss>