<?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>Scan filtering with address</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/95065/scan-filtering-with-address</link><description>Dear all, 
 
 I&amp;#39;m new to BLE development and have as many others encountered some challenges when trying to scan for a peripheral device using the address filter in the scanning module. 
 
 When using the UUID filter and/or name filter there&amp;#39;s no problem</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 05 Sep 2023 08:21:14 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/95065/scan-filtering-with-address" /><item><title>RE: Scan filtering with address</title><link>https://devzone.nordicsemi.com/thread/444431?ContentTypeID=1</link><pubDate>Tue, 05 Sep 2023 08:21:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:55a5a285-6f96-497a-9fef-10c7d90e96d4</guid><dc:creator>mhakbilen</dc:creator><description>&lt;p&gt;Thanks.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Scan filtering with address</title><link>https://devzone.nordicsemi.com/thread/444408?ContentTypeID=1</link><pubDate>Tue, 05 Sep 2023 05:16:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a3dc3159-5bc0-4fb7-ac59-cae4a99f5b22</guid><dc:creator>mahq</dc:creator><description>&lt;p&gt;Hello, as written in this topic above I did scrap my idea of connecting to peripheral devices using the mac address. I went for using the short name filter instead.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Scan filtering with address</title><link>https://devzone.nordicsemi.com/thread/443090?ContentTypeID=1</link><pubDate>Fri, 25 Aug 2023 06:06:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:440b2f26-c368-4d61-9127-96296611c19a</guid><dc:creator>mhakbilen</dc:creator><description>[quote userid="121988" url="~/f/nordic-q-a/95065/scan-filtering-with-address"]The adress sticks the same after reboot.[/quote]
&lt;p&gt;Hi mahq,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I am having trouble connecting to the MAC address. I would like to talk to you about this problem. Can you share your e-mail address or LinkedIn address?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Scan filtering with address</title><link>https://devzone.nordicsemi.com/thread/404063?ContentTypeID=1</link><pubDate>Tue, 10 Jan 2023 11:32:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1792c0cc-4aff-472e-8ed5-af0da8e13fc0</guid><dc:creator>mahq</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Did some more investigations on my own and found out that, if you are using a name filter when scanning (using SDK 2.0.2) it will be up to the peripheral to decide on how many characthers to match in the filter.&lt;/p&gt;
&lt;p&gt;I.e. if the central device has a filter named &amp;quot;Filter01&amp;quot; and a perihperal device is advertising with the name &amp;quot;F&amp;quot; this will be considered as a filter match.&lt;/p&gt;
&lt;p&gt;I will instead use the ShortName filter since then the central device will control that the advertising name is fulfilling the &amp;quot;min_len&amp;quot; specified in the data type &amp;quot;bt_scan_short_name&amp;quot;.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;kind regards,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Scan filtering with address</title><link>https://devzone.nordicsemi.com/thread/403995?ContentTypeID=1</link><pubDate>Tue, 10 Jan 2023 08:42:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:be281d60-61ad-4e66-bbbe-37515f071335</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Hi, I have been sick for few days and did not get time to test this. I do not know that format of the scan filter over the top of my head but I will try to test your code snippet this week when I am back to office. Sorry for the delays so far and thanks a lot of your patience.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Scan filtering with address</title><link>https://devzone.nordicsemi.com/thread/402735?ContentTypeID=1</link><pubDate>Mon, 02 Jan 2023 06:44:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1bcc794e-9571-444e-ae32-2c604b0e4516</guid><dc:creator>mahq</dc:creator><description>&lt;p&gt;Thank you for you answer. Didn&amp;#39;t really get your proposal to work.&lt;/p&gt;
&lt;p&gt;However I&amp;#39;m trying another apporach where the &amp;quot;connect_if_match&amp;quot; always is set to true and instead applying different name filters instead of an address filter.&lt;/p&gt;
&lt;p&gt;In order to separate between different units (peripherals) i want to use a similar name string for my units in the advertise data and scan filter which will have the format of some characters and two digits ex. &amp;quot;Filter01&amp;quot;, &amp;quot;Filter02&amp;quot;, &amp;quot;Filter03&amp;quot; etc. etc.&lt;/p&gt;
&lt;p&gt;I have a function in my central unit according to the code below in order to change between different filters and in that way connect to different peripherals:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void update_filter(char filter_number[3]){
	int err;
	char connect_string[] = {&amp;#39;F&amp;#39;, &amp;#39;i&amp;#39;, &amp;#39;l&amp;#39;, &amp;#39;t&amp;#39;, &amp;#39;e&amp;#39;, &amp;#39;r&amp;#39;, filter_number[0], filter_number[1], 0 };
	
	printk(&amp;quot;changing filter to %s \r\n&amp;quot;, connect_string);
	bt_scan_filter_remove_all();
	bt_scan_filter_disable();
	
	
	err = bt_scan_filter_add(BT_SCAN_FILTER_TYPE_NAME, connect_string);
	if (err) {
		printk(&amp;quot;error adding filter %d \r\n&amp;quot;, err);
		LOG_ERR(&amp;quot;Scanning filters cannot be set (err %d)&amp;quot;, err);
		return err;
	}

	err = bt_scan_filter_enable(BT_SCAN_NAME_FILTER, true);
	if (err) {
		printk(&amp;quot;error enabling filter \r\n&amp;quot;);
		LOG_ERR(&amp;quot;Filters cannot be turned on (err %d)&amp;quot;, err);
		return err;
	}

}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Though when applying the filter it doesn&amp;#39;t seem that a complete string match is needed in order to trigger a filter match. When applying a filter according to the code above (the scan_init functions has already been initialized) my central unit can connect to any random bluetooth unit in my office.&lt;/p&gt;
&lt;p&gt;I do not get any error message so I assume that the filter is properly added and enabled.&lt;/p&gt;
&lt;p&gt;Do I need to format my name filter in any certain way or doesn&amp;#39;t a name filter require a complete match of the filter string in order to trigger a filter match?&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Scan filtering with address</title><link>https://devzone.nordicsemi.com/thread/402364?ContentTypeID=1</link><pubDate>Wed, 28 Dec 2022 08:39:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ca160037-8acb-4b7b-b5ea-f03f98a73c39</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;You would have to reinitialize the scanner module with connect_if_match set.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Other was is to directly edit the structure defined in&amp;nbsp;NRF_BLE_SCAN_DEF(X) to change its X-&amp;gt;&lt;span&gt;connect_if_match = true when you need it.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Scan filtering with address</title><link>https://devzone.nordicsemi.com/thread/402294?ContentTypeID=1</link><pubDate>Tue, 27 Dec 2022 13:37:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d3e266fc-19e5-4877-9d11-af6b05be55f6</guid><dc:creator>mahq</dc:creator><description>&lt;p&gt;Found a solution to my issue,&lt;/p&gt;
&lt;p&gt;I was calling the incorrect function (bt_addr_to_str instead of&amp;nbsp;bt_addr_le_to_str after connecting to perephiral) hence a deviation between the addresses.&lt;/p&gt;
&lt;p&gt;Also must the input type pointer to the bt_scan_filter_add be of type &amp;quot;bt_addr_le_t&amp;quot; when using the filter type &amp;quot;BT_SCAN_FILTER_TYPE_ADDR&amp;quot;.&lt;/p&gt;
&lt;p&gt;I do, however, have another question;&lt;/p&gt;
&lt;p&gt;I would like the central unit to first scan for a generic name filter in order to list all mac-addresses (of the peripherals) which matches this filter but I don&amp;#39;t want an automatic connection. Then I would like the central unit to apply one filter with a specific mac-address in order to connect to only one of the matching units.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m trying this procedure and I do manage to get a filter match with only one mac address after first listing all devices matching the generic name filter. But the central unit is not connecting to the chosen peripheral.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;For the first scanning i&amp;#39;m calling the scan_init function where I set the &amp;quot;.connect_if_match&amp;quot; to false, when changing the filter to an address-filter I&amp;#39;m first calling the scan_init function a second time and setting the &amp;quot;.connect_if_match&amp;quot; to true. Is this possible scenario or is it only possible to set the &amp;quot;bt_scan_init_param&amp;quot; one time?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>