<?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>nRF Connect Check if bonded</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/89818/nrf-connect-check-if-bonded</link><description>How do I check to see if a peripheral is inside the list of bonded units of a central? 
 I know I can just scan -&amp;gt; see unit -&amp;gt; connect -&amp;gt; change security and if it IS bonded then it will not try to attempt a re-pairing. It will use the stored keys. However</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 11 Jul 2022 11:26:31 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/89818/nrf-connect-check-if-bonded" /><item><title>RE: nRF Connect Check if bonded</title><link>https://devzone.nordicsemi.com/thread/376398?ContentTypeID=1</link><pubDate>Mon, 11 Jul 2022 11:26:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dce7dcf9-e808-49c7-8c05-cf7a3be38c8f</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;I think this looks good.&lt;/p&gt;
&lt;p&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF Connect Check if bonded</title><link>https://devzone.nordicsemi.com/thread/376284?ContentTypeID=1</link><pubDate>Sat, 09 Jul 2022 01:33:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9577df0d-9bd8-40f1-9010-50dd84f2cf52</guid><dc:creator>dmleone</dc:creator><description>&lt;p&gt;I found something. I do not know if it is good. Maybe someone can offer some constructive criticism on if this is a proper way to accomplish what I want. It does work. not sure if elegant or proper bluetooth methodology&lt;/p&gt;
&lt;p&gt;I have a function check_bonds. it compares 2 bt_addr_le_t.addr elements. (i assume these are unique identifiers for all bonded units.) I then call bt_foreach_bond() where i want to check if bonded before calling for the connection. The advertising data i am inspecting is not looking to pair, only connect if bonded. So if a result from the check bonds function returns true, then go ahead and make a connection with the advertising device.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;void check_bonds(const struct bt_bond_info *info, void *user_data){
	struct bond_checker *bc = user_data;

	bt_addr_le_t *addr = &amp;amp;bc-&amp;gt;addr;
	bt_addr_le_t *dest = &amp;amp;info-&amp;gt;addr;

	if(!bt_addr_le_cmp(dest, addr)){
		printk(&amp;quot;Bond Found\n&amp;quot;);
		bc-&amp;gt;found = true;
	}
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;
bc.addr = (*addr);
bc.found = false;
bt_foreach_bond(BT_ID_DEFAULT, check_bonds, &amp;amp;bc);

if(bc.found){
	err = bt_le_scan_stop();

	if (err) {
		printk(&amp;quot;Stop LE scan failed (err %d)\n&amp;quot;, err);
		break;
	}
	param = BT_LE_CONN_PARAM_DEFAULT;
	err = bt_conn_le_create(addr, BT_CONN_LE_CREATE_CONN,
				param, &amp;amp;default_conn);
	if (err) {
		printk(&amp;quot;Create conn failed (err %d)\n&amp;quot;, err);
		start_scan();
	}

	return false;
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>