<?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>Re-pairing NRF BLE with the same host without manual bond erase button pushing</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/16981/re-pairing-nrf-ble-with-the-same-host-without-manual-bond-erase-button-pushing</link><description>Hello. 
 I am developing a BLE application on NRF52832 using Nordic SDK11 and S132 softdevice. I use Linux PC as a BLE host device, and can pair &amp;amp; bond the NRF bluetooth device with the Linux host. I use encrypted connection settings BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 14 Oct 2016 06:38:39 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/16981/re-pairing-nrf-ble-with-the-same-host-without-manual-bond-erase-button-pushing" /><item><title>RE: Re-pairing NRF BLE with the same host without manual bond erase button pushing</title><link>https://devzone.nordicsemi.com/thread/65131?ContentTypeID=1</link><pubDate>Fri, 14 Oct 2016 06:38:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d5974d68-c4db-4f62-bc48-d36561e79b52</guid><dc:creator>Olli</dc:creator><description>&lt;p&gt;Great, this worked!&lt;/p&gt;
&lt;p&gt;I inserted there a small safety condition that if at least NN hours have elapsed since previous communication, then the NRF device agrees to pair again with the same host, to allow re-pairing yet avoid possibility that other malicious host mimicking the same Mac would attempt to steal the bonded connection from the actual authorized host.&lt;/p&gt;
&lt;p&gt;Many thanks also for the quick reply: Support in this forum is awesome, I&amp;#39;ve discovered answers to dozens of my earlier questions by searching Q&amp;amp;As in this forum!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Re-pairing NRF BLE with the same host without manual bond erase button pushing</title><link>https://devzone.nordicsemi.com/thread/65130?ContentTypeID=1</link><pubDate>Tue, 11 Oct 2016 13:08:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:11941b2d-ac29-46c7-8035-3fe26d661aa3</guid><dc:creator>FormerMember</dc:creator><description>&lt;p&gt;The peer_manager code is set up so that it will reject a new bonding procedure from devices with already stored bonding information.&lt;/p&gt;
&lt;p&gt;Starting from the first received event in the pairing process, &lt;a href="http://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.s132.api.v2.0.0%2Fgroup___b_l_e___g_a_p___p_e_r_i_p_h___b_o_n_d_i_n_g___j_w___m_s_c.html&amp;amp;cp=2_3_0_1_1_2_1_3_8_7_0"&gt;BLE_GAP_EVT_SEC_PARAMS_REQUEST&lt;/a&gt;, the piece of code that rejects the  new bonding process can be found the following way:&lt;/p&gt;
&lt;p&gt;BLE_GAP_EVT_SEC_PARAMS_REQUEST --&amp;gt; security_dispatcher.c:&lt;/p&gt;
&lt;p&gt;smd_ble_evt_handler( --&amp;gt; BLE_GAP_EVT_SEC_PARAMS_REQUEST --&amp;gt; sec_params_request_process)&lt;/p&gt;
&lt;p&gt;--&amp;gt;&lt;/p&gt;
&lt;p&gt;sec_params_request_process(--&amp;gt; SMD_EVT_PARAMS_REQ)&lt;/p&gt;
&lt;p&gt;--&amp;gt;&lt;/p&gt;
&lt;p&gt;smd_evt_handler( --&amp;gt; SMD_EVT_PARAMS_REQ --&amp;gt; &lt;strong&gt;smd_params_reply_perform(..)&lt;/strong&gt;)&lt;/p&gt;
&lt;p&gt;In smd_params_reply_perform(..) there is a check if the connected device already is bonded. And if it is already bonded, the pairing procedure will be rejected:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;static void smd_params_reply_perform(uint16_t conn_handle)
{
ret_code_t err_code;

if (  (ble_conn_state_role(conn_handle) == BLE_GAP_ROLE_PERIPH)
    &amp;amp;&amp;amp; im_peer_id_get_by_conn_handle(conn_handle) != PM_PEER_ID_INVALID)
{
    // Bond already exists. Reject the pairing request if the user doesn&amp;#39;t intervene.
    ble_conn_state_user_flag_set(conn_handle, m_sm.flag_id_reject_pairing, true);
    send_config_req(conn_handle);
}
else
{
    ble_conn_state_user_flag_set(conn_handle, m_sm.flag_id_reject_pairing, false);
}
....
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>