<?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>BLE connection through MAC Address Issue.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/55724/ble-connection-through-mac-address-issue</link><description>Hey, what i&amp;#39;m trying to do is the following: 
 - Advertise The unique MAC-Addresse 
 - Scan and connect to a Peripheral Node with a specific MAC-Address 
 
 But it isn&amp;#39;t working 
 My configuration is as following: 
 advertisement setup: 
 
 
 
 scan setup</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 08 Jan 2020 10:10:06 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/55724/ble-connection-through-mac-address-issue" /><item><title>RE: BLE connection through MAC Address Issue.</title><link>https://devzone.nordicsemi.com/thread/228081?ContentTypeID=1</link><pubDate>Wed, 08 Jan 2020 10:10:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6f74c1ce-e8b9-42fd-803a-b6fffc52a208</guid><dc:creator>RSA</dc:creator><description>&lt;p&gt;what solved the issue was for some reason removing the &lt;em&gt;sd_ble_gap_addr_set()&lt;/em&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE connection through MAC Address Issue.</title><link>https://devzone.nordicsemi.com/thread/228008?ContentTypeID=1</link><pubDate>Wed, 08 Jan 2020 00:55:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:71d6926f-6a0a-4ce6-b2b3-d6057ea8e111</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;I was able to achieve this in the following manner:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;I modified the examples &lt;em&gt;examples\ble_peripheral\ble_app_blinky&lt;/em&gt; and&amp;nbsp;&lt;em&gt;examples\ble_central\ble_app_blinky_c&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;In&amp;nbsp;&lt;em&gt;examples\ble_peripheral\ble_app_blinky&amp;nbsp;&lt;/em&gt;I did the following:
&lt;ul&gt;
&lt;li&gt;Built and flashed the example without modifying it
&lt;ul&gt;
&lt;li&gt;If I understand you right, you want to connect to the device based on the unique MAC address. By default, this address will be included in the advertising packet (no need to add it through&amp;nbsp;&lt;em&gt;sd_ble_gap_addr_set()&lt;/em&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;The blinky peripheral device is now advertising, and I used the nRF Connect app on my phone to check what the device/mac address was:&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/400x400/__key/communityserver-discussions-components-files/4/pastedimage1578444503947v2.png" /&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;In the&amp;nbsp;&lt;em&gt;examples\ble_central\ble_app_blinky_c &lt;/em&gt;I did the following:
&lt;ul&gt;
&lt;li&gt;Added address filtering based on the findings above:&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static ble_gap_addr_t const mac_addr =
    {
        .addr_type = BLE_GAP_ADDR_TYPE_RANDOM_STATIC,
        .addr = {0x4C, 0x9E, 0xFE, 0x20, 0x83, 0xD4}
};


static void scan_init(void)
{
    ret_code_t          err_code;
    nrf_ble_scan_init_t init_scan;

    memset(&amp;amp;init_scan, 0, sizeof(init_scan));

    init_scan.connect_if_match = true;
    init_scan.conn_cfg_tag     = APP_BLE_CONN_CFG_TAG;

    err_code = nrf_ble_scan_init(&amp;amp;m_scan, &amp;amp;init_scan, scan_evt_handler);
    APP_ERROR_CHECK(err_code);

    // Setting filters for scanning.
    err_code = nrf_ble_scan_filters_enable(&amp;amp;m_scan, NRF_BLE_SCAN_ADDR_FILTER, false);
    APP_ERROR_CHECK(err_code);

    err_code = nrf_ble_scan_filter_set(&amp;amp;m_scan, SCAN_ADDR_FILTER, mac_addr.addr);
    APP_ERROR_CHECK(err_code);
}&lt;/pre&gt;&lt;/p&gt;
[quote userid="82673" url="~/f/nordic-q-a/55724/ble-connection-through-mac-address-issue/227843"]A thing i have noticed is that a 0 is attached in the avertissement header and that the address is mirrored, why is this?&amp;nbsp;[/quote]
&lt;p&gt;I think this is related to the specific address type. Since you set it to BLE_GAP_ADDR_TYPE_PUBLIC in the peripheral example, the MSBits was set to &amp;#39;0&amp;#39;. Read more about this in these links:&lt;/p&gt;
&lt;ul&gt;
&lt;li&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;/li&gt;
&lt;li&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/2112/how-to-get-6-byte-mac-address-at-nrf51822"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/2112/how-to-get-6-byte-mac-address-at-nrf51822&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE connection through MAC Address Issue.</title><link>https://devzone.nordicsemi.com/thread/227843?ContentTypeID=1</link><pubDate>Tue, 07 Jan 2020 10:17:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9ff58bdb-6aba-4df1-bf91-f34e5266d1d1</guid><dc:creator>RSA</dc:creator><description>&lt;p&gt;The change unfortunately did not fix the issue.&lt;/p&gt;
&lt;p&gt;A thing i have noticed is that a 0 is attached in the avertissement header and that the address is mirrored, why is this?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE connection through MAC Address Issue.</title><link>https://devzone.nordicsemi.com/thread/227221?ContentTypeID=1</link><pubDate>Thu, 02 Jan 2020 11:18:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:29b754a7-c04f-47c5-8635-0d28d715cdf1</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;In the scan setup, try changing the following line:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;err_code = nrf_ble_scan_filter_set(&amp;amp;m_scan, SCAN_ADDR_FILTER, m_mac_filter.addr);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;to the following:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;err_code = nrf_ble_scan_filter_set(&amp;amp;m_scan, SCAN_ADDR_FILTER, mac_addr.addr);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Swap &lt;em&gt;m_mac_filter&lt;/em&gt; with &lt;em&gt;mac_addr&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>