<?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>Filter mac with only two bytes</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/108450/filter-mac-with-only-two-bytes</link><description>I am using nrf52840 and i need to set the filter of mac address with only two bytes of mac and scan all the devices which are all prefixed with that two bytes and store the adv data of those devices sdk name nRF5_SDK_17.1.0_ddde560</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 21 Feb 2024 08:54:25 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/108450/filter-mac-with-only-two-bytes" /><item><title>RE: Filter mac with only two bytes</title><link>https://devzone.nordicsemi.com/thread/469963?ContentTypeID=1</link><pubDate>Wed, 21 Feb 2024 08:54:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:54a13f42-348e-4995-9514-d3d8f9cb75c5</guid><dc:creator>AP1</dc:creator><description>&lt;p&gt;Hi Edvin Thanks for your quick reply based on your suggestion now we are able to get the required devices&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Filter mac with only two bytes</title><link>https://devzone.nordicsemi.com/thread/469829?ContentTypeID=1</link><pubDate>Tue, 20 Feb 2024 14:31:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2cbeb47e-dc33-4bb9-938d-c5962086f806</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;The easiest way to do this is to not use the built in filters (because they would require the entire address), but just add the&amp;nbsp;BLE_GAP_EVT_ADV_REPORT event to your ble_evt_handler() in main.c. It should start occuring when you start scanning. When it does, you can use this event to check the address:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;        case BLE_GAP_EVT_ADV_REPORT:
            NRF_LOG_INFO(&amp;quot;received adv_report from %02x:%02x:%02x:%02x:%02x:%02x&amp;quot;, p_ble_evt-&amp;gt;evt.gap_evt.params.adv_report.direct_addr.addr[0],
                                                                                    p_ble_evt-&amp;gt;evt.gap_evt.params.adv_report.direct_addr.addr[1],
                                                                                    p_ble_evt-&amp;gt;evt.gap_evt.params.adv_report.direct_addr.addr[2],
                                                                                    p_ble_evt-&amp;gt;evt.gap_evt.params.adv_report.direct_addr.addr[3],
                                                                                    p_ble_evt-&amp;gt;evt.gap_evt.params.adv_report.direct_addr.addr[4],
                                                                                    p_ble_evt-&amp;gt;evt.gap_evt.params.adv_report.direct_addr.addr[5]);
            break;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;And then do whatever you like based on the address, such as connecting, store advertising data or whatever you want to do.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you dig deep into the scan filters in nrf_ble_scan.c, you will find that it also just use these BLE_GAP_EVT_ADV_REPORT events, and do a bunch of filtering based on the incoming advertisement packets, so I think just checking a few bytes in the advertising packet using this event in your main ble_evt_handler() is easier than starting to modify the scanning module from the SDK.&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>