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

how to add devices to whitelist??

hi, im trying to add devices to whitelist.is there any easy way to do it??

thankyou, Sougandh A.K

Parents
  • If it for peripheral you can use this (from ble_app_proximity)

         whitelist.addr_count = BLE_GAP_WHITELIST_ADDR_MAX_COUNT;
         whitelist.irk_count  = BLE_GAP_WHITELIST_IRK_MAX_COUNT;
         whitelist.pp_addrs   = p_whitelist_addr;
         whitelist.pp_irks    = p_whitelist_irk;
    
        err_code = dm_whitelist_create(&m_app_handle, &whitelist);
        APP_ERROR_CHECK(err_code);
    
        if ((whitelist.addr_count != 0) || (whitelist.irk_count != 0))
        {
            adv_params.fp          = BLE_GAP_ADV_FP_FILTER_CONNREQ;
            adv_params.p_whitelist = &whitelist;
    

    for central you can do this

    whitelist.addr_count = BLE_GAP_WHITELIST_ADDR_MAX_COUNT;
    whitelist.irk_count  = 0;
    whitelist.pp_addrs   = p_whitelist_addr;
    whitelist.pp_irks    = p_whitelist_irk;
    
    // Request creating of whitelist.
    err_code = dm_whitelist_create(&m_dm_app_id,&whitelist);
    APP_ERROR_CHECK(err_code);
    
    m_scan_param.active       = 0;            // Active scanning set.
    m_scan_param.selective    = 1;            // Selective scanning not set.
    m_scan_param.interval     = SCAN_INTERVAL;// Scan interval.
    m_scan_param.window       = SCAN_WINDOW;  // Scan window.
    m_scan_param.p_whitelist  = &whitelist;   // Provide whitelist.
    m_scan_param.timeout      = 0x001E;       // 30 seconds timeout.
    
  • Aryan, I don't understand the central part. With your example, you start with selective scanning but there are no devices in the whitelist at that moment yet. Shouldn't you first do non-selective scanning and after a connection with device is established, you should add it to whitelist (but how?). Then next time the central restarts, it should load the whitelist, see if it's not empty and THEN start with selective scanning, right?

Reply
  • Aryan, I don't understand the central part. With your example, you start with selective scanning but there are no devices in the whitelist at that moment yet. Shouldn't you first do non-selective scanning and after a connection with device is established, you should add it to whitelist (but how?). Then next time the central restarts, it should load the whitelist, see if it's not empty and THEN start with selective scanning, right?

Children
No Data
Related