<?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>Legacy Pairing/Bonding problem, pc-ble-driver, NRF52, central</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/82794/legacy-pairing-bonding-problem-pc-ble-driver-nrf52-central</link><description>I currently need to solve pairing/bonding to be able to implement DFU with the buttonless bonded bootloader. So I need to handle bonding/pairing from my central device, controlled using pc-ble-driver (and connectivity firmware SD 140, v6.1.1). The project</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 20 Dec 2021 08:22:33 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/82794/legacy-pairing-bonding-problem-pc-ble-driver-nrf52-central" /><item><title>RE: Legacy Pairing/Bonding problem, pc-ble-driver, NRF52, central</title><link>https://devzone.nordicsemi.com/thread/344261?ContentTypeID=1</link><pubDate>Mon, 20 Dec 2021 08:22:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:daf16563-442a-46b8-9e32-002ebda603f4</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Excellent! Thanks for the update, I&amp;#39;m glad to hear that it works now &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Legacy Pairing/Bonding problem, pc-ble-driver, NRF52, central</title><link>https://devzone.nordicsemi.com/thread/344126?ContentTypeID=1</link><pubDate>Fri, 17 Dec 2021 11:03:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cd10b964-1119-4a19-be15-9482a0cf70af</guid><dc:creator>Thomas Hoppe</dc:creator><description>&lt;p&gt;Solved it!&lt;/p&gt;
&lt;p&gt;Not sure why, but I&amp;#39;ve called sd_ble_gap_encrypt() using the &amp;#39;own&amp;#39; keyset instead of &amp;#39;peer&amp;#39;. After fixing this, I&amp;#39;m now able to create a secure connection every time and subscribing to the DFU - Char is possible.&lt;/p&gt;
&lt;p&gt;Many thanks for your support Vidar. Wish you all the best &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Legacy Pairing/Bonding problem, pc-ble-driver, NRF52, central</title><link>https://devzone.nordicsemi.com/thread/344102?ContentTypeID=1</link><pubDate>Fri, 17 Dec 2021 09:38:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dfd26e6e-44e1-4789-8b1a-167a9e5c671e</guid><dc:creator>Thomas Hoppe</dc:creator><description>&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/ws_2D00_sniffs.7z"&gt;devzone.nordicsemi.com/.../ws_2D00_sniffs.7z&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Of course. These are the sniffs used in the screenshots above.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Legacy Pairing/Bonding problem, pc-ble-driver, NRF52, central</title><link>https://devzone.nordicsemi.com/thread/344088?ContentTypeID=1</link><pubDate>Fri, 17 Dec 2021 08:56:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9653f7c6-43d5-4099-bd25-3c5234888d8d</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hm, does all packets following encryption start in the first connection and subsequent connections have the wrong mic? The sniffer should be able to decrypt the packets when using legacy pairing: &lt;span class="item"&gt;&lt;a class="" title="Sniffing a connection between bonded devices" href="https://infocenter.nordicsemi.com/topic/ug_sniffer_ble/UG/sniffer_ble/action_bonded.html?cp=10_5_5_4"&gt;Sniffing a connection between bonded devices&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="item"&gt;Are you able to to upload the sniffer file here?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Legacy Pairing/Bonding problem, pc-ble-driver, NRF52, central</title><link>https://devzone.nordicsemi.com/thread/344078?ContentTypeID=1</link><pubDate>Fri, 17 Dec 2021 08:38:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5b1f9b2f-3323-43f6-836c-3bfc69a21a88</guid><dc:creator>Thomas Hoppe</dc:creator><description>&lt;p&gt;I&amp;#39;ve sniffed both the initial bond and the reconnect case. When doing the initial bond, data is encrypted when I start to discover services (after calling sd_ble_gap_authenticate()), while in the reconnect case, the discovery part is unencrypted (as you mention).&lt;/p&gt;
&lt;p&gt;The image below shows the section when I try to reconect. If I understand correctly, LL_ENC_REQ is triggered by the call to sd_ble_encrypt(). Comparing the information from VS debugger with the sniffed data, the master id is sent correctly (red arrows).&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/1280x960/__key/communityserver-discussions-components-files/4/recon_2D00_fail.png" /&gt;&lt;/p&gt;
&lt;p&gt;Following the response from the peripheral (LL_ENC_RSP).&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/1280x480/__key/communityserver-discussions-components-files/4/resp.png" /&gt;&lt;/p&gt;
&lt;p&gt;For completeness, finally the log from the previous bonding:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/1280x960/__key/communityserver-discussions-components-files/4/0447.bond.png" /&gt;&lt;/p&gt;
&lt;p&gt;I&amp;#39;m not sure if this is helpful.&lt;/p&gt;
&lt;p&gt;Anyway, if the key that I use calling sd_ble_encrypt() would be corrupt, wouldn&amp;#39;t this not totally fail? As said, I still got security_mode=1, level=1 from&amp;nbsp;&lt;span&gt;BLE_GAP_EVT_CONN_SEC_UPDATE. I expect this wouldn&amp;#39;t be the case using a corrupted key.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Legacy Pairing/Bonding problem, pc-ble-driver, NRF52, central</title><link>https://devzone.nordicsemi.com/thread/343964?ContentTypeID=1</link><pubDate>Thu, 16 Dec 2021 14:45:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8f4d94c2-9be2-4790-a1db-fb1ca675c8bf</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Level 1 means the link did not get encrypted or authenticated, which explains why you are unable to enable subscribe to the DFU characteristic. The question is why. I obviously can&amp;#39;t tell if the encryption key is correct just by looking at it. The lesc and auth bits are set correctly at least.&lt;/p&gt;
&lt;p&gt;Here is what I get for comparison when testing on a dev kit :&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1639665262081v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;One way to troubleshoot this further is to capture a sniffer trace of the bonding exchange + the reconnect where you try to encrypt the link again. You can use our &lt;a href="https://www.nordicsemi.com/Products/Development-tools/nRF-Sniffer-for-Bluetooth-LE"&gt;nRF Sniffer for Bluetooth LE&lt;/a&gt; if you have an extra devkit or nRF52840 Dongle laying around.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Legacy Pairing/Bonding problem, pc-ble-driver, NRF52, central</title><link>https://devzone.nordicsemi.com/thread/343903?ContentTypeID=1</link><pubDate>Thu, 16 Dec 2021 12:50:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c1486971-f52a-47ec-8327-771e85cf1792</guid><dc:creator>Thomas Hoppe</dc:creator><description>&lt;p&gt;Thanks again Vidar. I&amp;#39;m now a little bit further. In case I found a stored key to the newly connected device, I call sd_ble_gap_encrypt() using the keyset: own/p_enc_key pair (received from&amp;nbsp;BLE_GAP_EVT_AUTH_STATUS after bonding).&lt;/p&gt;
&lt;p&gt;But subscription to the DFU characteristic still fails in this case.&lt;/p&gt;
&lt;p&gt;Not sure if this is important. When receiving&amp;nbsp;BLE_GAP_EVT_CONN_SEC_UPDATE I got two different security levels:&lt;/p&gt;
&lt;p&gt;Initial bond/sd_ble_gap_authenticate(): security_mode=1,&lt;span style="color:#008000;"&gt; level=2&lt;/span&gt;, key_size=16 -&amp;gt; DFU Char subscription&amp;nbsp;success&lt;/p&gt;
&lt;p&gt;Reconnect/sd_ble_gap_encrypt(): security_mode=1,&lt;span style="color:#ff6600;"&gt; level=1&lt;/span&gt;, key_size=0 -&amp;gt; DFU Char subscription fails (&lt;span&gt;BLE_GATT_STATUS_ATTERR_INSUF_AUTHENTICATION)&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Just in case this may be useful, here&amp;#39;s the call to sd_ble_gap_encrypt() in the debugger. The key may be valid .. (it&amp;#39;s a list not 0x00, 0x00, ..).&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/1280x960/__key/communityserver-discussions-components-files/4/sd_5F00_ble_5F00_gap_5F00_encrypt.png" /&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;PS: I took another look into how pc-nrfutil is able to subscribe to this characteristic (&lt;a href="https://github.com/NordicSemiconductor/pc-nrfutil/blob/af139f1fa2e511c9bf378eff00049d8bb69b8a15/nordicsemi/dfu/dfu_transport_ble.py"&gt;https://github.com/NordicSemiconductor/pc-nrfutil/blob/af139f1fa2e511c9bf378eff00049d8bb69b8a15/nordicsemi/dfu/dfu_transport_ble.py&lt;/a&gt;)&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;After connecting and service discovery, and if the bonded DFU char is present, it jumps to&amp;nbsp; &lt;span class="pl-en"&gt;&lt;span class="pl-token"&gt;jump_from_buttonless_mode_to_bootloader() (from line 164), where it calls bond() (line 199) in any case. In there, a call to sd_ble_gap_authenticate() (line 325) seems to be called every time, independent if a previous bonding was successfully done or not .. and this must be responed with success (line 334). After that, the char is subscribed (line 206). sd_ble_encrypt() (line 168) is started after the device has rebooted into DFU mode.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span class="pl-en"&gt;&lt;span class="pl-token"&gt;I&amp;#39;m still really confused :)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Legacy Pairing/Bonding problem, pc-ble-driver, NRF52, central</title><link>https://devzone.nordicsemi.com/thread/343719?ContentTypeID=1</link><pubDate>Wed, 15 Dec 2021 15:12:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0f0c7b8d-b2a0-4a6f-b1c9-776cf2464284</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Sorry, I misread your description. My answer was based on the assumption that you also got the error on the first connection, even though you were pretty clear on this.&lt;/p&gt;
&lt;p&gt;What you want to do on re-connect is to secure the connection with the previously exchanged encryption key by calling sd_ble_gap_encrypt() , not send a new bond request.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;This procedure to encrypt the connection with an existing key is illustrated by the message sequence chart here: &lt;span class="item"&gt;&lt;a class="" title="Encryption Establishment using stored keys" href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s140.api.v6.1.1/group___b_l_e___g_a_p___c_e_n_t_r_a_l___e_n_c___m_s_c.html?cp=4_7_4_4_2_1_3_5_3"&gt;Encryption Establishment using stored keys&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="item"&gt;Best regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="item"&gt;Vidar&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Legacy Pairing/Bonding problem, pc-ble-driver, NRF52, central</title><link>https://devzone.nordicsemi.com/thread/343699?ContentTypeID=1</link><pubDate>Wed, 15 Dec 2021 14:41:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7068d9bb-a411-45f6-9ecb-7b9999a4ad95</guid><dc:creator>Thomas Hoppe</dc:creator><description>&lt;p&gt;Hello Vidar,&lt;/p&gt;
&lt;p&gt;thanks for your fast response.&lt;/p&gt;
&lt;p&gt;Not sure, but I assume you talk about a different topic. My goal is not re-bonding using a new set of keys. I need a valid connection to be able to subscribe to the mentioned characteristic.&lt;/p&gt;
&lt;p&gt;After closing the connection (with the initial bond) and connecting again (with just sd_ble_gap_connect()), my subscription fails. I didn&amp;#39;t get any event to supply my previously stored key. So I assume I miss something to call after the connection is established.&lt;/p&gt;
&lt;p&gt;My (simplified) call order (with initial bonding):&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;sd_ble_gap_connect() .. wait for event.&lt;/li&gt;
&lt;li&gt;sd_ble_gap_authenticate(bond) .. wait for event.&lt;/li&gt;
&lt;li&gt;sd_ble_gap_sec_params_reply() .. wait for event, got bonding keys, store them&lt;/li&gt;
&lt;li&gt;[discover services, characteristics, desciptors ] ..&lt;/li&gt;
&lt;li&gt;subscribe to&amp;nbsp;&lt;span&gt;BLE_DFU_BUTTONLESS_BONDED_CHAR_UUID&lt;/span&gt;&lt;span&gt;&amp;nbsp;-&amp;gt; &lt;span style="color:#008000;"&gt;success&lt;/span&gt;.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;..&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;close connection&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span&gt;Do the same while without removing previous bonding information:&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;sd_ble_gap_connect() .. wait for event.&lt;/li&gt;
&lt;li&gt;Got async&amp;nbsp;&lt;span&gt;BLE_GAP_EVT_SEC_REQUEST, how to respond?&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;?What to do at this point? How to supply my stored key? Calls to sd_ble_gap_authenticate() fail, so I assume they are wrong here, but I don&amp;#39;t wan&amp;#39;t to re-bond, just get a &amp;#39;bonded&amp;#39; connection as required by this characteristic -&amp;gt; &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/service_dfu.html"&gt;https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/service_dfu.html&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;[discover services, characteristics, desciptors ] ..&lt;/li&gt;
&lt;li&gt;subscribe to&amp;nbsp;&lt;span&gt;BLE_DFU_BUTTONLESS_BONDED_CHAR_UUID&lt;/span&gt;&lt;span&gt;&amp;nbsp;-&amp;gt; &lt;span style="color:#ff6600;"&gt;fails&lt;/span&gt;. Bonding/Pairing not active?&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span&gt;I hope you understand my problem.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thank you again,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thomas&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Legacy Pairing/Bonding problem, pc-ble-driver, NRF52, central</title><link>https://devzone.nordicsemi.com/thread/343640?ContentTypeID=1</link><pubDate>Wed, 15 Dec 2021 12:51:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:de24c137-0b60-4711-a03f-635bd1aa8ffa</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hello Thomas,&lt;/p&gt;
&lt;p&gt;The peer manager on the peripheral will by default reject bonding requests from a previously bonded peer, so this is likely why you get the &lt;span style="color:rgba(0, 0, 255, 1);"&gt;BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP&lt;/span&gt; status in response to your request. I explained how you can configure the Peer manager to accept bond updates in my post here: &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/51965/pairing-and-bonding-after-deleting-synchronization/208927#208927"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/51965/pairing-and-bonding-after-deleting-synchronization/208927#208927&lt;/a&gt;. The other option is to delete the bond on the DFU target before you initiate DFU.&lt;/p&gt;
[quote user=""]&lt;span style="color:rgba(255, 102, 0, 1);"&gt;A second question:&lt;/span&gt; Does the connectivity firmware store the bonding keys on device site too? This question is centered about the usability. If I connect my central device to a different host PC and try to connect to an already bonded peripheral, does the central know the bonding keys (e.g. stored in flash) or do I have to copy my host site keystore to the new host (and supply them when receiving &lt;span style="color:rgba(0, 0, 255, 1);"&gt;BLE_GAP_EVT_SEC_REQUEST&lt;span style="color:rgba(0, 0, 0, 1);"&gt;)&lt;/span&gt;&lt;/span&gt;?[/quote]
&lt;p&gt;The host (pc-ble-driver app in this case) is responsible for the key storage. The connectivity FW does not store anything to flash. &lt;/p&gt;
&lt;p&gt;If anything is unclear, let me know.&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>