Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Static / programmable whitelist

Hi,

Is it possible to add a static bluetooth address to the whitelist?

I am using SDK 14.2.0, device is nrf52832 + peer manager.

BR

bjarke

Parents
  • Hi,

    Whitelist can be used both by peripheral (to filter which centrals can connect) and by central (to filter what peripherals to connect to.) I assume that you need this for a peripheral.

    If you use the Advertising Module then it is your responsibility to provide a whitelist on the BLE_ADV_EVT_WHITELIST_REQUEST event.

    You may then choose to fetch a whitelist from peer manager using pm_whitelist_get(), as is done for instance in the HID Mouse Application example.

    Or, in your case, you may make a whitelist manually using any Bluetooth addresses that you would like. The whitelist is an array of ble_gap_addr_t structures and an array of ble_gap_irk_t structures. (The IRK structure is only needed for resolvable addresses, not for static ones.)

    In any case you must reply to the whitelist request event with a call to ble_advertising_whitelist_reply(), where you provide the whitelist.

    Regards,
    Terje

  • Hi,

    I have been looking at ble_advertising.c, and can see that for Softdevice >2, the adresses are not used in the ble_advertising_whitelist_reply(...

    from ble_advertising.c:

    uint32_t ble_advertising_whitelist_reply(ble_advertising_t * const p_advertising,
                                             ble_gap_addr_t    const * p_gap_addrs,
                                             uint32_t               addr_cnt,
                                             ble_gap_irk_t  const * p_gap_irks,
                                             uint32_t               irk_cnt)
    {
        if (!p_advertising->whitelist_reply_expected)
        {
            return NRF_ERROR_INVALID_STATE;
        }
    
        p_advertising->whitelist_reply_expected = false;
    
        #if (NRF_SD_BLE_API_VERSION <= 2)
    
            p_advertising->whitelist.addr_count = addr_cnt;
            p_advertising->whitelist.irk_count  = irk_cnt;
    
            for (uint32_t i = 0; i < addr_cnt; i++)
            {
                *p_advertising->whitelist.pp_addrs[i] = p_gap_addrs[i];
            }
    
            for (uint32_t i = 0; i < irk_cnt; i++)
            {
                *p_advertising->whitelist.pp_irks[i] = p_gap_irks[i];
            }
    
        #else
    
            p_advertising->whitelist_in_use = ((addr_cnt > 0) || (irk_cnt > 0));
    
        #endif
    
        return NRF_SUCCESS;
    }
    

    Any ideas?

    Regards

Reply
  • Hi,

    I have been looking at ble_advertising.c, and can see that for Softdevice >2, the adresses are not used in the ble_advertising_whitelist_reply(...

    from ble_advertising.c:

    uint32_t ble_advertising_whitelist_reply(ble_advertising_t * const p_advertising,
                                             ble_gap_addr_t    const * p_gap_addrs,
                                             uint32_t               addr_cnt,
                                             ble_gap_irk_t  const * p_gap_irks,
                                             uint32_t               irk_cnt)
    {
        if (!p_advertising->whitelist_reply_expected)
        {
            return NRF_ERROR_INVALID_STATE;
        }
    
        p_advertising->whitelist_reply_expected = false;
    
        #if (NRF_SD_BLE_API_VERSION <= 2)
    
            p_advertising->whitelist.addr_count = addr_cnt;
            p_advertising->whitelist.irk_count  = irk_cnt;
    
            for (uint32_t i = 0; i < addr_cnt; i++)
            {
                *p_advertising->whitelist.pp_addrs[i] = p_gap_addrs[i];
            }
    
            for (uint32_t i = 0; i < irk_cnt; i++)
            {
                *p_advertising->whitelist.pp_irks[i] = p_gap_irks[i];
            }
    
        #else
    
            p_advertising->whitelist_in_use = ((addr_cnt > 0) || (irk_cnt > 0));
    
        #endif
    
        return NRF_SUCCESS;
    }
    

    Any ideas?

    Regards

Children
No Data
Related