<?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>How to compare the peripheral device adresses and connect from the UART string</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/45856/how-to-compare-the-peripheral-device-adresses-and-connect-from-the-uart-string</link><description>Hi I want to get the peripheral address from the UART and compare with scanned peripheral addresses from the central (nrf52832) and if the received address string is of one of the scanned devices list, the central will connect to that particular device</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 08 Apr 2019 12:58:09 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/45856/how-to-compare-the-peripheral-device-adresses-and-connect-from-the-uart-string" /><item><title>RE: How to compare the peripheral device adresses and connect from the UART string</title><link>https://devzone.nordicsemi.com/thread/180769?ContentTypeID=1</link><pubDate>Mon, 08 Apr 2019 12:58:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:64bd8974-207b-4c5e-bbd5-a40245cc32b2</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;You can modify the NUS central example to connect to a specific address for instance by changing the&amp;nbsp;scan_init() function to this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void scan_init(void)
{
    ret_code_t          err_code;
    nrf_ble_scan_init_t init_scan;
    static uint8_t      addr[BLE_GAP_ADDR_LEN] = {0x45, 0x9F, 0xC7, 0xF7, 0x66, 0xEF};

    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);

    err_code = nrf_ble_scan_filter_set(&amp;amp;m_scan, SCAN_ADDR_FILTER, addr);
    APP_ERROR_CHECK(err_code);

    err_code = nrf_ble_scan_filters_enable(&amp;amp;m_scan, NRF_BLE_SCAN_ADDR_FILTER, false);
    APP_ERROR_CHECK(err_code);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;You also have to modify sdk_config.h, setting&amp;nbsp;NRF_BLE_SCAN_ADDRESS_CNT to 1. This will only connect to a device with BLE MAC address&amp;nbsp;EF:66:F7:C7:9F:45.&lt;/p&gt;
&lt;p&gt;The mechanism is the same if you get the address via UART instead, and then you can update the filter as needed by using&amp;nbsp;nrf_ble_scan_all_filter_remove() to remove an old address and set a new filter. ( In fact the filtering mechanism is quite flexible, but that should not be relevant here. If you are interested, just look at the API documentation in &amp;lt;SDK&amp;gt;\components\ble\nrf_ble_scan\nrf_ble_scan.h&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>