<?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>Whitelisting in Gatt Server mode (SDK 15.2 /nrf52840)</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/60222/whitelisting-in-gatt-server-mode-sdk-15-2-nrf52840</link><description>Im using sdk 15.2 with 2 nrf52840 boards, i would like the server to connect to a particular client. How to add the devices to whitelist in sdk 15.2 ?. I have gone through various blogs and I have used the following snippet, but the server connects to</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 29 Sep 2020 14:03:32 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/60222/whitelisting-in-gatt-server-mode-sdk-15-2-nrf52840" /><item><title>RE: Whitelisting in Gatt Server mode (SDK 15.2 /nrf52840)</title><link>https://devzone.nordicsemi.com/thread/272092?ContentTypeID=1</link><pubDate>Tue, 29 Sep 2020 14:03:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0a584658-784e-4b69-aaad-7edccf86d028</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;Try to add it in the following manner instead:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static ble_gap_scan_params_t m_scan_param =                               /**&amp;lt; Scan parameters requested for scanning and connection. */
{
    // Other params
    .filter_policy = BLE_GAP_SCAN_FP_WHITELIST,
    // Other params
};

.
.
.
.

/**@brief Function to start scanning. */
static void scan_start(void)
{
    ret_code_t ret;

    ret = nrf_ble_scan_params_set(&amp;amp;m_scan, &amp;amp;m_scan_param);

.
.
static void scan_init(void)
{
    .
    .
    .
    init_scan.p_scan_param     = &amp;amp;m_scan_param;&lt;/pre&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><item><title>RE: Whitelisting in Gatt Server mode (SDK 15.2 /nrf52840)</title><link>https://devzone.nordicsemi.com/thread/269946?ContentTypeID=1</link><pubDate>Wed, 16 Sep 2020 19:47:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4694b271-3a5c-4796-9670-021113a56ff2</guid><dc:creator>preethi16</dc:creator><description>&lt;p&gt;Hi Simon,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Sorry for the long delay. No have not made any progress. It is still the same like i have said before . i get that error when i make those changes.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Preethi&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Whitelisting in Gatt Server mode (SDK 15.2 /nrf52840)</title><link>https://devzone.nordicsemi.com/thread/251367?ContentTypeID=1</link><pubDate>Sun, 24 May 2020 21:44:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3a2963b3-d109-48b7-a537-9c4d67e3462e</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;I am sorry for the long delay, I&amp;#39;ve been quite busy lately. Have you made any progress on this?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Whitelisting in Gatt Server mode (SDK 15.2 /nrf52840)</title><link>https://devzone.nordicsemi.com/thread/248311?ContentTypeID=1</link><pubDate>Tue, 05 May 2020 20:51:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:34820e8c-0f4c-4cd1-9cd8-a04e73a248fa</guid><dc:creator>preethi16</dc:creator><description>&lt;p&gt;Hi Simon ,&lt;/p&gt;
&lt;p&gt;I tired compiling with your changes and it throw me an error reporting the filter_policy is just read only. I have attached the screen post along with this message.&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1588711884821v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Preethi,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Whitelisting in Gatt Server mode (SDK 15.2 /nrf52840)</title><link>https://devzone.nordicsemi.com/thread/247818?ContentTypeID=1</link><pubDate>Mon, 04 May 2020 10:18:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a1496969-7829-404d-b500-e0099c7643c7</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;I have not tested this, but I think I figured out how to do this with the scanner (all changes are done to &lt;span&gt;ble_app_uart_c/main.c&lt;/span&gt;):&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;In scan_init(),&amp;nbsp;after&amp;nbsp;&lt;em&gt;memset(&amp;amp;init_scan, 0, sizeof(init_scan))&lt;/em&gt;, set &lt;em&gt;init_scan.scan_param-&amp;gt;filter_policy=BLE_GAP_SCAN_FP_WHITELIST&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;In ble_app_uart_c/main.c, under &lt;em&gt;scan_evt_handler()--&amp;gt;case&amp;nbsp;&lt;/em&gt;
&lt;div&gt;&lt;span&gt;&lt;em&gt;NRF_BLE_SCAN_EVT_WHITELIST_REQUEST&lt;/em&gt; you should set the whitelist using&amp;nbsp;&lt;/span&gt;
&lt;div&gt;
&lt;div&gt;&lt;em&gt;sd_ble_gap_whitelist_set()&lt;/em&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Could you report back to me if this works or not.&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><item><title>RE: Whitelisting in Gatt Server mode (SDK 15.2 /nrf52840)</title><link>https://devzone.nordicsemi.com/thread/247184?ContentTypeID=1</link><pubDate>Wed, 29 Apr 2020 02:21:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ae1edf58-86a4-4e1f-ae83-5942f38566ed</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;I will be gone until monday (4th of may) and I&amp;#39;m not able to look at &lt;br /&gt;your issue until then&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Whitelisting in Gatt Server mode (SDK 15.2 /nrf52840)</title><link>https://devzone.nordicsemi.com/thread/245655?ContentTypeID=1</link><pubDate>Mon, 20 Apr 2020 19:49:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:83166aa4-6a3c-4a60-a9f0-e9b3dd799204</guid><dc:creator>preethi16</dc:creator><description>&lt;p&gt;Hi Simon ,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks for the detailed reply. I am trying on ble_peripheral where im whitelisting while using a scanner. It would be very nice of you if you can show how to whitelist in scanning in a peripheral/gatt server . I have done similar steps in the ble scanning evt handler.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Preethi.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Whitelisting in Gatt Server mode (SDK 15.2 /nrf52840)</title><link>https://devzone.nordicsemi.com/thread/245349?ContentTypeID=1</link><pubDate>Sat, 18 Apr 2020 16:02:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d65da55e-c554-4b04-b004-be8a5077f483</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;I managed to make it work using respectively&amp;nbsp;&lt;em&gt;\nRF5_SDK_15.2.0\examples\ble_peripheral\ble_app_uart &lt;/em&gt;and&lt;em&gt;&amp;nbsp;nRF5_SDK_15.2.0\examples\ble_central\ble_app_uart_c.&amp;nbsp;&lt;/em&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;In &lt;strong&gt;ble_app_uart_c/main.c&lt;/strong&gt; I figured out the address and address type by using&amp;nbsp;&lt;em&gt;sd_ble_gap_addr_get():&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;ret_code_t err_code;
    ble_gap_addr_t mac_addr;
    err_code = sd_ble_gap_addr_get(&amp;amp;mac_addr); 
    APP_ERROR_CHECK(err_code);

    if(BLE_GAP_ADDR_TYPE_PUBLIC == mac_addr.addr_type){
        NRF_LOG_INFO(&amp;quot;Address type is BLE_GAP_ADDR_TYPE_PUBLIC&amp;quot;);
    }else if(BLE_GAP_ADDR_TYPE_RANDOM_STATIC == mac_addr.addr_type){
        NRF_LOG_INFO(&amp;quot;Address type is BLE_GAP_ADDR_TYPE_RANDOM_STATIC&amp;quot;);
    } else if(BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE == mac_addr.addr_type){
        NRF_LOG_INFO(&amp;quot;Address type is BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE&amp;quot;);
    } else if(BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_NON_RESOLVABLE == mac_addr.addr_type){
        NRF_LOG_INFO(&amp;quot;Address type is BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_NON_RESOLVABLE&amp;quot;);
    } else if(BLE_GAP_ADDR_TYPE_ANONYMOUS == mac_addr.addr_type){
        NRF_LOG_INFO(&amp;quot;Address type is BLE_GAP_ADDR_TYPE_ANONYMOUS&amp;quot;);
    }
    
    NRF_LOG_INFO(&amp;quot;Address: [%X, %X, %X, %X, %X, %X]&amp;quot;, mac_addr.addr[0], mac_addr.addr[1], mac_addr.addr[2], mac_addr.addr[3], mac_addr.addr[4], mac_addr.addr[5]);
&lt;/pre&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;I got the following log:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;Address type is BLE_GAP_ADDR_TYPE_RANDOM_STATIC
&amp;lt;info&amp;gt; app: Address: [D3, EA, 17, FD, E8, FB]&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;In&amp;nbsp;&lt;em&gt;ble_app_uart/main.c&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/em&gt;I made the following changes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span&gt;In main.c --&amp;gt;&amp;nbsp;&lt;em&gt;advertising_init()&lt;/em&gt; I added the following:&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;init.config.ble_adv_whitelist_enabled = true;&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span&gt;In the top of main.c --&amp;gt;on_adv_evt() I added the following:&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;ble_gap_addr_t whitelist_addr = {1, BLE_GAP_ADDR_TYPE_RANDOM_STATIC, {0xD3, 0xEA, 0x17, 0xFD, 0xE8, 0xFB}};
ble_gap_addr_t const     *p_whitelist_addr[] = {&amp;amp;whitelist_addr};&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span&gt;In&amp;nbsp; main.c --&amp;gt;on_adv_evt() I added a new case:&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;        case BLE_ADV_EVT_WHITELIST_REQUEST:
            err_code = sd_ble_gap_whitelist_set(p_whitelist_addr, 1);
            APP_ERROR_CHECK(err_code);
            err_code = ble_advertising_whitelist_reply(&amp;amp;m_advertising, &amp;amp;whitelist_addr, 1, NULL, 0);
            APP_ERROR_CHECK(err_code);
            break;&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;You can also use scan filtering, which filters on a higher level of abstraction than the SoftDevice, read more about the difference &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/45034/scan-with-whitelist-vs-scan-filtering"&gt;here&lt;/a&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>