<?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 Reject new devices attempting to pair, only allow old bonded device</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/83445/ble-reject-new-devices-attempting-to-pair-only-allow-old-bonded-device</link><description>Hi All, 
 I am running nrfConnect SDK v1.8.0 ad started a new sample LBS project. I ultimately want to have 3 devices, 1 being a Central and 2 Peripherals both running LBS. This will be reworked and extended in the future but for now that is fine. 
 My</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 12 Jan 2022 06:17:18 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/83445/ble-reject-new-devices-attempting-to-pair-only-allow-old-bonded-device" /><item><title>RE: BLE Reject new devices attempting to pair, only allow old bonded device</title><link>https://devzone.nordicsemi.com/thread/347295?ContentTypeID=1</link><pubDate>Wed, 12 Jan 2022 06:17:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b157d4b1-4cd3-49c6-a824-82dd1d18620c</guid><dc:creator>rfleming</dc:creator><description>&lt;p&gt;Hey Simonr,&lt;/p&gt;
&lt;p&gt;After a bit more playing around I found the answer!&lt;/p&gt;
&lt;p&gt;I couldn&amp;#39;t get the remote_info to work as you suggested. The callback function within the bt_conn_cb is never called. Moreover if I do the call manually&amp;nbsp;from the &lt;strong&gt;connected&lt;/strong&gt; callback, it doesn&amp;#39;t populate any fields to do with the IRK nor the RPA conversion or confirmation&amp;nbsp;against a&amp;nbsp;previously Public address.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static void remote_info_available(struct bt_conn *conn, struct bt_conn_remote_info *remote_info)
{
	printk(&amp;quot;remote info available\n&amp;quot;);
}

static struct bt_conn_cb conn_callbacks = {
	.connected = connected,
	.disconnected = disconnected,
	.identity_resolved = identity_resolved,
	.remote_info_available = remote_info_available,
#ifdef CONFIG_BT_LBS_SECURITY_ENABLED
	.security_changed = security_changed,
#endif
};&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;After a bit more poking around I found a function buried in the rpa.c file called &lt;strong&gt;bt_rpa_irk_matches&lt;/strong&gt;&amp;nbsp;though after testing it within &lt;strong&gt;connected&lt;/strong&gt; callback, either I am doing something wrong with my irk, or the function wasn&amp;#39;t made for this purpose.&lt;/p&gt;
&lt;p&gt;I tried reversing the byte order in case I had the wrong endianess, same result.&lt;/p&gt;
&lt;p&gt;NEVERTHELESS,&lt;/p&gt;
&lt;p&gt;As it turns out, once a device has been bonded, once it enters the &lt;strong&gt;connect&lt;/strong&gt; callback, even if the device has to enter the passkey again, the conn argument (&lt;strong&gt;struct bt_conn *conn&lt;/strong&gt;) contains the target resolved address.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;bt_conn&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/strong&gt;structure has 3 ble addresses that it parses.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;conn-&amp;gt;le.init_addr&lt;/strong&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;the address as seen by a sniffer, raw and unresolved. Likely private etc.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;conn-&amp;gt;le.dst&lt;/strong&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;if device was previoulsy bonded, this address actually is already resolved with the public one &amp;lt;---- Solution!!&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;conn-&amp;gt;le.resp_addr&lt;/strong&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;the address of THIS device.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;So by taking the address provided by the destination, I am able to reject any bonded devices!&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks again for your help,&lt;/p&gt;
&lt;p&gt;Ryan.&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE Reject new devices attempting to pair, only allow old bonded device</title><link>https://devzone.nordicsemi.com/thread/347056?ContentTypeID=1</link><pubDate>Tue, 11 Jan 2022 07:13:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:eade2e55-6dd2-449f-8645-8b4135553b60</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi again Ryan&lt;/p&gt;
&lt;p&gt;Yes, as long as you store this data in flash, which won&amp;#39;t be lost if you reset or go to system OFF mode this should indeed be possible.&lt;/p&gt;
&lt;p&gt;To get information from the device you connect to you can use the &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/reference/bluetooth/connection_mgmt.html#c.bt_conn_get_remote_info"&gt;bt_conn_get_remote_info()&lt;/a&gt; I think and compare it to the stored data.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE Reject new devices attempting to pair, only allow old bonded device</title><link>https://devzone.nordicsemi.com/thread/346935?ContentTypeID=1</link><pubDate>Mon, 10 Jan 2022 12:33:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2a8853de-ac70-470d-ac96-763ae0a34376</guid><dc:creator>rfleming</dc:creator><description>&lt;p&gt;Hi Simonr,&lt;/p&gt;
&lt;p&gt;What if I have a bonded device and my peripheral restarts. Can I still compare this the way you speak of?&lt;/p&gt;
&lt;p&gt;Could you please identify the functions that I should look into? I&amp;#39;ve been scraping through quite a few of these functions in various header files all day and don&amp;#39;t quite know what I am looking at to be honest.&lt;/p&gt;
&lt;p&gt;Cheers,&lt;/p&gt;
&lt;p&gt;Ryan.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE Reject new devices attempting to pair, only allow old bonded device</title><link>https://devzone.nordicsemi.com/thread/346872?ContentTypeID=1</link><pubDate>Mon, 10 Jan 2022 10:02:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7e06b5ac-5980-4946-8510-67a156b7214a</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi Ryan&lt;/p&gt;
&lt;p&gt;I think what you&amp;#39;re looking for is the&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/reference/bluetooth/connection_mgmt.html"&gt; Connection Management API&lt;/a&gt; in the nRFConnect SDK. As long as you store the first connected central&amp;#39;s data you can compare it in the next CONNECTED event and trigger a disconnect if it doesn&amp;#39;t match.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE Reject new devices attempting to pair, only allow old bonded device</title><link>https://devzone.nordicsemi.com/thread/346822?ContentTypeID=1</link><pubDate>Sun, 09 Jan 2022 21:43:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b1500dce-9ce6-4bbe-9c62-e60cb455e9ae</guid><dc:creator>rfleming</dc:creator><description>&lt;p&gt;Hey,&lt;/p&gt;
&lt;p&gt;Thanks for the reply Simon.&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration:line-through;"&gt;Though as mentioned, this is what I am currently trying to do, though don&amp;#39;t know the best (or appropriate) way to match the private addresses (IRK?) to the bonded address I discover through the&amp;nbsp;&lt;strong&gt;bt_foreach_bond&lt;/strong&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;function.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;After a more reading around. Turns out what I get is the random address and can be resolved by doing an AES decryption. My issue is all the examples that I could find online were all for the previous NRF SDK, rather than NRF Connect SDK (ncs).&lt;/p&gt;
&lt;p&gt;Is there any APIs based on the Zephyr implementation that come to mind that could work like an example provided on this forum for the nrf sdk:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/12083/resolving-private-resolvable-addresses?ReplyFilter=Answers&amp;amp;ReplySortBy=Answers&amp;amp;ReplySortOrder=Descending"&gt;devzone.nordicsemi.com/.../resolving-private-resolvable-addresses&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Security changed: 6A:05:8D:39:63:AF (random) level 4&lt;br /&gt;Pairing completed: 94:XX:XX:XX:XX:9B (public), bonded: 1&lt;br /&gt;irk: 000000000000000xxxETCxxx0000715d&lt;/p&gt;
&lt;p&gt;i got my IRK from&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;pre class="ui-code" data-mode="text"&gt;struct bt_keys *keys = bt_keys_find_irk(BT_ID_DEFAULT, bt_conn_get_dst(conn));
		// keys-&amp;gt;irk
		printk(&amp;quot;irk: %s\n&amp;quot;, bt_hex(keys-&amp;gt;irk.val, 16));&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Cheers,&lt;/p&gt;
&lt;p&gt;Ryan.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE Reject new devices attempting to pair, only allow old bonded device</title><link>https://devzone.nordicsemi.com/thread/346684?ContentTypeID=1</link><pubDate>Fri, 07 Jan 2022 11:49:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9ed2336a-6eb6-42a7-9b70-4827a5bab608</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;As far as I know there is no way to blacklist devices from the peripheral side, but what you could do is to check the peer address when the periphearl gets a CONNECTED event, and disconnect immediately if it&amp;#39;s not the address it is bonded to.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>