<?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>issues with public address type when applying scan filter</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/61512/issues-with-public-address-type-when-applying-scan-filter</link><description>I&amp;#39;m trying to connect to a device with a public address using an address filter in the scan (not whitelisting), I&amp;#39;ve seen plenty of similar unresolved issues posted here. So this is my take; 
 nrf_ble_scan_filter_set(&amp;amp;m_scan, SCAN_ADDR_FILTER, m_target_periph_addr</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 28 May 2020 10:38:07 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/61512/issues-with-public-address-type-when-applying-scan-filter" /><item><title>RE: issues with public address type when applying scan filter</title><link>https://devzone.nordicsemi.com/thread/252133?ContentTypeID=1</link><pubDate>Thu, 28 May 2020 10:38:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:44657219-6e6f-4987-8ba2-71264150dfd2</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Or take in the entire address, including the type, and set the address type in the filter based on that input. I just tried to point out that it is fixable since this is not part of the softdevice, so you don&amp;#39;t have to wait for the next SDK release for the fix.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="simone.bonetti"]Thanks for the help, hope to see the fix in the next SDK release![/quote]
&lt;p&gt;&amp;nbsp;Me too! Thank you both for reporting.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="simone.bonetti"]the scan filter NEEDS to evaluate the address type in order to avoid possible &amp;quot;false positives&amp;quot;, e.g. 2 devices with the same MAC, but one set as PUBLIC, the other set as RANDOM[/quote]
&lt;p&gt;&amp;nbsp;I don&amp;#39;t think this is a real issue.&lt;/p&gt;
&lt;p&gt;1: In almost all cases, there wouldn&amp;#39;t be two devices with the same address (chances are microscopical).&lt;/p&gt;
&lt;p&gt;2: In most cases, the random addresses will not be accepted as valid addresses, because they start with the wrong bits. If they by accident do, then 1) &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;BR,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: issues with public address type when applying scan filter</title><link>https://devzone.nordicsemi.com/thread/252130?ContentTypeID=1</link><pubDate>Thu, 28 May 2020 10:28:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:95b5ef40-bbbb-4a20-a8ba-9fb80fac9fa6</guid><dc:creator>simone.bonetti</dc:creator><description>&lt;p&gt;Yes, that&amp;#39;s what is causing the issue, and could be a temporary workaround, but i think that the SDK team should not delete that control when fixing the issue (the scan filter NEEDS to evaluate the address type in order to avoid possible &amp;quot;false positives&amp;quot;, e.g. 2 devices with the same MAC, but one set as PUBLIC, the other set as RANDOM), rather, i suggest to evaluate the solution me and &lt;a href="https://devzone.nordicsemi.com/members/ajkahl"&gt;ajkahl&lt;/a&gt; are proposing.&lt;/p&gt;
&lt;p&gt;Thanks for the help, hope to see the fix in the next SDK release!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: issues with public address type when applying scan filter</title><link>https://devzone.nordicsemi.com/thread/252101?ContentTypeID=1</link><pubDate>Thu, 28 May 2020 08:19:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2fef79b9-7704-4fb8-8e2c-42ceca64f9c7</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;The reason that I asked for the example is that it lowers the threshold to actually test it and see the same as you see. It increases the handling speed for tickets.&lt;/p&gt;
&lt;p&gt;So, I put together a couple of projects from scratch, and I see what you mean. It reads out the address type from the advertisement, and doesn&amp;#39;t deduct it the same way that it is done when you set the address filter.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;So I suggest the following workaround:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static bool find_peer_addr(ble_gap_evt_adv_report_t const * const p_adv_report,
                           ble_gap_addr_t const                 * p_addr)
{
    //if (p_addr-&amp;gt;addr_type == p_adv_report-&amp;gt;peer_addr.addr_type)
    {
        // Compare addresses.
        if (memcmp(p_addr-&amp;gt;addr,
                   p_adv_report-&amp;gt;peer_addr.addr,
                   sizeof(p_adv_report-&amp;gt;peer_addr.addr)) == 0)
        {
            return true;
        }
    }
    return false;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Wouldn&amp;#39;t that work as a workaround?&lt;/p&gt;
&lt;p&gt;As I said, I have reported this to the SDK team.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: issues with public address type when applying scan filter</title><link>https://devzone.nordicsemi.com/thread/252018?ContentTypeID=1</link><pubDate>Wed, 27 May 2020 14:49:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1c5c6742-d86a-42a6-9ce5-ef463a6661a6</guid><dc:creator>simone.bonetti</dc:creator><description>&lt;p&gt;No, i mean that the problem with the &lt;span&gt;nrf_ble_scan_addr_filter_add is that, with the current implementation, it has not enough information to infer if an address is public or random, and it wrongly infer a type just by looking at the first 2 MSB of the user provided MAC.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;the user cannot specify the address type in the function parameters, it only accepts a 48-bit MAC address, so it cannot infer if the passed address is meant to be public or random.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;for instance, without additional information, the following MAC address 00:15:42:XX:XX:XX could be either&amp;quot;public&amp;quot;&amp;nbsp;or &amp;quot;non-resolvable random private&amp;quot;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;That&amp;#39;s the reason why the function&amp;nbsp;&lt;em&gt;sd_ble_gap_addr_set&amp;nbsp;&lt;/em&gt;(used to set the MAC address of a device, which is then part of the advertising) NEEDS to know both TYPE (whether public or random) and the MAC itself to properly set the TxAdd/RxAdd bits inside the advertising PDU. The&amp;nbsp;&lt;em&gt;nrf_ble_scan_addr_filter_add&amp;nbsp;&lt;/em&gt;should work exactly the same, without trying to infer the type when it does not have enough information to do it.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;There&amp;#39;s no need to provide source codes for a non-working example, just set the following MAC on a peripheral:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static ble_gap_addr_t m_dev_address =
{
    .addr_type = BLE_GAP_ADDR_TYPE_PUBLIC, /**&amp;lt; See @ref BLE_GAP_ADDR_TYPES. */
    .addr = {0xXX,0xXX,0xXX,0xXX,0xXX,0x00} /**&amp;lt; 48-bit address, LSB format. 0xXX could be any number */
};&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;and then setup a scan filter using the peripheral MAC address on a BLE Central node (you can simply use&amp;nbsp;ble_central\ble_app_uart_c and&amp;nbsp;\ble_peripheral\ble_app_uart as a base example).&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;You will see that when the filter is applied&amp;nbsp;&lt;em&gt;nrf_ble_scan_addr_filter_add&amp;nbsp;&lt;/em&gt;infers that its type is &amp;quot;Non-Resolvable random private&amp;quot; (due to the 0b00) and stores the filter that way.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;When a scan is performed, the addresses match, but the type does not (inside filter is &amp;quot;non-resolvable random private&amp;quot; while inside ADV packet is &amp;quot;public&amp;quot;) and the connection fails.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: issues with public address type when applying scan filter</title><link>https://devzone.nordicsemi.com/thread/251906?ContentTypeID=1</link><pubDate>Wed, 27 May 2020 10:48:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:814bdbd4-fbe5-4243-a8cc-72884e034ba8</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;I have forwarded the report to our SDK team (which doesn&amp;#39;t work on DevZone, unfortunately).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Do you mean that nrf_ble_scan_addr_filter_add() changes the address that is added to the filter if it is a public address?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;As far as I can tell, it will set an address type (which may be wrong if it is a pulbic address. That I agree on).&lt;/p&gt;
&lt;p&gt;Later, when the filter is used, it will be called in on_adv_report() -&amp;gt; if (addr_filter_enabled) -&amp;gt;&amp;nbsp;adv_addr_compare() -&amp;gt;&amp;nbsp;find_peer_addr()&lt;/p&gt;
&lt;p&gt;which will check the stored address with the address from the advertising report. Yes, it will also compare the address type, but the (wrongly) assumed address type will be the same as when you added the address.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I may be missing something here, and if so, please let me know. But I don&amp;#39;t see why this wouldn&amp;#39;t work. If it in fact doesn&amp;#39;t run as expected, perhaps you can provide a central and peripheral example where this doesn&amp;#39;t work?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;BR,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: issues with public address type when applying scan filter</title><link>https://devzone.nordicsemi.com/thread/251864?ContentTypeID=1</link><pubDate>Wed, 27 May 2020 08:57:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e01e1a97-f4d7-4ef8-9a88-ae33ad177123</guid><dc:creator>simone.bonetti</dc:creator><description>&lt;p&gt;No, i cannot workaround the issue that way. In the peripheral device, i deliberately set the following address 00:15:42:XX:XX:XX as public,&amp;nbsp;and the addr_type information is correctly encoded&amp;nbsp;the inside the TxAdd/RxAdd bits in the advertising PDU. That&amp;#39;s the configuration i&amp;#39;m using:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static ble_gap_addr_t m_dev_address =
{
    .addr_type    = BLE_GAP_ADDR_TYPE_PUBLIC,                                       /**&amp;lt; See @ref BLE_GAP_ADDR_TYPES. */
    .addr         = {0xAA,0xBB,0xCC,0x42,0x15,0x00}                                 /**&amp;lt; 48-bit address, LSB format. */
};&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;i cannot change that configuration because we registered our company MAC address in the IEEE on purpose and it needs to be identified as &amp;quot;public&amp;quot; by all the devices (third party smarphones and such) that can perform a scan as a central role.&lt;/p&gt;
&lt;p&gt;The central device i&amp;#39;m developing with a nrf52833 correctly identifies the peripheral device as &amp;quot;public&amp;quot; if i do not add any filter to the scan activity, so&amp;nbsp;the scan report is working correctly.&lt;/p&gt;
&lt;p&gt;The current implementation of&amp;nbsp;&lt;em&gt;nrf_ble_scan_addr_filter_add&lt;/em&gt;&lt;span&gt;&amp;nbsp; accepts a simple 48-bit address and does not allow me to specify the type to correctly setup the filter, instead it wrongly infers the type based on the first 2 bits (which in my case ends up with a&amp;nbsp;&amp;quot;Non-resolvable private address&amp;quot;), there&amp;#39;s no way to workaround the filter.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;In my opinion the &lt;em&gt;nrf_ble_scan_addr_filter_add &lt;/em&gt;function&amp;nbsp;should work as&amp;nbsp;&lt;em&gt;sd_ble_gap_addr_set.&amp;nbsp;&lt;/em&gt;The user shall specify the address AND if the address is just PUBLIC or RANDOM. Then, IF is RANDOM, the function may infer the sub-types (resolvable, non-resolvable) based on the MSB, but if it&amp;#39;s PUBLIC, no assumptions on the MSB values should be made.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Another thing that i don&amp;#39;t like is that the function&amp;nbsp;&lt;em&gt;nrf_ble_scan_addr_filter_add&amp;nbsp;&lt;/em&gt;inverts the passed address&amp;nbsp; to convert it to LSB format. It leads to confusion since it&amp;#39;s not clear to the caller which format is expected. Using&amp;nbsp;&lt;em&gt;ble_gap_addr_t&lt;/em&gt;&lt;/span&gt;&lt;span&gt;&amp;nbsp;as input parameter (which is clearly stated to use LSB format), and getting rid of the inversion inside the function, would solve this as well.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;That&amp;#39;s&amp;nbsp;basically&amp;nbsp;the same that&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/members/ajkahl"&gt;ajkahl&lt;/a&gt; suggested previously as a fix.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Is there a more official way to open a ticket to the SDK devs or will you handle the submission yourself?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks for the support!&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: issues with public address type when applying scan filter</title><link>https://devzone.nordicsemi.com/thread/251584?ContentTypeID=1</link><pubDate>Tue, 26 May 2020 03:01:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7b8c4cbb-4a8c-478e-962c-d0f9d5eeb2be</guid><dc:creator>ajkahl</dc:creator><description>&lt;p&gt;Ignore the above, I had max/min connection interval params mucked up. Works now, Cheers!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: issues with public address type when applying scan filter</title><link>https://devzone.nordicsemi.com/thread/251583?ContentTypeID=1</link><pubDate>Tue, 26 May 2020 02:28:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:652f6332-4a73-4fd9-bcec-3d89206662b7</guid><dc:creator>ajkahl</dc:creator><description>&lt;p&gt;Hi Simone, I can&amp;#39;t seem to&amp;nbsp;get&amp;nbsp;sd_ble_gap_connect to work, it returns&amp;nbsp;NRF_ERROR_INVALID_PARAM, which is:&lt;/p&gt;
&lt;p&gt;// * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.&lt;br /&gt;// * - Invalid parameter(s) in p_scan_params or p_conn_params.&lt;br /&gt;// * - Use of whitelist requested but whitelist has not been set, see @ref sd_ble_gap_whitelist_set.&lt;br /&gt;// * - Peer address was not present in the device identity list, see @ref sd_ble_gap_device_identities_set.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m looking at the last item above and wondering what that&amp;#39;s about. Are your m_scan.scan_params &amp;amp; m_scan.conn_params just set to defaults?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: issues with public address type when applying scan filter</title><link>https://devzone.nordicsemi.com/thread/251434?ContentTypeID=1</link><pubDate>Mon, 25 May 2020 09:32:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8c71a8c4-cfc4-4c27-bc8e-7d315da25e10</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;It seems you are correct. I don&amp;#39;t know why I thought that the public addresses needed to start with 0b01 (probably because of the SDK).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Is there a problem saying that the address is the format that you need to use in order to add it to the filter? Non-resolvable private address in the 0b00 case?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: issues with public address type when applying scan filter</title><link>https://devzone.nordicsemi.com/thread/251425?ContentTypeID=1</link><pubDate>Mon, 25 May 2020 09:18:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:97f49163-38e0-48a2-9a20-e94a47f40c32</guid><dc:creator>ajkahl</dc:creator><description>&lt;p&gt;thanks for the info, glad you&amp;#39;ve found a solution. I&amp;#39;ll definitely play around with alternatives to the scan/connect.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: issues with public address type when applying scan filter</title><link>https://devzone.nordicsemi.com/thread/251411?ContentTypeID=1</link><pubDate>Mon, 25 May 2020 08:49:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:612271da-6508-41f4-a3f0-89c4d0f777d7</guid><dc:creator>simone.bonetti</dc:creator><description>&lt;p&gt;I managed to find a workaround to the issue with the following code:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static ble_gap_addr_t companion_gap_addr;

bool ble_app_start_comm_test(uint8_t * server_addr)
{
    ret_code_t err_code;

    nrf_ble_scan_copy_addr_to_sd_gap_addr(&amp;amp;companion_gap_addr,server_addr);
    
    //overriding due to a possibile issue inside stack inside function &amp;quot;nrf_ble_scan_address_type_decode&amp;quot;
    companion_gap_addr.addr_type = BLE_GAP_ADDR_TYPE_PUBLIC; 


    err_code = sd_ble_gap_connect(&amp;amp;companion_gap_addr,&amp;amp;m_scan.scan_params,&amp;amp;m_scan.conn_params,APP_BLE_CONN_CFG_TAG);
    APP_ERROR_CHECK(err_code);

    return true;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;basically, in my application,&amp;nbsp;a&amp;nbsp;host device sends via UART the known MAC adddress of the device it wants to connect to in the following format ( 00:15:42:XX:XX:XX ).&lt;/p&gt;
&lt;p&gt;i internally convert it to the LSB format required by the SDK and i override the (wrong?) decoded address type to a PUBLIC one.&lt;/p&gt;
&lt;p&gt;Instead of scanning with an address filter, i issue a direct connect command with the given MAC address. It works.&lt;/p&gt;
&lt;p&gt;Maybe it can help you with your application.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: issues with public address type when applying scan filter</title><link>https://devzone.nordicsemi.com/thread/251402?ContentTypeID=1</link><pubDate>Mon, 25 May 2020 08:28:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4635f179-9f7a-4af3-98fc-0481fbaecd49</guid><dc:creator>ajkahl</dc:creator><description>&lt;p&gt;I concur with Simone, &lt;br /&gt;&lt;br /&gt;I&amp;nbsp;cannot find any reference to any restriction on the top bits of an IEEE MAC used as a BD_ADDR. &lt;br /&gt;&lt;br /&gt;I cannot find any evidence to support the claim &amp;quot;&lt;span&gt;according to the BLE specification the MSB should be 0b01&amp;quot;. Please provide it if it exists.&lt;br /&gt;&lt;br /&gt;The only limitations imposed on the usage of an IEEE MAC is the block of 64 LAPs used for inquiry operations. &lt;br /&gt;&lt;br /&gt;The difference between a public and random address is solely&amp;nbsp;indicated by txAddr/rxAddr bit (a 49th bit if you will).&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: issues with public address type when applying scan filter</title><link>https://devzone.nordicsemi.com/thread/251393?ContentTypeID=1</link><pubDate>Mon, 25 May 2020 07:55:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d8e13fcd-8339-46a1-b1cd-5f4a3529b491</guid><dc:creator>simone.bonetti</dc:creator><description>&lt;p&gt;Thanks for the reply! are you sure about the following statement?&lt;/p&gt;
&lt;p&gt;&amp;quot;&lt;span&gt;If the device has a public address, then according to the BLE specification the MSB should be 0b01&amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I cannot find any evidence of it inside the BLE Core Specifications i&amp;#39;m referencing:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;BLUETOOTH CORE SPECIFICATION Version 5.1 | Vol 6, Part B, Chapter 1.3&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I also found the following post:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/27012/how-to-distinguish-between-random-and-public-gap-addresses"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/27012/how-to-distinguish-between-random-and-public-gap-addresses&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;in which &lt;a href="https://devzone.nordicsemi.com/members/endnode"&gt;endnode&lt;/a&gt;&amp;nbsp; showed some screenshots from the BLE training course in which it&amp;#39;s stated that a PUBLIC address cannot be distinguished from a RANDOM one just by looking at the 48-bit address, since it&amp;#39;s the TxAdd/RxAdd bit that serves the purpose.&lt;/p&gt;
&lt;p&gt;As my understanding, the 24-bit Company IDs (which are assigned by the IEEE) have no restrictions on the bytes value, and in my specific case my company has a IEEE assigned MAC address equal to 00:15:42. (if you put 00:15:42 here&amp;nbsp;&lt;a href="https://macvendors.com/"&gt;https://macvendors.com/&lt;/a&gt;&amp;nbsp;you can see that it&amp;nbsp;matches&amp;nbsp;with MICROHARD S.R.L. which is the company i&amp;#39;m working for).&lt;/p&gt;
&lt;p&gt;All the devices we&amp;#39;re producing have the following MAC address format:&amp;nbsp; 00:15:42:XX:YY:ZZ and since we&amp;#39;re planning to use a Nordic device for the next products we&amp;#39;re facing issues scanning with the current SDK implementation of the address filtering.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: issues with public address type when applying scan filter</title><link>https://devzone.nordicsemi.com/thread/251390?ContentTypeID=1</link><pubDate>Mon, 25 May 2020 07:23:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:518247ec-18b9-48a2-b2ae-0c226afb8f75</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Do any of you have a sniffer trace of the advertising device? Is it a device that you have made yourself, or 3rd party devices? If the device has a public address, then according to the BLE specification the MSB should be 0b01, so in my opinion, it is not an SDK bug. I believe this rule overrules the public MAC address for the advertising device.&lt;/p&gt;
&lt;p&gt;If it is a 3rd party device, are you sure the address is in fact starting with 0b00?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you have created the advertising device yourselves, then I believe you need to look into whether or not you are allowed to use that address or not before going to certification with Bluetooth SIG.&lt;/p&gt;
&lt;p&gt;As for the scan address type function, you should be able to just change it, but that will possibly only delay your issues until certification, if the advertising device is not using a valid BLE address.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: issues with public address type when applying scan filter</title><link>https://devzone.nordicsemi.com/thread/251216?ContentTypeID=1</link><pubDate>Fri, 22 May 2020 10:03:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3820b2ed-8a53-418e-8432-a894edd0dc2b</guid><dc:creator>simone.bonetti</dc:creator><description>&lt;p&gt;i&amp;#39;m facing exactly the same issue. My company has a registered IEEE MAC address with the following format:&amp;nbsp;00:15:42:XX:YY:ZZ and i want to filter a specific device upon scan.&lt;/p&gt;
&lt;p&gt;The peripheral device has been setup with the following configuration and i can correctly see the MAC address during advertising (from a phone using&amp;nbsp;nRF Connect)&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static ble_gap_addr_t m_dev_address =
{
    .addr_type    = BLE_GAP_ADDR_TYPE_PUBLIC,                                       /**&amp;lt; See @ref BLE_GAP_ADDR_TYPES. */
    .addr         = {0xAA,0xBB,0xCC,0x42,0x15,0x00}                                 /**&amp;lt; 48-bit address, LSB format. */
};&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I tried to setup a central device with an address scan filter, but since the&amp;nbsp;2 MSB of my address is 0b00, it is automatically decoded as &amp;quot;Non-Resolvable Private Address&amp;quot; by the function &amp;quot;nrf_ble_scan_address_type_decode&amp;quot; as &lt;a href="https://devzone.nordicsemi.com/members/ajkahl"&gt;ajkahl&lt;/a&gt; noted, and the scan filter fails to work.&lt;/p&gt;
&lt;p&gt;The function expects the address to be decoded as &amp;quot;Public&amp;quot;&amp;nbsp;if its MSB&amp;nbsp;is 0b01,&amp;nbsp;but this&amp;nbsp;is not compliant with the BT specification, as stated by &lt;a href="https://devzone.nordicsemi.com/members/ajkahl"&gt;ajkahl&lt;/a&gt; in the first post.&lt;/p&gt;
&lt;p&gt;i&amp;#39;m actually struggling to find a workaround for this, because with the current implementation of &amp;quot;the&amp;nbsp;&amp;nbsp;nrf_ble_scan_address_type_decode&amp;quot; function its impossible to use an address scan filter with the MAC address i&amp;#39;m providing.&lt;/p&gt;
&lt;p&gt;Can you please confirm that it&amp;#39;s a SDK bug? or else me and &lt;a href="https://devzone.nordicsemi.com/members/ajkahl"&gt;ajkahl&lt;/a&gt; have some serious issues into understanding BT specifications &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f606.svg" title="Laughing"&gt;&amp;#x1f606;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: issues with public address type when applying scan filter</title><link>https://devzone.nordicsemi.com/thread/251093?ContentTypeID=1</link><pubDate>Thu, 21 May 2020 02:33:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:eb8831a5-da26-422a-82ac-7693761e01cd</guid><dc:creator>ajkahl</dc:creator><description>&lt;p&gt;Thanks Edvin, I&amp;#39;m still not understanding what is happening here and if I&amp;#39;m missing something completely as far as the BT spec goes, but It might help if I run through my specific example and symptoms:&lt;/p&gt;
&lt;p&gt;- The peripheral I&amp;#39;m scanning for is a rigado BMD300 with a factory programmed IEEE MAC, in this case the rigado format is 94:54:93:XX:YY:ZZ&lt;/p&gt;
&lt;p&gt;- The peripheral address type is set to public&lt;/p&gt;
&lt;p&gt;- I can scan for and connect to this using nRF connect without issue, and the mac/address shows as per the above format&lt;/p&gt;
&lt;p&gt;- Given the address starts with 9 we know the top&amp;nbsp;two bits are 0b10&lt;/p&gt;
&lt;p&gt;- According to the ble spec above this would decode as &amp;#39;reserved&amp;#39;, which, given it should definitely not be any of the others I&amp;#39;m going to make the assumption for now that this might now be used for public addresses&lt;/p&gt;
&lt;p&gt;- When debugging the decode function responds with case 2 (naturally) - &amp;#39;random private&amp;nbsp;resolvable&amp;#39; and hence the scan/connect fails.&lt;/p&gt;
&lt;p&gt;Now I feel this is all pretty moot, because as I state above the determination of whether an address is public or not &lt;strong&gt;isn&amp;#39;t&lt;/strong&gt; decodable by the top two bits of the&amp;nbsp;address, and hence my issue with the library decode function. According to the spec, and&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/27012/how-to-distinguish-between-random-and-public-gap-addresses"&gt;this post&amp;nbsp;&lt;/a&gt;&amp;nbsp;an extra flag bit is used to indicate if an address is public, AFAICT this is set on the advertising device using&amp;nbsp;&lt;em&gt;sd_ble_gap_privacy_set.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;So the issue to me seems that&amp;nbsp;&lt;em&gt;nrf_ble_scan_addr_filter_add&lt;/em&gt; ignores the explicit address type as it exists in&amp;nbsp;&lt;em&gt;ble_gap_addr_t&amp;nbsp;&lt;/em&gt;and instead uses&amp;nbsp;&lt;em&gt;nrf_ble_scan_address_type_decode&amp;nbsp;&lt;/em&gt;which inevitably does not return the desired result, because it simply&amp;nbsp;isn&amp;#39;t given enough information to do so, namely is the address type public or not.&lt;/p&gt;
&lt;p&gt;A simple fix in this case might be to pass the entire&amp;nbsp;&lt;em&gt;ble_gap_addr_t&amp;nbsp;&lt;/em&gt;to&amp;nbsp;&lt;em&gt;nrf_ble_scan_addr_filter_add&lt;/em&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;and use the address type specified there (or at the very least if set to public, do not use the decode function). Additionally then resolving the fact the decode function does not match the spec.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: issues with public address type when applying scan filter</title><link>https://devzone.nordicsemi.com/thread/250945?ContentTypeID=1</link><pubDate>Wed, 20 May 2020 11:49:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1e82232d-9125-40ad-96d4-cfa62c39a3b8</guid><dc:creator>Edvin</dc:creator><description>[quote user="ajkahl"]I&amp;nbsp;can&amp;#39;t see where those bits are swapped?[/quote]
&lt;p&gt;Sorry. I i mixed it up. It isn&amp;#39;t.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="ajkahl"]but in any case the decode function returns the sub-type of a random address type,&amp;nbsp;a public address, according to the spec referenced, is not part of this.[/quote]
&lt;p&gt;&amp;nbsp;I think that are only different names for the same thing. The two first (or last, depending on what way you look at it), is declaring what type of address it is.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Please see carles&amp;#39; answer in &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/2084/gap-address-types" rel="noopener noreferrer" target="_blank"&gt;this ticket&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Are you referring to the public addresses that you purchase through IEEE? How the assigning of these are actually done, I am not sure, but in BLE,&amp;nbsp;you need to us 0b01 for a public address.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: issues with public address type when applying scan filter</title><link>https://devzone.nordicsemi.com/thread/250843?ContentTypeID=1</link><pubDate>Wed, 20 May 2020 02:00:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9097ccc1-8723-4fdf-8335-748301c5108f</guid><dc:creator>ajkahl</dc:creator><description>[quote userid="26071" url="~/f/nordic-q-a/61512/issues-with-public-address-type-when-applying-scan-filter/250731"]Please note that from the Bluetooth Specification has &amp;quot;Address [47;46]&amp;quot;, while the SDK use 46;47, so the bit order is swapped.[/quote]
&lt;p&gt;I&amp;nbsp;can&amp;#39;t see where those bits are swapped? but in any case the decode function returns the sub-type of a random address type,&amp;nbsp;a public address, according to the spec referenced, is not part of this.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m assuming that a public MAC used in this scenario is not limited to having the top 2 bits of it&amp;#39;s MSB set to 10 (or in fact restricted to anything that would reliably decode an address type or sub-type).&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: issues with public address type when applying scan filter</title><link>https://devzone.nordicsemi.com/thread/250731?ContentTypeID=1</link><pubDate>Tue, 19 May 2020 12:58:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dab586db-c4f2-4982-a7f2-de589e950f78</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Please note that from the Bluetooth Specification has &amp;quot;Address [47;46]&amp;quot;, while the SDK use 46;47, so the bit order is swapped.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user=""]which attempts to decode the type from the given address itself, from what I can tell this will only work with non-public (or random) addresses[/quote]
&lt;p&gt;&amp;nbsp;Why is that?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>