<?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 to initiate BLE pairing manually</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/86794/how-to-initiate-ble-pairing-manually</link><description>Hello, 
 
 I&amp;#39;m running nRF Connect SDK v1.9.0 on two nRF52840-DK devices, one Peripheral other Central. 
 My application requires to initiate pairing, i.e. send pair request, programmatically. 
 
 For testing, I created a Peripheral device with a Service</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 29 Jun 2026 01:03:27 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/86794/how-to-initiate-ble-pairing-manually" /><item><title>RE: How to initiate BLE pairing manually</title><link>https://devzone.nordicsemi.com/thread/568509?ContentTypeID=1</link><pubDate>Mon, 29 Jun 2026 01:03:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:abcaf552-5069-455e-a149-1dfb4ac2337d</guid><dc:creator>Phil</dc:creator><description>&lt;p&gt;I set the security level in the Central instead of in the Peripheral when the connection is established.&amp;nbsp; Function&amp;nbsp;&lt;span&gt;bt_conn_set_security() is called from the connected() callback via a kwork item.&lt;br /&gt;&lt;br /&gt;I&amp;#39;ve been testing this with both devices not bonded to anything.&amp;nbsp; I erase the bond information each time before testing.&lt;br /&gt;&lt;br /&gt;The two devices pair and then bond reliably when they connect.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;I also set the security level of our custom characteristics in the peripheral.&amp;nbsp; That way when the phone connects with nRF Connect, the phone will initiate pairing and bonding when it attempts to read that characteristic.&amp;nbsp; This is also reliable.&amp;nbsp;&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Thanks for your advice.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to initiate BLE pairing manually</title><link>https://devzone.nordicsemi.com/thread/568463?ContentTypeID=1</link><pubDate>Fri, 26 Jun 2026 06:55:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5d3e7c71-6cec-45b1-9ac7-95f3ae08561f</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Thanks for the update. Default behaviour is that the peripheral will reject a pairing request from an already bonded peer device. You can change this by enabling&amp;nbsp;the CONFIG_SMP_ALLOW_OVERWRITE setting, but as indicated in the help text, it has some security implications that should be considered.&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1782456919252v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to initiate BLE pairing manually</title><link>https://devzone.nordicsemi.com/thread/568461?ContentTypeID=1</link><pubDate>Fri, 26 Jun 2026 06:43:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7b90f153-10b5-45df-8bb6-af3130a351a4</guid><dc:creator>Phil</dc:creator><description>&lt;p&gt;Thanks for your reply.&lt;br /&gt;&lt;br /&gt;I have it working where the peripheral calls bt_conn_set_security() when the central connects to it.&lt;br /&gt;The Central and Peripheral both pair and bond..... most of the time.&lt;br /&gt;&lt;br /&gt;However, occassionally the pairing fails with an error code &amp;quot;Failed to set security level&amp;quot;.&amp;nbsp; The peripheral has bond information stored in NV memory, but the Central doesn&amp;#39;t.&lt;br /&gt;&lt;br /&gt;I&amp;#39;ll try it with the Central setting the security level on connection.&lt;/p&gt;
&lt;p&gt;It starts to make sense once you see things running.&amp;nbsp;Thanks for your help.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to initiate BLE pairing manually</title><link>https://devzone.nordicsemi.com/thread/568459?ContentTypeID=1</link><pubDate>Fri, 26 Jun 2026 05:59:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:75a81c92-a8fc-468c-b465-412389381a0b</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;When in the GAP Peripheral role, calling bt_conn_set_security() sends a security request, it will not initiate pairing like a central would. A security request sent immediately after connection is likely to be ignored by the central because it will&amp;nbsp;overlap with other important events. If you want to send a security request, it is generally good practice to wait a few seconds to see whether the central initiates pairing or encryption first. Only send the request if it does not.&lt;/p&gt;
&lt;p&gt;The linked sample is from the SDK.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to initiate BLE pairing manually</title><link>https://devzone.nordicsemi.com/thread/568449?ContentTypeID=1</link><pubDate>Thu, 25 Jun 2026 23:03:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:13506fb8-426c-45fa-8071-d27c438ea5c1</guid><dc:creator>Phil</dc:creator><description>&lt;p&gt;Vidar,&lt;/p&gt;
&lt;p&gt;Thanks for your reply.&amp;nbsp; I&amp;#39;ll try setting the security level in the Central by calling bt_conn_set_security() to trigger the pairing process.&lt;/p&gt;
&lt;p&gt;Is that example for SDK v3.3.0?&lt;br /&gt;&lt;br /&gt;I found in the code for the peripheral I could not call bt_conn_set_security() from the connected() call-back.&amp;nbsp; I mean I could call it but it didn&amp;#39;t do anything.&amp;nbsp; I had to use a kwork and call it from the kwork handler.&amp;nbsp; I presume this is because the connected() call-back is running in the BT stack, so is effectively running in an ISR.&lt;/p&gt;
&lt;p&gt;I found that calling bt_conn_set_security() in the peripheral as soon as it connected caused pairing to start as soon as my phone connects (using nRF Connect app).&amp;nbsp; &amp;nbsp;A Pairing Request window pops up on my phone.&amp;nbsp; However, it pops up twice.&amp;nbsp; It does pair and bond Ok.&amp;nbsp; This is without the phone trying to read/write any attributes.&amp;nbsp; It connects, pairs and does device discovery only.&amp;nbsp; Function bt_conn_set_security() is definitely called only once. Could the reason the pairing request pops up twice in the nRF Connect app be something to do with the phone (Android on Samsung Galaxy)?&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to initiate BLE pairing manually</title><link>https://devzone.nordicsemi.com/thread/568400?ContentTypeID=1</link><pubDate>Thu, 25 Jun 2026 07:41:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:77fde75c-7b51-451a-b87a-1a53e2f8b8e8</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;You can initiate the pairing process from the central by calling bt_conn_set_security() like in the central_uart sample here:&amp;nbsp;&lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/5aa13555aa18356ea4b47766d16aa3dfbd80b978/samples/bluetooth/central_bas/src/main.c#L152"&gt;https://github.com/nrfconnect/sdk-nrf/blob/5aa13555aa18356ea4b47766d16aa3dfbd80b978/samples/bluetooth/central_bas/src/main.c#L152&lt;/a&gt;. It is also important to change the&amp;nbsp;security requirement on your characteristics if you want to require the link to be encrypted before any data exchange (&lt;a href="https://academy.nordicsemi.com/courses/bluetooth-low-energy-fundamentals/lessons/lesson-5-bluetooth-le-security-fundamentals/topic/blefund-lesson-5-exercise-1/"&gt;https://academy.nordicsemi.com/courses/bluetooth-low-energy-fundamentals/lessons/lesson-5-bluetooth-le-security-fundamentals/topic/blefund-lesson-5-exercise-1/&lt;/a&gt;).&amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to initiate BLE pairing manually</title><link>https://devzone.nordicsemi.com/thread/568392?ContentTypeID=1</link><pubDate>Thu, 25 Jun 2026 00:54:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:41898d3d-6caf-4cd6-a42e-0c17c4d3774a</guid><dc:creator>Phil</dc:creator><description>&lt;p&gt;I have exactly the same issue.&lt;br /&gt;I&amp;#39;m running nRF Connect SDK v3.3.0 on two nRF54L15-DK boards, one Peripheral and one Central.&lt;br /&gt;When the Central is scanning and receives advertising from the peripheral, a button can be pressed on the Central to initiate a connection.The devices connect Ok in an unencrypted link.&lt;br /&gt;&lt;br /&gt;I want the devices to pair and bond,&amp;nbsp;or at least start the pairing process, automatically when the connection is established.&amp;nbsp;&lt;br /&gt;I assumed that when the Central gets a connected complete callback it could programatically initiate the pairing process by sending a pairing request.&amp;nbsp; However, I can&amp;#39;t find any documentation on how to do this.&lt;br /&gt;&lt;br /&gt;Is it only possible to automatically start the pairing process from the peripheral?&amp;nbsp;&amp;nbsp;&lt;br /&gt;Does the peripheral have to send a security request in order to trigger the Central to send a pairing request?&lt;br /&gt;&lt;br /&gt;We want to use pairing process &amp;quot;Just Works&amp;quot;, so there in no operator involvement during the pairing process.&amp;nbsp; Our central and peripheral devices are simple and only have a button and LED, no display or keyboard.&amp;nbsp; However we want the link encrypted and the devices to be bonded.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to initiate BLE pairing manually</title><link>https://devzone.nordicsemi.com/thread/366745?ContentTypeID=1</link><pubDate>Fri, 06 May 2022 13:19:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:45d9bb3e-8d21-46c4-b96b-470d030b3a6b</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;The MIC failures occur because the sniffer does not have the encryption key to decrypt the payload.&amp;nbsp; To be able to sniff LESC pairing you need to enable the debug DH keys: &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.9.1/kconfig/CONFIG_BT_USE_DEBUG_KEYS.html"&gt;https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.9.1/kconfig/CONFIG_BT_USE_DEBUG_KEYS.html&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to initiate BLE pairing manually</title><link>https://devzone.nordicsemi.com/thread/366554?ContentTypeID=1</link><pubDate>Thu, 05 May 2022 22:11:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:39dcd6bf-aae4-4022-adbd-233de824cafd</guid><dc:creator>ealtan</dc:creator><description>&lt;p&gt;I was using one Nordic nRF52840-DK in Peripheral mode and the other unit was another nRF52840-based module DK from another company.&amp;nbsp; So, I switched to two Nordic DKs and connection problems went away, so that&amp;#39;s good.&amp;nbsp; But pairing failures are still here, so I&amp;#39;ve put Nordic nRF52840 dongle with Wireshark capture in between.&amp;nbsp; &amp;nbsp;&lt;/p&gt;
&lt;p&gt;It seems like all is going well till when Slave responds with&amp;nbsp; LL_START_ENC_REQ and then I see all packets that are not empty PDU having &amp;quot;Encrypted packet decrypted incorrectly (bad MIC) &amp;quot; error.&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Any idea why these bad MIC errors might be happening ?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to initiate BLE pairing manually</title><link>https://devzone.nordicsemi.com/thread/365631?ContentTypeID=1</link><pubDate>Fri, 29 Apr 2022 15:24:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:25986786-4f9e-4e5d-afaa-8917b2cd9367</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;I don&amp;#39;t think there is much you can do in FW to improve chances for a connection attempt to succeed&amp;nbsp; except for increasing the Radio&amp;#39;s TX output power ( &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.9.1/zephyr/samples/bluetooth/hci_pwr_ctrl/README.html"&gt;example&lt;/a&gt; ). Default is 0 dBm and radio is supporting up to +8 dBm. But I&amp;#39;m surprised you don&amp;#39;t see this with the other board. Maybe the other board automatically repeats the connection attempt if it fails the first time? A Bluetooth &lt;a href="https://www.nordicsemi.com/Products/Development-tools/nRF-Sniffer-for-Bluetooth-LE"&gt;sniffer &lt;/a&gt;trace may help show what the problem is.&lt;/p&gt;
&lt;p&gt;You are still using 2 Nordic DKs for this test?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to initiate BLE pairing manually</title><link>https://devzone.nordicsemi.com/thread/365621?ContentTypeID=1</link><pubDate>Fri, 29 Apr 2022 14:56:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:463366df-98bb-4f45-96f2-968864864acd</guid><dc:creator>ealtan</dc:creator><description>&lt;p&gt;Yes, it is possible, however,&amp;nbsp; I repeat the test with another MCU vendor and I don&amp;#39;t have these connection and pairing issues.&amp;nbsp; &amp;nbsp;So, my question is,&amp;nbsp; what can I change to create a more robust connection and pairing operation ?&amp;nbsp; &amp;nbsp;For example, is there more info on these parameters ?&amp;nbsp; How do they affect connections ?&amp;nbsp; &amp;nbsp;:&amp;nbsp;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;/** Connection parameters for LE connections */&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;struct&lt;/span&gt;&lt;span&gt; bt_le_conn_param {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span&gt;uint16_t&lt;/span&gt;&lt;span&gt; interval_min;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span&gt;uint16_t&lt;/span&gt;&lt;span&gt; interval_max;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span&gt;uint16_t&lt;/span&gt;&lt;span&gt; latency;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span&gt;uint16_t&lt;/span&gt;&lt;span&gt; timeout;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;};&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; .options &lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span&gt; (_options), \&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; .interval &lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span&gt; (_interval), \&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; .window &lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span&gt; (_window), \&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; .interval_coded &lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;0&lt;/span&gt;&lt;span&gt;, \&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; .window_coded &lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;0&lt;/span&gt;&lt;span&gt;, \&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; .timeout &lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;0&lt;/span&gt;&lt;span&gt;, \&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to initiate BLE pairing manually</title><link>https://devzone.nordicsemi.com/thread/365585?ContentTypeID=1</link><pubDate>Fri, 29 Apr 2022 12:22:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:712923a8-8c88-4fbf-bae8-c86e8724358c</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Could it be the environment you are testing this in? BT_HCI_ERR_CONN_FAIL_TO_ESTABLISH will happen from time to time. It means the peripheral did not respond to the connect request (only one request is sent per connect attempt) and that the central have to retry. It is normal for this error to happen from time time, but it can also occur quite frequently if there is lots of noise or interference from other nearby sources, for instance, active scanning from other BLE devices.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to initiate BLE pairing manually</title><link>https://devzone.nordicsemi.com/thread/365420?ContentTypeID=1</link><pubDate>Thu, 28 Apr 2022 12:17:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:245328a5-0f82-440f-9040-76097ac3b2aa</guid><dc:creator>ealtan</dc:creator><description>&lt;p&gt;Thank you,&amp;nbsp; I did that, but overall pairing seems to be very unreliable.&amp;nbsp; Many times it fails with&amp;nbsp;unspecified&amp;nbsp; reason.&amp;nbsp; &amp;nbsp;&lt;/p&gt;
&lt;p&gt;But before that getting into details with pairing,&amp;nbsp; connections have been pretty undeterministic, too.&amp;nbsp; &amp;nbsp; I have a Central which&amp;nbsp;issues a connect to a Peripheral,&amp;nbsp; many times Central comes back with disconnected callback with reason&amp;nbsp; BT_HCI_ERR_CONN_FAIL_TO_ESTAB.&amp;nbsp; &amp;nbsp;So,&amp;nbsp; do you have any recommendations to make connections more reliable ?&amp;nbsp; Any parameters to tweak ?&amp;nbsp; &amp;nbsp;Why would it keep disconnecting with&amp;nbsp;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;BT_HCI_ERR_CONN_FAIL_TO_ESTAB reason ?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to initiate BLE pairing manually</title><link>https://devzone.nordicsemi.com/thread/365087?ContentTypeID=1</link><pubDate>Wed, 27 Apr 2022 06:53:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5b995a9b-69bf-4c42-ab5f-000a601280a3</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;I see. In that case you can add &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.9.1/kconfig/CONFIG_BT_BONDABLE.html"&gt;CONFIG_BT_BONDABLE&lt;/a&gt;=n to your project, or call &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.9.1/zephyr/reference/bluetooth/connection_mgmt.html#c.bt_set_bondable"&gt;bt_set_bondable(&amp;#39;false&amp;#39;)&lt;/a&gt; on startup.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to initiate BLE pairing manually</title><link>https://devzone.nordicsemi.com/thread/365045?ContentTypeID=1</link><pubDate>Tue, 26 Apr 2022 21:21:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0ef7a91f-2b0c-4b96-9197-a4f70071f971</guid><dc:creator>ealtan</dc:creator><description>[quote userid="4240" url="~/f/nordic-q-a/86794/how-to-initiate-ble-pairing-manually/364605#364605"]The other connections will be secured with the encryption key that was exchanged during pairing.[/quote]
&lt;p&gt;Is that because these two devices are bonded ?&amp;nbsp; &amp;nbsp; I don&amp;#39;t want them to be bonded,&amp;nbsp; I want to trigger and restart pairing process every time .&amp;nbsp; Is there a way of doing this ?&amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to initiate BLE pairing manually</title><link>https://devzone.nordicsemi.com/thread/364605?ContentTypeID=1</link><pubDate>Mon, 25 Apr 2022 07:29:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ac63b5c0-76a9-438b-84d3-ed152009eb1f</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Thanks for the clarification and sorry for delayed response. The reason you are not getting the pairing_complete callback on the subsequent connections is that the pairing procedure is only performed in the first connection. The other connections will be secured with the encryption key that was exchanged during pairing.&lt;/p&gt;
&lt;p&gt;You can register the &amp;quot;security changed&amp;quot; callback if you want to monitor when the link becomes secured in both cases (i.e. after pairing or encryption with existing keys):&lt;/p&gt;
&lt;p&gt;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.9.1/zephyr/reference/bluetooth/connection_mgmt.html#c.bt_conn_cb.security_changed"&gt;https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.9.1/zephyr/reference/bluetooth/connection_mgmt.html#c.bt_conn_cb.security_changed&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Here is how the callback is used in our central uart sample for reference: &lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/7848293244a0904cb401f13f420bf610d7aa8e91/samples/bluetooth/central_uart/src/main.c#L425"&gt;https://github.com/nrfconnect/sdk-nrf/blob/7848293244a0904cb401f13f420bf610d7aa8e91/samples/bluetooth/central_uart/src/main.c#L425&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to initiate BLE pairing manually</title><link>https://devzone.nordicsemi.com/thread/364065?ContentTypeID=1</link><pubDate>Thu, 21 Apr 2022 03:17:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b0495396-23b1-418e-a05b-4b9544ea0da1</guid><dc:creator>ealtan</dc:creator><description>&lt;p&gt;Thank you, Vidar,&amp;nbsp; &amp;nbsp;just one clarification,&amp;nbsp; I&amp;nbsp; initiate pairing from Central to Peripheral.&amp;nbsp; &amp;nbsp;By using bt_conn_set_security()&amp;nbsp; I can upgrade the security level and that causes&amp;nbsp; pairing_complete callback to be called.&amp;nbsp; So, that&amp;#39;s good, thank you.&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;But I have a new issue.&amp;nbsp; I have a test suite that I&amp;#39;m running in a loop : Central connects to a Peripheral, Central initiates pairing,&amp;nbsp; pairing successfully completes,&amp;nbsp; Central does some characteristics&amp;nbsp; read/write and then disconnects.&amp;nbsp; This process is run in a loop.&amp;nbsp; &amp;nbsp;My problem is, after the first run,&amp;nbsp; pairing never completes, ie&amp;nbsp; I never see pairing_complete callback being&amp;nbsp; called.&amp;nbsp; &amp;nbsp;So I&amp;#39;m guessing that I need to do something else to clear old pairing info.&amp;nbsp; Any idea how I can do that ?&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Many thanks,&lt;/p&gt;
&lt;p&gt;E.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to initiate BLE pairing manually</title><link>https://devzone.nordicsemi.com/thread/362833?ContentTypeID=1</link><pubDate>Mon, 11 Apr 2022 11:49:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4f863a47-04cd-4bf0-a7b4-622bb9309ff1</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;It is generally recommended to let the central initiate the pairing request, or at least, give it a chance to send it first. From the &amp;quot;&lt;a href="https://developer.apple.com/accessories/Accessory-Design-Guidelines.pdf"&gt;Accessory Design&lt;/a&gt;&lt;br /&gt;&lt;a href="https://developer.apple.com/accessories/Accessory-Design-Guidelines.pdf"&gt;Guidelines for Apple Devices&lt;/a&gt;&amp;quot; document:&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;em&gt;40.10 Pairing&lt;/em&gt;&lt;br /&gt;&lt;em&gt;The accessory should not request pairing until an ATT request is rejected using the Insufficient&lt;/em&gt;&lt;br /&gt;&lt;em&gt;Authentication error code. See the Bluetooth 4.0 specification, Volume 3, Part F, Section 4 for details.&lt;/em&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;br /&gt;&lt;em&gt;If, for security reasons, the accessory requires a bonded relationship with the Central, the Peripheral&lt;/em&gt;&lt;br /&gt;&lt;em&gt;should reject the ATT request using the Insufficient Authentication error code, as appropriate. As a&lt;/em&gt;&lt;br /&gt;&lt;em&gt;result, the device may proceed with the necessary security procedures.&lt;/em&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;em&gt;Similarly, if the device acts as a Central and a GATT server, it may reject an ATT request using the&lt;/em&gt;&lt;br /&gt;&lt;em&gt;Insufficient Authentication error code. The accessory should initiate the security procedure for pairing&lt;/em&gt;&lt;br /&gt;&lt;em&gt;in response.&lt;/em&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;br /&gt;&lt;em&gt;Pairing may require user authorization depending on device. Once an accessory is paired with a device,&lt;/em&gt;&lt;br /&gt;&lt;em&gt;it shall retain the distributed keys of both central and peripheral for future use. If the pairing is no longer&lt;/em&gt;&lt;br /&gt;&lt;em&gt;required, the accessory shall delete both sets of keys.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;The Insufficient Authentication error code is returned when the GATT client tries to read a characteristic that has the security level set to a level that requires authentication. The user will automatically get a pairing popup if they use iOS.&lt;/p&gt;
&lt;p&gt;Characteristic read and write permissions (i.e. security level) is configured when you initialize the service. Like here for the HIDS service: &lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/35f91d3151abfaddf60d826ed87c91cfa81773a5/subsys/bluetooth/services/hids.c#L751"&gt;https://github.com/nrfconnect/sdk-nrf/blob/35f91d3151abfaddf60d826ed87c91cfa81773a5/subsys/bluetooth/services/hids.c#L751&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;But to answer your question, it should be possible to issue a security request from the peripheral by calling the &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.9.1/zephyr/reference/bluetooth/connection_mgmt.html#c.bt_conn_set_security"&gt;bt_conn_set_security()&lt;/a&gt; function, or by enabling the &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.9.1/kconfig/CONFIG_BT_GATT_AUTO_SEC_REQ.html"&gt;CONFIG_BT_GATT_AUTO_SEC_REQ&lt;/a&gt; option.&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>