<?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 know that the device disconnected due to an authentication failure</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/121002/how-to-know-that-the-device-disconnected-due-to-an-authentication-failure</link><description>Hi, 
 I configured for using security BT_SECURITY_L2 for a device that I had previously configured for using BT_SECURITY_L4. When I try to connect with an Android phone that was previously paired when configured for BT_SECURITY_L4, it prints &amp;quot; SMP does</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 19 May 2025 13:17:34 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/121002/how-to-know-that-the-device-disconnected-due-to-an-authentication-failure" /><item><title>RE: How to know that the device disconnected due to an authentication failure</title><link>https://devzone.nordicsemi.com/thread/536002?ContentTypeID=1</link><pubDate>Mon, 19 May 2025 13:17:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2435f6de-5294-4d82-89ff-cc39e4a7d7be</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Please make a sniffer log if you are not able to make this work by removing the device from the phone (and BT off/on to clear cache) and a full erase of the peripheral (e.g. eraseall or recover).&lt;/p&gt;
&lt;p&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to know that the device disconnected due to an authentication failure</title><link>https://devzone.nordicsemi.com/thread/535837?ContentTypeID=1</link><pubDate>Fri, 16 May 2025 18:45:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cabc703f-6d32-4d42-b58f-56165b72f30b</guid><dc:creator>V.Lorz</dc:creator><description>&lt;p&gt;None of those options seemed to make a change in behaviour.&lt;/p&gt;
&lt;p&gt;Could you, please, point me to a working example for LE Secure Connections pairing using Level 2, Just Works?&lt;/p&gt;
&lt;p&gt;I configured the characteristics for using READ/WRITE with &lt;code&gt;BT_GATT_PERM_READ_ENCRYPT&lt;/code&gt;/&lt;code&gt;BT_GATT_PERM_WRITE_ENCRYPT&lt;/code&gt;, called &lt;code&gt;bt_conn_set_security(conn, BT_SECURITY_L2);&lt;/code&gt; in the &lt;code&gt;connected&lt;/code&gt; callback.&lt;/p&gt;
&lt;p&gt;Should I add any configuration option in prj.conf to indicate the Android device it should not try to pair with the device using a PIN or KEY?&lt;/p&gt;
&lt;p&gt;BR&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to know that the device disconnected due to an authentication failure</title><link>https://devzone.nordicsemi.com/thread/533396?ContentTypeID=1</link><pubDate>Tue, 29 Apr 2025 12:30:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7b92385e-d2e0-45e6-8c59-d7a39d00edf6</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Sorry, try with&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;CONFIG_BT_ID_UNPAIR_MATCHING_BONDS=y&lt;/li&gt;
&lt;li&gt;&lt;span&gt;&lt;/span&gt;CONFIG_BT_ID_ALLOW_UNAUTH_OVERWRITE=y&lt;/li&gt;
&lt;li&gt;&lt;span&gt;&lt;/span&gt;CONFIG_BT_KEYS_OVERWRITE_OLDEST=y&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;Kenneth&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to know that the device disconnected due to an authentication failure</title><link>https://devzone.nordicsemi.com/thread/533271?ContentTypeID=1</link><pubDate>Mon, 28 Apr 2025 21:07:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d9adbe36-d842-41d2-abb7-ef28c6719175</guid><dc:creator>V.Lorz</dc:creator><description>&lt;p&gt;I seems like &lt;code&gt;CONFIG_BT_ID_ALLOW_UNAUTH_OVERWRITE&lt;/code&gt; has a dependency on &lt;code&gt;CONFIG_BT_SMP_ALLOW_UNAUTH_OVERWRITE&lt;/code&gt; being &amp;#39;n&amp;#39;.&lt;/p&gt;
&lt;p&gt;It is the peripheral which still has the keys intact.&lt;/p&gt;
&lt;p&gt;BR&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to know that the device disconnected due to an authentication failure</title><link>https://devzone.nordicsemi.com/thread/533269?ContentTypeID=1</link><pubDate>Mon, 28 Apr 2025 20:26:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bfd020fe-fce5-4c51-8ccd-065bebe583bf</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;I suspect this is a corner case that you encounter during development and not on an end product.&lt;/p&gt;
&lt;p&gt;You can try to add the kconfig options I have suggested just to check if that make any difference.&lt;/p&gt;
&lt;p&gt;Can tell me which side had keys intact here when you encountered the issue, is it the phone or the peripheral that still had the keys intact?&lt;/p&gt;
&lt;p&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to know that the device disconnected due to an authentication failure</title><link>https://devzone.nordicsemi.com/thread/533255?ContentTypeID=1</link><pubDate>Mon, 28 Apr 2025 17:54:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e446908c-4972-4e68-b834-61d76e2f993b</guid><dc:creator>V.Lorz</dc:creator><description>&lt;p&gt;Thanks Kenneth,&lt;/p&gt;
&lt;p&gt;I implemented the callback but I receive error code 9, according to&amp;nbsp;&lt;code&gt;enum bt_security_err&lt;/code&gt; this is &lt;code&gt;BT_SECURITY_ERR_UNSPECIFIED&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Is this the intended behaviour? Or should I expect a different code?&lt;/p&gt;
&lt;p&gt;BR&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to know that the device disconnected due to an authentication failure</title><link>https://devzone.nordicsemi.com/thread/533244?ContentTypeID=1</link><pubDate>Mon, 28 Apr 2025 15:16:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a418fbcf-ca73-4fdd-8eea-ddcda423dc12</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Hi Chase,&lt;/p&gt;
&lt;p&gt;For test you can try to add (one or all):&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;CONFIG_BT_ID_UNPAIR_MATCHING_BONDS=y&lt;/li&gt;
&lt;li&gt;&lt;span&gt;&lt;/span&gt;CONFIG_BT_ID_ALLOW_UNAUTH_OVERWRITE=y&lt;/li&gt;
&lt;li&gt;&lt;span&gt;&lt;/span&gt;CONFIG_BT_KEYS_OVERWRITE_OLDEST=y&lt;/li&gt;
&lt;li&gt;&lt;span&gt;&lt;/span&gt;CONFIG_BT_SMP_ALLOW_UNAUTH_OVERWRITE=y&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If that doesn&amp;#39;t help, then my next suggestion is an on-air sniffer log:&lt;br /&gt;&lt;a href="https://www.nordicsemi.com/Products/Development-tools/nRF-Sniffer-for-Bluetooth-LE"&gt;https://www.nordicsemi.com/Products/Development-tools/nRF-Sniffer-for-Bluetooth-LE&lt;/a&gt;&amp;nbsp;&lt;br /&gt;&lt;a href="https://docs.nordicsemi.com/bundle/nrfutil/page/README.html"&gt;https://docs.nordicsemi.com/bundle/nrfutil/page/README.html&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You can send me the .pcapng file from wireshark, just make sure to sniff the specific connection by following:&lt;br /&gt;&lt;a href="https://docs.nordicsemi.com/bundle/nrfutil/page/nrfutil-ble-sniffer/guides/common_actions_sniffing_conn_single_periph.html"&gt;https://docs.nordicsemi.com/bundle/nrfutil/page/nrfutil-ble-sniffer/guides/common_actions_sniffing_conn_single_periph.html&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Edit: Sorry, I can see I didn&amp;#39;t really address your question.&lt;/p&gt;
[quote user=""]How can I know, inside the callback&amp;nbsp;&lt;code&gt;disconnected&lt;/code&gt;, that the connection was closed with &lt;code&gt;BT_HCI_ERR_AUTH_FAIL&lt;/code&gt;? I always receive reason 22 (&lt;code&gt;BT_HCI_ERR_LOCALHOST_TERM_CONN&lt;/code&gt;).[/quote]
&lt;p&gt;Maybe register a bt_conn_auth_info_cb callback to capture authentication failures (pairing_failed).&amp;nbsp;In the pairing_failed() callback, you can react appropriately, e.g., call bt_unpair().&lt;/p&gt;
&lt;p&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>