<?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>BLE bonding</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/58248/ble-bonding</link><description>Hi, 
 
 As far as I understand, every connection establishment has to start with advertising. 
 Event if I have already connected and bonded to a peer, after disconnection I have to start advertising in order to connect to this peer again. 
 Am I right</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sun, 15 Mar 2020 10:27:26 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/58248/ble-bonding" /><item><title>RE: BLE bonding</title><link>https://devzone.nordicsemi.com/thread/239841?ContentTypeID=1</link><pubDate>Sun, 15 Mar 2020 10:27:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:35118bc9-ccbc-45c1-8be4-d54846e61a17</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;The IRK is&amp;nbsp;Identity Resolving Key, which gives a hint. When a device using a resolvable address changes the address, that is derived from the IRK. And it is also possible to do the reverse: check an address to see if it has been derived from a specific IRK, which is done by the peer that has the IRK after bonding. The exact details of how the resolution works is black magic to me (cryptography), but there is no need to understand the math in order to use it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE bonding</title><link>https://devzone.nordicsemi.com/thread/239811?ContentTypeID=1</link><pubDate>Fri, 13 Mar 2020 20:52:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a4b9332a-6af8-45d6-ad46-85c38bd7d5e7</guid><dc:creator>Roei</dc:creator><description>&lt;p&gt;Thanks, you helped me a lot!&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I still don&amp;#39;t understand how exactly the IRK works. Can you give me an example, how the first peer can recognize the second peer, using IRK, after the second one changed it&amp;#39;s address?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE bonding</title><link>https://devzone.nordicsemi.com/thread/236590?ContentTypeID=1</link><pubDate>Wed, 26 Feb 2020 14:21:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d7c3fea9-5442-46e8-94ec-c03a067604e4</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;The device identities list is a list of device IRK&amp;#39;s (Identity resolution keys). So that is needed for whitelisting peers that use privacy (which include any modern phone). Whitelisting static MAC addresses only work with devices that do not use privacy. Therefore, you will need code for both to handle both cases, like it is done in the SDK examples.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE bonding</title><link>https://devzone.nordicsemi.com/thread/236561?ContentTypeID=1</link><pubDate>Wed, 26 Feb 2020 13:19:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:451e20fd-326f-4645-826f-3e653ee0ab65</guid><dc:creator>Roei</dc:creator><description>&lt;p&gt;Thanks a lot!&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;One more question -&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I&amp;#39;m still confused about the difference between&amp;nbsp;pm_whitelist_set and&amp;nbsp;pm_device_identities_list_set. Can you please explain what does each of them do?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE bonding</title><link>https://devzone.nordicsemi.com/thread/236552?ContentTypeID=1</link><pubDate>Wed, 26 Feb 2020 13:06:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bb9b95b2-e6b0-4bac-a25c-0b5e6126ac0c</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I see. You could start advertising normally, and then restart, or slightly adjust the advertising module.&lt;/p&gt;
&lt;p&gt;The resone calling ble_advertising_restart_without_whitelistadvertising() did not work is that the module only supports restarting advertising in the same mode, and when advertising is not active the mode is IDLE. If you want to start advertising without whitelist you could expand the library with a&amp;nbsp;ble_advertising_start_without_whitelist() function like this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;uint32_t ble_advertising_start_without_whitelist(ble_advertising_t * const p_advertising,
                                                 ble_adv_mode_t            advertising_mode)
{
    ret_code_t ret;

    p_advertising-&amp;gt;whitelist_temporarily_disabled = true;
    p_advertising-&amp;gt;whitelist_in_use               = false;
    p_advertising-&amp;gt;adv_params.filter_policy       = BLE_GAP_ADV_FP_ANY;
    // Set correct flags.
    ret = flags_set(p_advertising, BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE);
    VERIFY_SUCCESS(ret);

    ret = ble_advertising_start(p_advertising, advertising_mode);
    if ((ret != NRF_SUCCESS) &amp;amp;&amp;amp; (p_advertising-&amp;gt;error_handler != NULL))
    {
        p_advertising-&amp;gt;error_handler(ret);
    }

    return NRF_SUCCESS;
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;The only difference from the restart variant is that it does not stop advertising, and it uses the specified&amp;nbsp;mode instead of the current mode. Calling this function instead of&amp;nbsp;ble_advertising_start() will do the trick.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE bonding</title><link>https://devzone.nordicsemi.com/thread/236268?ContentTypeID=1</link><pubDate>Tue, 25 Feb 2020 13:22:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:093e2b98-3aa4-4f68-986f-3e56152ae024</guid><dc:creator>Roei</dc:creator><description>&lt;p&gt;OK, the problem is that the current advertising mode is Idle, and I need to set it to Fast before I restart advertising without whitelist. Or should I do another thing?&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: BLE bonding</title><link>https://devzone.nordicsemi.com/thread/236265?ContentTypeID=1</link><pubDate>Tue, 25 Feb 2020 13:00:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:10ab7958-95b7-4c80-a5a0-c84d8e64eebe</guid><dc:creator>Roei</dc:creator><description>&lt;p&gt;Yes, I used the example and I test it with my mobile, I can see when I connect or disconnect clearly, and I tested it with more mobiles to validate the whitelist. It was all good, but I need the option to start reqular advertising as well.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I get the idle event right after starting advertising (in the same ms).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE bonding</title><link>https://devzone.nordicsemi.com/thread/236253?ContentTypeID=1</link><pubDate>Tue, 25 Feb 2020 12:40:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cea9bef9-4afb-4c43-a790-c2239a444ce4</guid><dc:creator>Roei</dc:creator><description>&lt;p&gt;I will explain again.&lt;/p&gt;
&lt;p&gt;I want my application to start advertising with whitelist in some cases, and without whitelist in others.&lt;/p&gt;
&lt;p&gt;How can I do that without starting advertising and restart again?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE bonding</title><link>https://devzone.nordicsemi.com/thread/236252?ContentTypeID=1</link><pubDate>Tue, 25 Feb 2020 12:40:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:03c8b35c-9116-4298-92d7-ca0d4ce29141</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Please elaborate much more.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Are you using an example?&lt;/li&gt;
&lt;li&gt;Which exact changes have you done from the example (preferably show a diff or similar)?&lt;/li&gt;
&lt;li&gt;How do you test?&lt;/li&gt;
&lt;li&gt;How long time&amp;nbsp;does it take from the call to&amp;nbsp;ble_advertising_restart_without_whitelist() until you get the&amp;nbsp;BLE_ADV_EVT_IDLE?&lt;/li&gt;
&lt;/ul&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE bonding</title><link>https://devzone.nordicsemi.com/thread/236244?ContentTypeID=1</link><pubDate>Tue, 25 Feb 2020 12:30:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c5f53a5a-c8fa-4814-a229-2ebeac188a44</guid><dc:creator>Roei</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I set ble_adv_whitelist_enabled = true when initialized my module.&lt;/p&gt;
&lt;p&gt;After that, I just operated ble_advertising_restart_without_whitelist(), and the result was&amp;nbsp;BLE_ADV_EVT_IDLE.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE bonding</title><link>https://devzone.nordicsemi.com/thread/236240?ContentTypeID=1</link><pubDate>Tue, 25 Feb 2020 12:22:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:377830c4-e62b-44f5-bdea-fb07c9cd394e</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;This works out of the box with the unmodified&amp;nbsp;Current Time Application, and it is not clear to me what you have done. Why do you change&amp;nbsp;whitelist_temporarily_disabled? That is only intended to be used by the module itself, it is not something you should modify.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE bonding</title><link>https://devzone.nordicsemi.com/thread/236224?ContentTypeID=1</link><pubDate>Tue, 25 Feb 2020 11:53:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f2d92661-cd2a-452f-892f-39b5496c4a8a</guid><dc:creator>Roei</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&lt;span style="background-color:transparent;color:#11171a;float:none;font-family:&amp;#39;GT Eesti&amp;#39;,&amp;#39;Helvetica&amp;#39;,Arial,sans-serif;font-size:14px;font-style:normal;font-weight:400;letter-spacing:normal;line-height:21px;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;"&gt;ble_advertising_restart_without_whitelist()&lt;/span&gt; doesn&amp;#39;t work, it cause&amp;nbsp;BLE_ADV_EVT_IDLE event, instead of&amp;nbsp;BLE_ADV_EVT_FAST. Only when I set&amp;nbsp;whitelist_temporarily_disabled = false, it works.&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: BLE bonding</title><link>https://devzone.nordicsemi.com/thread/236220?ContentTypeID=1</link><pubDate>Tue, 25 Feb 2020 11:32:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6d94ad6e-7dc4-4b33-ae00-150d2343fb9b</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;The advertising module handles this for you, If you refer to the Current Time Application, you can see that it calls&amp;nbsp;ble_advertising_restart_without_whitelist()&amp;nbsp;in a few places, particularly when there is a&amp;nbsp;BSP_EVENT_WHITELIST_OFF event. So basically all you have to do is call this function if you want any central to be allowed to connect.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE bonding</title><link>https://devzone.nordicsemi.com/thread/236191?ContentTypeID=1</link><pubDate>Tue, 25 Feb 2020 09:53:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e3ad0045-f522-4aa6-b446-228f06487a20</guid><dc:creator>Roei</dc:creator><description>&lt;p&gt;OK, thanks, you helped me a lot!&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Just one more question regarding&amp;nbsp;&lt;span style="background-color:transparent;color:#11171a;float:none;font-family:&amp;#39;GT Eesti&amp;#39;,&amp;#39;Helvetica&amp;#39;,Arial,sans-serif;font-size:14px;font-style:normal;font-weight:400;letter-spacing:normal;line-height:21px;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;"&gt;whitelisting -&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background-color:transparent;color:#11171a;float:none;font-family:&amp;#39;GT Eesti&amp;#39;,&amp;#39;Helvetica&amp;#39;,Arial,sans-serif;font-size:14px;font-style:normal;font-weight:400;letter-spacing:normal;line-height:21px;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;"&gt;When I don&amp;#39;t want to advertise with whitelist, I just don&amp;#39;t use&amp;nbsp;pm_whitelist_set and&amp;nbsp;pm_device_identities_list_set functions. Is that the right way? Or should I set a disabled flag to be sure that the advertising will be clean from whitelist?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE bonding</title><link>https://devzone.nordicsemi.com/thread/236161?ContentTypeID=1</link><pubDate>Tue, 25 Feb 2020 08:40:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e25743c3-ab57-4c1e-aa8b-19179a211cc8</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user="Roei"]I will be more specific. My use case is that I want to connect and bond my NRF device with my mobile. After turning off and on the device and mobile, I want them to connect again.[/quote]
&lt;p&gt;That makes sense.&lt;/p&gt;
[quote user="Roei"]Until now, I did it with direct advertising. I saved the mobile&amp;#39;s address after bonding when they first connected, so I will use it for direct advertising when my NRF device is turned on again.[/quote]
&lt;p&gt;You should not use directed advertising against mobile phones. Apple explicitly states that it should not be used. Since you use directed advertising I assume you only want the bonded pone to be allowed to connect. The normal way of achieving this is by using whitelisting. With that concept, you will advertise normally, but connections from non-whitelisted devices will be ignored. You can refer to for instance the &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v16.0.0/ble_sdk_app_cts_c.html"&gt;Current Time Application&lt;/a&gt;&amp;nbsp;to see an example of whitelisting.&lt;/p&gt;
[quote user="Roei"]The problem is that my mobile changes it&amp;#39;s address. I read some articles about that privacy feature. Do you know that?[/quote]
&lt;p&gt;All modern smartphones changes address regularly to avoid being tracked. This is done by deriving the MAC address form an identity resolving key (IRK), and the address is then called a&amp;nbsp;Resolvable Private Address (RPA). As long as you have bonded your peripheral device also has this IRK and can use it for whitelisting. This is all implemented for you in the nRF5 SDK (and in HW which does the address resolution for you), so you do not need to think much about it other than knowing the concepts.&lt;/p&gt;
[quote user="Roei"]What can I do about that? How can I reconnect to a mobile which changed it&amp;#39;s address?[/quote]
&lt;p&gt;Use bonding and whitelisting as I have suggested above.&lt;/p&gt;
&lt;p&gt;I notice that all of these questions are general BLE questions, so it might be worth spending some hours reading up on BLE before proceeding. I suspect that could save you some work in the long run. If you like to get such information from books, then I could recomend &lt;a href="http://shop.oreilly.com/product/0636920033011.do"&gt;Getting Started with Bluetooth Low Energy&lt;/a&gt;. It does not cover all the recent additions to the Bluetooth specification, but all the basics are explained in a good and simple way.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE bonding</title><link>https://devzone.nordicsemi.com/thread/236154?ContentTypeID=1</link><pubDate>Tue, 25 Feb 2020 08:26:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ed637967-7e2f-47e1-babe-b793c2595c54</guid><dc:creator>Roei</dc:creator><description>&lt;p&gt;Thanks for your answer!&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I will be more specific. My use case is that I want to connect and bond my NRF device with my mobile. After turning off and on the device and mobile, I want them to connect again.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Until now, I did it with direct advertising. I saved the mobile&amp;#39;s address after bonding when they first connected, so I will use it for direct advertising when my NRF device is turned on again.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The problem is that my mobile changes it&amp;#39;s address. I read some articles about that privacy feature. Do you know that?&lt;/p&gt;
&lt;p&gt;What can I do about that? How can I reconnect to a mobile which changed it&amp;#39;s address?&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: BLE bonding</title><link>https://devzone.nordicsemi.com/thread/236145?ContentTypeID=1</link><pubDate>Tue, 25 Feb 2020 08:04:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f97bb61c-3786-4bc9-abd9-9e5e6f9cd127</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user=""]As far as I understand, every connection establishment has to start with advertising.[/quote]
&lt;p&gt;Yes, that is correct. This is a key concept of the BLE protocol. The peripheral advertises regularly, and in case of connected advertising, it will switch the radio to Rx and listen for connection requests from a central in a short window after transmitting the advertising packet. This is how BLE connections are established.&lt;/p&gt;
&lt;p&gt;[quote user=""][/quote]&lt;/p&gt;
&lt;p&gt;Event if I have already connected and bonded to a peer, after disconnection I have to start advertising in order to connect to this peer again.&lt;/p&gt;
&lt;p&gt;Am I right?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Yes pairing and bonding is independent of the connection mechanism.&lt;/p&gt;
[quote user=""]In that case - what is the meaning of bonding here? Shouldn&amp;#39;t the peers connect automatically again without advertising/direct advertising?[/quote]
&lt;p&gt;No, that would not be possible. When the peripheral is not advertising or in a connection it is typically in sleep, with the radio completely turned off. So there would be no way to connect to it. Pairing is a completely different concept, which is how devices exchange encryption keys (used both for encrypting the link and optionally randomizing the address to that it cannot be tracked even though it advertises). Bonding is the same thing, the only difference is that when bonding, the peers agree to store the keys to be used for later.&lt;/p&gt;
[quote user=""]Do I have another option?[/quote]
&lt;p&gt;Not really. Dependign on your use case you may not need to bond, but there is no way around advertising to initiate a connection, regardless of if bonded or not.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>