<?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>Selective Connection To a Specific Gateway</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/83306/selective-connection-to-a-specific-gateway</link><description>Hello! 
 I am having 3 nrf5340 devices; 2 Gateways and 1 Headset. I am trying to achieve the scenario where I can allow the Headset connects to selectively one of the 2 Gateways using a button on the headset as an interface for the user, and if the user</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 12 Jan 2022 09:32:29 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/83306/selective-connection-to-a-specific-gateway" /><item><title>RE: Selective Connection To a Specific Gateway</title><link>https://devzone.nordicsemi.com/thread/347321?ContentTypeID=1</link><pubDate>Wed, 12 Jan 2022 09:32:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c0c0f79b-7176-4bf0-a1c9-72eb73da5154</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;I checked NCS v1.7.1, where bt_le_whitelist_add() is not deprecated, and there you need to add&amp;nbsp;CONFIG_BT_WHITELIST to your prj.conf.&lt;/p&gt;
&lt;p&gt;I was just looking at the uart examples. They don&amp;#39;t use the&amp;nbsp;&lt;span&gt;BT_LE_ADV_CONN_DIR(_peer), but you can add it.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;You can see where it is defined by using the right click and &amp;quot;go to definition&amp;quot; and look around for how things are implemented. If you can&amp;#39;t do this, you should install nRF Connect for VS Code.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Selective Connection To a Specific Gateway</title><link>https://devzone.nordicsemi.com/thread/347307?ContentTypeID=1</link><pubDate>Wed, 12 Jan 2022 08:37:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:84eb6f1a-0948-4e87-a1e9-20f0b0c0dcb2</guid><dc:creator>Loai</dc:creator><description>&lt;p&gt;Hi Edvin,&lt;/p&gt;
&lt;p&gt;I checked my &lt;strong&gt;bluetooth.h&lt;/strong&gt; file to see the available API to use, I noticed that&amp;nbsp;&lt;strong&gt;bt_le_whitelist_add()&lt;/strong&gt; is available and the function&amp;nbsp;&lt;strong&gt;bt_le_filter_accept_list_add()&amp;nbsp;&lt;/strong&gt;is not available. It seems that the software version you are referring to is newer than mine, but what wanders me is that calling all the functions related to whitelist cause a compilation error while other functions from bluetooth.h file are ok to use!&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I referred also to your second suggested solution regarding the directed advertising. May I know the path of the main.c you are referring to in order to paste the if-else conditions within? I have found the other main.c file where the advertisement starts is being implemented, but not specifically where &lt;strong&gt;connect()&lt;/strong&gt; function is defined.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Selective Connection To a Specific Gateway</title><link>https://devzone.nordicsemi.com/thread/347163?ContentTypeID=1</link><pubDate>Tue, 11 Jan 2022 12:56:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:80eca2d1-6b5d-4d98-839f-5e37b4fa95dc</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;I see from some release notes (release-notes-2.7.rst) that bt_le_whitelist_add is deprecated in favor of bt_le_filter_accept_list_add(). Try using that function instead.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you look at the definition of bt_le_filter_accept_list_add() in bt_rcp_gap_client.c (write it, right click, and go to definition), you can see that this function is only defined if&amp;nbsp;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;CONFIG_BT_FILTER_ACCEPT_LIST is defined, so you need to add this to prj.conf for the function to be usable:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1641905163239v1.png" alt=" " /&gt;&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;Another approach is to use something called directed advertising. If you look at where you call bt_le_adv_start(), you probably do so with BT_LE_ADV_CONN as the first parameter. You can also try to replace this with&amp;nbsp;&lt;/span&gt;&lt;/span&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;BT_LE_ADV_CONN_DIR(_peer), where _peer is the peer address as a&amp;nbsp;&lt;span&gt;bt_addr_le_t parameter (I think).&lt;/span&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;span&gt;Try copying the address from the connected event, something like this:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;//Near top of main.c:
bt_addr_le_t address_1 = NULL;
bt_addr_le_t address_2 = NULL;

static void connected(struct bt_conn *conn, uint8_t err)
{
	char addr[BT_ADDR_LE_STR_LEN];

	if (err) {
		LOG_ERR(&amp;quot;Connection failed (err %u)&amp;quot;, err);
		return;
	}

	bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));
	LOG_INF(&amp;quot;Connected %s&amp;quot;, log_strdup(addr));

    err = bt_le_filter_accept_list_add(addr);
    LOG_INF(&amp;quot;err = %d&amp;quot;, err);

	current_conn = bt_conn_ref(conn);

	dk_set_led_on(CON_STATUS_LED);
	
	// Copy this:
	if (address_1 == NULL)
	{
        address_1 = bt_conn_get_dst(conn);
    }
    else if (address_2 == NULL)
    {
        address_2 = bt_conn_get_dst(conn);
    }
}

...
// wherever you start advertising:
err = bt_le_adv_start(BT_LE_ADV_CONN_DIR(addr_1), ad, ARRAY_SIZE(ad), ...)
&lt;/pre&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&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;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Best regards,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Edvin&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Selective Connection To a Specific Gateway</title><link>https://devzone.nordicsemi.com/thread/347051?ContentTypeID=1</link><pubDate>Tue, 11 Jan 2022 06:55:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1ca09196-99b1-4d71-bd6b-657d220db941</guid><dc:creator>Loai</dc:creator><description>&lt;p&gt;Hi Edvin. My apologies for the late reply. I don&amp;#39;t think the headset is bonded with both gateways at the same time. It only bonds with a single device and I can hear the audio transmitted by that device only.&lt;/p&gt;
&lt;p&gt;Using my current implementation, the comparison I implemented helps me to disconnect, find a new device, and connect with that device, but I was thinking if I can find an optimized way to do that.&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I was thinking to implement your suggested idea which is using the function&amp;nbsp;&lt;strong&gt;bt_le_whitelist_add()&lt;/strong&gt; in &lt;strong&gt;ble_tans.c&lt;/strong&gt; file, but I faced an error &amp;#39;&lt;em&gt;undefined reference to bt_le_whitelist_add&amp;#39;.&lt;/em&gt; Based on your experience, would you mind to guide me regarding the best practice of using that function?&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/6763.Screenshot-2022_2D00_01_2D00_11-155406.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Selective Connection To a Specific Gateway</title><link>https://devzone.nordicsemi.com/thread/346406?ContentTypeID=1</link><pubDate>Thu, 06 Jan 2022 10:17:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:eb87020e-ea0b-4dfd-ae54-6beeab35553b</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Are you bonded with the gateways? If so, the peripheral should know the IRK (Identity resolving key). I see that the way that you are currently searching through the addresses is pretty much working, right? What you want to do is to skip the comparing of new addresses if I understand correctly?&lt;/p&gt;
&lt;p&gt;Are you able to determine using&amp;nbsp;&lt;strong&gt;bt_addr_le_cmp(const bt_addr_le_t *a, const bt_addr_le_t *b)&amp;nbsp;&lt;/strong&gt;whether the new address is the same device as before?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Selective Connection To a Specific Gateway</title><link>https://devzone.nordicsemi.com/thread/346326?ContentTypeID=1</link><pubDate>Thu, 06 Jan 2022 02:43:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8c7922a8-deeb-490a-b014-152c7b6a0e21</guid><dc:creator>Loai</dc:creator><description>&lt;p&gt;Thank you very much, Edvin, for your answer.&lt;/p&gt;
&lt;p&gt;After doing some research last time, I noticed that the Whitelist is where I can include all the addresses that I wish to connect to. However, in my case I just want to iterate the connection upon the user pressing the button (From Gateway 1&amp;nbsp;&lt;span&gt;&amp;rarr; Gateway 2) and vice versa&amp;nbsp;(From Gateway 2 &amp;rarr; Gateway 1), and I will not be able to determine the address of the second device. While searching for an answer last time, I came across something called the &amp;#39;Blacklist&amp;#39;, which can help me blacklist/hide the received address to give an opportunity for the scanner to search for a new address. This was a brilliant idea, but unfortunately, it is not supported in the current nRF SDK.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Selective Connection To a Specific Gateway</title><link>https://devzone.nordicsemi.com/thread/345936?ContentTypeID=1</link><pubDate>Tue, 04 Jan 2022 14:00:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c3cb6565-6300-4722-b65e-0c6bf7ac5b81</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Have you tried to add only one of the devices to the whitelist using&amp;nbsp;bt_le_whitelist_add()? I know you say that that the address is changing, but if you try to bond to both devices, but only keep the one you want to connect to in the whitelist, perhaps that does the trick. I must admit I haven&amp;#39;t tested this in the nRF Connect SDK yet.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>