This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How Can I Implement Whiteist In SDK 15.2.0

i'm trying to build a scanner that scan only a list of devices , and i want to use a whitelist .

i didn't understand the concept of the new whitelisting in SDK 15.2.0, i tried to use ble_app_uart example but it didn't work

the programme that i want to implement very simple just a scanner with withlist , please help me on that

thanks

Parents
  • How do you set the whitelist? Could you share the main.c file?

    Best regards,

    Simon

  • sorry i'm using ble_app_hrs_c exemple not ble_app_uart .

    i didn't know how to use it ,i just add adresses to whitelist buffer 

    ble_gap_addr_t       dkAdrs1     = {0,BLE_GAP_ADDR_TYPE_RANDOM_STATIC,{0x03,0xCC,0xD2,0xF4,0x30,0xEB}};
    ble_gap_addr_t       dkAdrs2     = {0,BLE_GAP_ADDR_TYPE_RANDOM_STATIC,{0xEC,0xAD,0xD6,0xA2,0x56,0x67}};//EC:AD:D6:A2:56:67
     
    static void on_whitelist_req(void)
    {
        ret_code_t err_code;
    
       // Whitelist buffers.
        ble_gap_addr_t whitelist_addrs[8]={dkAdrs1,dkAdrs2};
        ble_gap_irk_t  whitelist_irks[8];
    
        memset(whitelist_addrs, 0x00, sizeof(whitelist_addrs));
        memset(whitelist_irks,  0x00, sizeof(whitelist_irks));
        
          
        uint32_t addr_cnt = (sizeof(whitelist_addrs) / sizeof(ble_gap_addr_t));
        uint32_t irk_cnt  = (sizeof(whitelist_irks)  / sizeof(ble_gap_irk_t));
    
        // Reload the whitelist and whitelist all peers.
        whitelist_load();
    
        // Get the whitelist previously set using pm_whitelist_set().
        err_code = pm_whitelist_get(whitelist_addrs, &addr_cnt,
                                    whitelist_irks,  &irk_cnt);
    
        if (((addr_cnt == 0) && (irk_cnt == 0)) ||
            (m_whitelist_disabled))
        {
            // Don't use whitelist.
            NRF_LOG_INFO("=> Don't use whitelist");
            err_code = nrf_ble_scan_params_set(&m_scan, NULL);
            APP_ERROR_CHECK(err_code);
        }
    }
    

Reply
  • sorry i'm using ble_app_hrs_c exemple not ble_app_uart .

    i didn't know how to use it ,i just add adresses to whitelist buffer 

    ble_gap_addr_t       dkAdrs1     = {0,BLE_GAP_ADDR_TYPE_RANDOM_STATIC,{0x03,0xCC,0xD2,0xF4,0x30,0xEB}};
    ble_gap_addr_t       dkAdrs2     = {0,BLE_GAP_ADDR_TYPE_RANDOM_STATIC,{0xEC,0xAD,0xD6,0xA2,0x56,0x67}};//EC:AD:D6:A2:56:67
     
    static void on_whitelist_req(void)
    {
        ret_code_t err_code;
    
       // Whitelist buffers.
        ble_gap_addr_t whitelist_addrs[8]={dkAdrs1,dkAdrs2};
        ble_gap_irk_t  whitelist_irks[8];
    
        memset(whitelist_addrs, 0x00, sizeof(whitelist_addrs));
        memset(whitelist_irks,  0x00, sizeof(whitelist_irks));
        
          
        uint32_t addr_cnt = (sizeof(whitelist_addrs) / sizeof(ble_gap_addr_t));
        uint32_t irk_cnt  = (sizeof(whitelist_irks)  / sizeof(ble_gap_irk_t));
    
        // Reload the whitelist and whitelist all peers.
        whitelist_load();
    
        // Get the whitelist previously set using pm_whitelist_set().
        err_code = pm_whitelist_get(whitelist_addrs, &addr_cnt,
                                    whitelist_irks,  &irk_cnt);
    
        if (((addr_cnt == 0) && (irk_cnt == 0)) ||
            (m_whitelist_disabled))
        {
            // Don't use whitelist.
            NRF_LOG_INFO("=> Don't use whitelist");
            err_code = nrf_ble_scan_params_set(&m_scan, NULL);
            APP_ERROR_CHECK(err_code);
        }
    }
    

Children
  • What you are doing here will not set the whitelist. The arrays whitelist_addrs and whitelist_irks are sent into the function pm_whitelist_get(..), and that function simply store the whitelist into the arrays (addresses and the belonging irk's), which is previously set using pm_whitelist_set().

    However, the whitelist is set inside the function whitelist_load() thorugh the function pm_whitelist_set(). Normally a whitelist is set based on the bonded peers stored in flash, and you can see that this is done first by looking inside the function whitelist_load(). First the peer ID's are loaded from flash through peer_list_get(), and those peers are then whitelisted through pm_whitelist_set().

    It seems like you want to set the whitelist manually, and here is a link that explains how to do that.

    Best regards,

    Simon

  • thank you
    yes . i want to set the whitelist manually , i follow the link but it didn't work in SDK 15.2.

    for example : there is no type named   ble_gap_whitelist_t

    how can i set whitelist manually , is there an example in SDK 15.2

  • I am sorry, the whitelist in the tutorial I pointed you to was using an older SDK. In SDK 15.2 you have to use the function sd_ble_gap_whitelist_set(). Here is a thread that demonstrates how to do it with SDK 13, and I think the approach is the same with SDK 15.2.

    Please tell me if you encounter any more problems.

    Best regards,

    Simon

  • thanks .

    I think you misunderstood me.

    i'm trying to build a scanner with whitelist , which means a ble central (gateway) , scan only a list of advertiser (non-connectable advertiser).

    not an advertiser that advertise with whitelist .

    please help me on that , i just need an example of enabling whitelist and adding the list of addresses

  • It doesn't matter if you are scanning or advertising, it is set the same way. You use the function sd_ble_gap_whitelist_set() for both cases.

    Best regards,

    Simon

Related