<?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>How do I prevent an iPhone from bonding?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/38912/how-do-i-prevent-an-iphone-from-bonding</link><description>Currently, in my application, any iPhone can attempt to read from one of my protected characteristics and initiate the bonding sequence. I have it set to &amp;quot;just works&amp;quot; mode (no PIN or out-of-band pairing) Where can I put an if statement that lets me restrict</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 03 Oct 2018 00:51:27 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/38912/how-do-i-prevent-an-iphone-from-bonding" /><item><title>RE: How do I prevent an iPhone from bonding?</title><link>https://devzone.nordicsemi.com/thread/151311?ContentTypeID=1</link><pubDate>Wed, 03 Oct 2018 00:51:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c09ab4f4-5e2f-400b-a3fb-7b5126395cfb</guid><dc:creator>Andrew Ong</dc:creator><description>&lt;p&gt;I did as you suggested in the form of this function and it seems to work well.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static void turn_bonding_on_off(bool on){
    if(on){
        ble_gap_sec_params_t sec_param;
        ret_code_t           err_code;

        memset(&amp;amp;sec_param, 0, sizeof(ble_gap_sec_params_t));

        // Security parameters to be used for all security procedures.
        sec_param.bond           = SEC_PARAM_BOND;
        sec_param.mitm           = SEC_PARAM_MITM;
        sec_param.lesc           = SEC_PARAM_LESC;
        sec_param.keypress       = SEC_PARAM_KEYPRESS;
        sec_param.io_caps        = SEC_PARAM_IO_CAPABILITIES;
        sec_param.oob            = SEC_PARAM_OOB;
        sec_param.min_key_size   = SEC_PARAM_MIN_KEY_SIZE;
        sec_param.max_key_size   = SEC_PARAM_MAX_KEY_SIZE;
        sec_param.kdist_own.enc  = 1;
        sec_param.kdist_own.id   = 1;
        sec_param.kdist_peer.enc = 1;
        sec_param.kdist_peer.id  = 1;

        err_code = pm_sec_params_set(&amp;amp;sec_param);
        APP_ERROR_CHECK(err_code);
    } else {
        /* Disallow bonding */
        pm_sec_params_set(NULL);
    }
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I prevent an iPhone from bonding?</title><link>https://devzone.nordicsemi.com/thread/151016?ContentTypeID=1</link><pubDate>Mon, 01 Oct 2018 14:35:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:da2fc12a-917d-48b3-b2e9-c62953240efe</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Andrew,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I would need to know more about what you mentioned &amp;quot;&lt;span&gt;my device timeout during interrogation&amp;quot;, what exactly happened&amp;nbsp;? Which app did you use ? Could you try using nRFConnect ? Could you check if the nRF52 crashes at some points ?&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;The sec_param.bond&amp;nbsp; configuration only used to enable/disable bonding, not about pairing. This mean the phone can still pair (encrypt the link) but don&amp;#39;t store bond information. The device still can read characteristic&amp;nbsp;that require encryption.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I prevent an iPhone from bonding?</title><link>https://devzone.nordicsemi.com/thread/150844?ContentTypeID=1</link><pubDate>Sat, 29 Sep 2018 00:46:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9dc8d0ef-b6bc-4c72-b9fd-bcf3373b21cb</guid><dc:creator>Andrew Ong</dc:creator><description>&lt;p&gt;A whitelist is an option, but it seems like overengineering because I would need a way to approve what goes on the whitelist. At that point, I&amp;#39;m at square 1. I just want&amp;nbsp;devices to be able to bond when a button is pressed.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I DO use the peer manager. I tried using&amp;nbsp;&lt;span&gt;pm_sec_params_set(NULL) but that made my device timeout during interrogation.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Isn&amp;#39;t it better to&amp;nbsp;reinitialize the peer manager with&amp;nbsp;&amp;nbsp;sec_param.bond = 0 or&amp;nbsp;&amp;nbsp;sec_param.bond&amp;nbsp; = 1? EDIT: when I tried setting&amp;nbsp;sec_param.bond = 0, I got a Fatal error: &amp;quot;Invalid parameter&amp;quot;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;    ble_gap_sec_params_t sec_param;
    ret_code_t           err_code;

    err_code = pm_init();
    APP_ERROR_CHECK(err_code);

    memset(&amp;amp;sec_param, 0, sizeof(ble_gap_sec_params_t));

    // Security parameters to be used for all security procedures.
    sec_param.bond           = SEC_PARAM_BOND;
    sec_param.mitm           = SEC_PARAM_MITM;
    sec_param.lesc           = SEC_PARAM_LESC;
    sec_param.keypress       = SEC_PARAM_KEYPRESS;
    sec_param.io_caps        = SEC_PARAM_IO_CAPABILITIES;
    sec_param.oob            = SEC_PARAM_OOB;
    sec_param.min_key_size   = SEC_PARAM_MIN_KEY_SIZE;
    sec_param.max_key_size   = SEC_PARAM_MAX_KEY_SIZE;
    sec_param.kdist_own.enc  = 1;
    sec_param.kdist_own.id   = 1;
    sec_param.kdist_peer.enc = 1;
    sec_param.kdist_peer.id  = 1;

    err_code = pm_sec_params_set(&amp;amp;sec_param);
    APP_ERROR_CHECK(err_code);
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I prevent an iPhone from bonding?</title><link>https://devzone.nordicsemi.com/thread/150463?ContentTypeID=1</link><pubDate>Wed, 26 Sep 2018 11:49:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f16c172e-612d-4ebe-84d1-907efbf30662</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Andrew,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Have you considered using whitelist ? You can limit the connection of other phones to only the phones you have bonded with.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If whitelist is not an option ( you still want to allow connection from any phone) you can think of dynamically configure peermanager to enable and disable pairing. To disable pairing, you can simply call&amp;nbsp;pm_sec_params_set() with NULL parameter to disable pairing and call it again with correct parameter to enable pairing/bonding.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you don&amp;#39;t use peermanager, then you have full control, just choose what to reply when you receive the BLE_GAP_EVT_SEC_PARAMS_REQUEST event&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>