<?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>Secure BLE connections in nrf52833</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/87268/secure-ble-connections-in-nrf52833</link><description>Hi All, 
 Hope everyone is fine. 
 I&amp;#39;m using Vs code with nrf Connect sdk v1.9.1 to develope firmware for nrf52833. 
 Here our device has no display or Keyboard to give input. I want to achieve pairing with external mobile application ex. nrf connect</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 27 Apr 2022 07:09:19 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/87268/secure-ble-connections-in-nrf52833" /><item><title>RE: Secure BLE connections in nrf52833</title><link>https://devzone.nordicsemi.com/thread/365093?ContentTypeID=1</link><pubDate>Wed, 27 Apr 2022 07:09:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a233b0f7-c9e7-42ca-84cb-b495566be6cd</guid><dc:creator>viswa</dc:creator><description>&lt;p&gt;Hi Hung&lt;/p&gt;
&lt;p&gt;I haven&amp;#39;t tried you example as it is...but added those parts you mentioned into my code. I will try to build the example you shared and check it.&lt;/p&gt;
&lt;p&gt;When mobile tries to connect, there should be some api to respond to that request, what is this api?&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve come across this pairing_accept() from Zephyr Documention, which I see no where used in peripheral_sc_only sample and example you provided.&lt;/p&gt;
&lt;p&gt;&lt;span&gt;This function returns following structure.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;struct&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;bt_conn_pairing_feat&lt;/span&gt;&lt;span&gt; *&lt;/span&gt;&lt;span&gt;const&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;feat&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Does this have anything to do pairing success?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Secure BLE connections in nrf52833</title><link>https://devzone.nordicsemi.com/thread/365091?ContentTypeID=1</link><pubDate>Wed, 27 Apr 2022 07:06:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0cd1d9be-7f27-4fce-85ee-2ffef4df4c6f</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Have&amp;nbsp;you tested with the example I provided ?&amp;nbsp;&lt;br /&gt;Please make sure you erase the chip and remove bond on the phone.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Secure BLE connections in nrf52833</title><link>https://devzone.nordicsemi.com/thread/365073?ContentTypeID=1</link><pubDate>Wed, 27 Apr 2022 04:22:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fe90319e-967e-41a6-86e5-661788b7622d</guid><dc:creator>viswa</dc:creator><description>&lt;p&gt;Hi Hung Bui&lt;/p&gt;
&lt;p&gt;I have tried to add&amp;nbsp;&lt;/p&gt;
[quote userid="2121" url="~/f/nordic-q-a/87268/secure-ble-connections-in-nrf52833/364931#364931"]use&amp;nbsp;&lt;span&gt;BT_GATT_PERM_READ_ENCRYPT&lt;/span&gt;[/quote]
&lt;p&gt;and removed the below code from callback.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;if (bt_conn_set_security(conn, BT_SECURITY_L2)) {
		printf(&amp;quot;Failed to set security\n&amp;quot;);
	}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Then, it will connect directly without pairing and when I try read ccc characteristic then mobile app starts bonding process, still I get the same timeout response as I got earlier.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Secure BLE connections in nrf52833</title><link>https://devzone.nordicsemi.com/thread/364931?ContentTypeID=1</link><pubDate>Tue, 26 Apr 2022 11:26:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:57ba7582-f1ce-416d-9ebd-0a09e08ee6ba</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Viswa,&amp;nbsp;&lt;br /&gt;I don&amp;#39;t think calling&amp;nbsp;bt_conn_set_security() from the peripheral is a good idea. The better way is as mentioned, change the permission of the characteristic. But i need to correct my self, you should use&amp;nbsp;&lt;span&gt;BT_GATT_PERM_READ_ENCRYPT instead of&amp;nbsp;BT_GATT_PERM_READ_AUTHEN.&amp;nbsp;&lt;br /&gt;BT_GATT_PERM_READ_AUTHEN is used when you have keyboard, display.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I attached here an example that I modified the peripheral_ht so that when you enable indication on the characteristic it will require the central to bond.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/6443.peripheral_5F00_ht_5F00_smp.zip"&gt;devzone.nordicsemi.com/.../6443.peripheral_5F00_ht_5F00_smp.zip&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Please notice how the hts.c file is modified:&amp;nbsp;&lt;br /&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1650972510084v3.png" alt=" " /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Secure BLE connections in nrf52833</title><link>https://devzone.nordicsemi.com/thread/364900?ContentTypeID=1</link><pubDate>Tue, 26 Apr 2022 10:14:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0348ed0b-9945-428b-9ae3-d065b3b94289</guid><dc:creator>viswa</dc:creator><description>[quote userid="2121" url="~/f/nordic-q-a/87268/secure-ble-connections-in-nrf52833/364688#364688"] This mean your device should have at least display or keyboard capability.[/quote]
&lt;p&gt;Our device has no dedicated Keyboard / Display.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I have commented &amp;quot;&lt;span&gt;CONFIG_BT_SMP_SC_ONLY&lt;/span&gt;&lt;span&gt;=y&amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/* Callback I&amp;#39;ve selected for secure connections */ 

static struct bt_conn_auth_cb auth_cb_display = {
	.passkey_display = auth_passkey_display,
	.passkey_entry = NULL,
	.cancel = auth_cancel,
	.pairing_complete = pairing_complete,
	.pairing_failed = pairing_failed,
}; 

/* Inside Connection callback */
if (bt_conn_set_security(conn, BT_SECURITY_L2)) {
		printf(&amp;quot;Failed to set security\n&amp;quot;);
	}&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;for above code I got below response, what shall I add in configuration to get legacy pairing.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;W: opcode 0x200a status 0x09

Connected: 00:00:00:00:00:00 (public)
E: SMP Timeout

Security failed: 63:67:23:18:43:74 (random) level 1 err 9
Pairing Failed (9). Disconnecting.
{Disconnected (reason: 22)}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Secure BLE connections in nrf52833</title><link>https://devzone.nordicsemi.com/thread/364822?ContentTypeID=1</link><pubDate>Tue, 26 Apr 2022 07:14:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:99dc98c6-df53-4a78-9195-8ffb10948e1d</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Sarma,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Most of our sample support pairing. For example&amp;nbsp;\zephyr\samples\bluetooth\peripheral_hr&amp;nbsp; sample or \nrf\samples\bluetooth\peripheral_hids_mouse sample.&amp;nbsp;&lt;br /&gt;They don&amp;#39;t require the peer device to bond but they can support if the peer device (the phone) request to bond/pair.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you want to request the peer device to bond you would need to configure the characteristic so that it require encryption. You can do that by configuring the permission of the characteristic, for example change from&amp;nbsp;&lt;span&gt;BT_GATT_PERM_READ&lt;/span&gt; to &lt;span&gt;BT_GATT_PERM_READ_AUTHEN.&amp;nbsp;&lt;br /&gt;&lt;/span&gt;You can read about that &lt;a href="https://devzone.nordicsemi.com/guides/nrf-connect-sdk-guides/b/software/posts/building-a-ble-application-on-ncs-comparing-and-contrasting-to-softdevice-based-ble-applications#mcetoc_1elnnim8t3"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;In addition to support storing bond information, in addition to&amp;nbsp;CONFIG_BT_SMP=y the following configuration needed:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;CONFIG_BT_SETTINGS=y&lt;/span&gt;&lt;br /&gt;&lt;span&gt;CONFIG_FLASH=y&lt;/span&gt;&lt;br /&gt;&lt;span&gt;CONFIG_FLASH_PAGE_LAYOUT=y&lt;/span&gt;&lt;br /&gt;&lt;span&gt;CONFIG_FLASH_MAP=y&lt;/span&gt;&lt;br /&gt;&lt;span&gt;CONFIG_NVS=y&lt;/span&gt;&lt;br /&gt;&lt;span&gt;CONFIG_SETTINGS=y&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: Secure BLE connections in nrf52833</title><link>https://devzone.nordicsemi.com/thread/364802?ContentTypeID=1</link><pubDate>Tue, 26 Apr 2022 05:18:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:400527e0-e9f7-4702-9540-90b4628a2f70</guid><dc:creator>viswa</dc:creator><description>&lt;p&gt;Hi Hung Bui&lt;/p&gt;
[quote userid="2121" url="~/f/nordic-q-a/87268/secure-ble-connections-in-nrf52833/364688#364688"]You can do normal legacy pairing, or doing Secure Connection with justwork[/quote]
&lt;p&gt;May I know config/security levels to acheive that?&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;
&lt;p&gt;Visweswara Sarma.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Secure BLE connections in nrf52833</title><link>https://devzone.nordicsemi.com/thread/364688?ContentTypeID=1</link><pubDate>Mon, 25 Apr 2022 11:24:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d9e663e4-0076-4f13-be8a-c490423b82ef</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Viswa,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;As you already find out, the example only allow SC pairing at security level 4. This mean your device should have at least display or keyboard capability.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;However, error 8 means&amp;nbsp; &amp;quot;BT_SECURITY_ERR_KEY_REJECTED&amp;quot; this mean your device may have paired with the phone earlier but one of the device has erased this bond information. Please try to erase the device&amp;#39;s flash (erase all, chip erase) and remove any bond on the phone.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;Note that you don&amp;#39;t need secure connection to pair and encrypt the link. You can do normal legacy pairing, or doing Secure Connection with justwork. Of course when doing that you will not at security level 4. Please try remove&amp;nbsp;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;CONFIG_BT_SMP_SC_ONLY&lt;/span&gt;&lt;span&gt;=y&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;from prj.conf.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>