<?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>Implementing a bonding mode</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/51724/implementing-a-bonding-mode</link><description>Device: 
 
 Peripheral only 
 Peer Manager and Bonding working 
 S140 radio 
 nRF5 SDK 15.2.0 
 Rigado BMD-340 module 
 Central == iOS devices 
 
 Our nRF5 module is controlled by a Kinetis which uses a GPIO to indicate it should boot into a &amp;quot;bonding</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 04 Oct 2019 06:39:03 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/51724/implementing-a-bonding-mode" /><item><title>RE: Implementing a bonding mode</title><link>https://devzone.nordicsemi.com/thread/213310?ContentTypeID=1</link><pubDate>Fri, 04 Oct 2019 06:39:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e2567484-ed86-4a42-afd9-372a11eb7b22</guid><dc:creator>Joakim Jakobsen</dc:creator><description>&lt;p&gt;Thanks for sharing your solution.&lt;/p&gt;
&lt;p&gt;And I can&amp;#39;t see any issues doing it like that.&lt;/p&gt;
&lt;p&gt;Best regards, &lt;br /&gt;Joakim&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Implementing a bonding mode</title><link>https://devzone.nordicsemi.com/thread/213256?ContentTypeID=1</link><pubDate>Thu, 03 Oct 2019 17:34:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f595cd49-5794-4bee-b532-29ab9c0a3319</guid><dc:creator>jbroxson</dc:creator><description>&lt;p&gt;I believe we have come up with a working solution... in on_adv_evt() we now do the following:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;        case BLE_ADV_EVT_FAST:
            // If we are not in bonding mode, do not enter FAST
            if (!nrf_gpio_pin_read(PIN_BOND))
            {
                NRF_LOG_INFO(&amp;quot;on_adv_evt():BLE_ADV_EVT_FAST - Restarting advertising&amp;quot;);

                APP_ERROR_CHECK(ble_advertising_start(&amp;amp;s_advertising, BLE_ADV_MODE_DIRECTED_HIGH_DUTY));
                break;
            }

            // Set the power output to the appropriate level (default is 0 dBm)
            NRF_LOG_INFO(&amp;quot;on_adv_evt():BLE_ADV_EVT_FAST - ADV_TX_POWER_LEVEL: %d&amp;quot;, ADV_TX_POWER_LEVEL);
            err_code = sd_ble_gap_tx_power_set(BLE_GAP_TX_POWER_ROLE_ADV, s_advertising.adv_handle, ADV_TX_POWER_LEVEL);
            APP_ERROR_CHECK(err_code);

            break;

        case BLE_ADV_EVT_SLOW:
            // If we are not in bonding mode, do not enter SLOW
            if (!nrf_gpio_pin_read(PIN_BOND))
            {
                NRF_LOG_INFO(&amp;quot;on_adv_evt():BLE_ADV_EVT_SLOW - Restarting advertising&amp;quot;);

                APP_ERROR_CHECK(ble_advertising_start(&amp;amp;s_advertising, BLE_ADV_MODE_DIRECTED_HIGH_DUTY));
                break;
            }

&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;If we are not in bonding mode, and FAST/SLOW WHITELIST timeout, we will move back to trying directed (if possible) then back to&amp;nbsp;&lt;span style="background-color:#ffffff;color:#000000;float:none;font-family:Verdana,Arial,Helvetica,sans-serif;font-size:12px;font-style:normal;font-weight:400;letter-spacing:normal;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;"&gt;FAST WHITELIST.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Do you see any issues with doing it this way?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Implementing a bonding mode</title><link>https://devzone.nordicsemi.com/thread/212743?ContentTypeID=1</link><pubDate>Tue, 01 Oct 2019 08:41:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7673b7ce-43f7-414e-b927-eb12a8264d4d</guid><dc:creator>Joakim Jakobsen</dc:creator><description>&lt;p&gt;Hi!&lt;/p&gt;
&lt;p&gt;Did some research about this together with a colleague.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Without doing some extensive research in the spec. and the code, I think we found a valid workaround for you.&lt;/p&gt;
&lt;p&gt;I suspect the error you are seeing is related to the advertising module wanting to increment the advertising mode on timeout, but slow/fast is not enabled.&lt;/p&gt;
&lt;p&gt;A workaround for this is not to increment the advertising mode, but rather restart the advertising using directed advertising.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static ble_adv_mode_t adv_mode_next_get(ble_adv_mode_t adv_mode)
{
    if(adv_mode== BLE_ADV_MODE_DIRECTED_HIGH_DUTY )
    {
      return BLE_ADV_MODE_DIRECTED_HIGH_DUTY;
    }
    else
    {
    return (ble_adv_mode_t)((adv_mode + 1) % BLE_ADV_MODES);
    }
} &lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Let me know if this is something that could work for you.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards,&amp;nbsp;&lt;br /&gt;Joakim&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Implementing a bonding mode</title><link>https://devzone.nordicsemi.com/thread/212147?ContentTypeID=1</link><pubDate>Thu, 26 Sep 2019 22:12:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:28d462e2-171d-4207-a6da-bb78edd7484e</guid><dc:creator>jbroxson</dc:creator><description>&lt;p&gt;Yes. That is correct. I understand why that is not valid, but our goal is to allow only directed or whitelist when in our Connectable mode, while allowing normal (fast/slow) in our Bonding mode. How can I prevent the device from entering Fast and Slow advertising (without whitelist) after the whitelist modes timeout?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Implementing a bonding mode</title><link>https://devzone.nordicsemi.com/thread/211737?ContentTypeID=1</link><pubDate>Wed, 25 Sep 2019 09:08:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:117a5e43-c764-4e43-9938-9add6dcc1df8</guid><dc:creator>Joakim Jakobsen</dc:creator><description>&lt;p&gt;Sorry I think I misread the question.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You are getting the error 7 when slow/fast advertising is &lt;em&gt;not&amp;nbsp;&lt;/em&gt;enabled? So you are only getting the error using directed advertising?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Implementing a bonding mode</title><link>https://devzone.nordicsemi.com/thread/211736?ContentTypeID=1</link><pubDate>Wed, 25 Sep 2019 09:07:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9e516200-f664-4534-a97c-4f42a4357673</guid><dc:creator>Joakim Jakobsen</dc:creator><description>&lt;p&gt;Hi again!&lt;/p&gt;
&lt;p&gt;Sorry about the long delay here.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Have you made any progress on this?&lt;/p&gt;
&lt;p&gt;So you are getting error 7 (Invalid param) when you aren&amp;#39;t using the APP_ADV_FAST_INTERVAL with the directed advertising?&lt;/p&gt;
&lt;p&gt;What did you try to set the interval to when you got the error?&lt;/p&gt;
&lt;p&gt;Best regards,&amp;nbsp;&lt;br /&gt;Joakim&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Implementing a bonding mode</title><link>https://devzone.nordicsemi.com/thread/208753?ContentTypeID=1</link><pubDate>Mon, 09 Sep 2019 16:17:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:382a2c21-0323-4c19-9339-861510b8093b</guid><dc:creator>jbroxson</dc:creator><description>&lt;p&gt;Joakim,&lt;/p&gt;
&lt;p&gt;Changing the code so that it only enables whitelist and directed advertising results in an error 7 from&amp;nbsp;&lt;span style="background-color:#ffffff;"&gt;ble_advertising_init&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;    if (nrf_gpio_pin_read(PIN_BOND))
    {
        init.config.ble_adv_fast_enabled            = true;
        init.config.ble_adv_fast_interval           = APP_ADV_FAST_INTERVAL;
        init.config.ble_adv_fast_timeout            = APP_ADV_FAST_DURATION;

        init.config.ble_adv_slow_enabled            = true;
        init.config.ble_adv_slow_interval           = APP_ADV_SLOW_INTERVAL;
        init.config.ble_adv_slow_timeout            = APP_ADV_SLOW_DURATION;

        init.config.ble_adv_whitelist_enabled       = false;
    }
    else
    {
        init.config.ble_adv_directed_high_duty_enabled = true;
        init.config.ble_adv_directed_enabled        = true;
        init.config.ble_adv_directed_interval       = APP_ADV_FAST_INTERVAL;
        init.config.ble_adv_directed_timeout        = APP_ADV_FAST_DURATION;

        init.config.ble_adv_whitelist_enabled       = true;
///////// only enable whitelist and directed in this case
//        init.config.ble_adv_fast_enabled            = true;
//        init.config.ble_adv_fast_interval           = 40;
//        init.config.ble_adv_fast_timeout            = 100;

//        init.config.ble_adv_slow_enabled            = true;
//        init.config.ble_adv_slow_interval           = 1600;
//        init.config.ble_adv_slow_timeout            = 100;

    }

    err_code = ble_advertising_init(&amp;amp;s_advertising, &amp;amp;init);
    APP_ERROR_CHECK(err_code);//// &amp;lt;&amp;lt;&amp;lt;  Error 7 (NRF_ERROR_INVALID_PARAM) hit here&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;If I enter bluetooth settings on iOS, remove any bonding to the nRF device, reboot the iOS device (iOS does some caching which can cause weirdness at times), then browse for it, I can see the device if FAST or SLOW advertising is enabled (expected). I am not able advertise without FAST or SLOW enabled (the error 7 above will occur).&lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Implementing a bonding mode</title><link>https://devzone.nordicsemi.com/thread/208573?ContentTypeID=1</link><pubDate>Mon, 09 Sep 2019 05:29:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d474fde7-5a53-4d79-8257-6f5883b0b199</guid><dc:creator>Joakim Jakobsen</dc:creator><description>&lt;p&gt;Hi!&amp;nbsp;&lt;/p&gt;
[quote user=""]The idea is that bonding should occur in close proximity only, and only bonded devices can connect when in non-bonding mode at higher power (allowing connection at a larger distance).[/quote][quote user=""]Code for our advertising init is below. In this code I tried setting fast/slow to low timeouts, but iOS still sees it.[/quote]
&lt;p&gt;What do you mean iOS still sees it?&amp;nbsp;&lt;br /&gt;When you say that &amp;quot;only bonded devices can connect when in non-bonding mode&amp;quot;, do you want the device advertising to be invisible to non-bonded devices?&lt;/p&gt;
[quote user=""]If I configure advertising to only do whitelist, the API returns an error (don&amp;#39;t have it handy, but was along the lines of &amp;quot;incorrect parameter&amp;quot;)[/quote]
&lt;p&gt;&amp;nbsp;Could you try debugging your application again, and try figure out where exactly you are getting the invalid parameter error from?&lt;/p&gt;
&lt;p&gt;Best regards&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>