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

How to apply whitelist during advertisement?

Hi,

I am trying to apply a whitelist during advertisement on my peripheral device. Only one central should be whitelisted at a time. The whitelist is empty on initial boot up. I am using BLE_GAP_ADV_FP_FILTER_CONNREQ, but I always get NRF_ERROR_INVALID_PARAM, using my configuration. I am guessing this is because I haven't told the SoftDevice which whitelist to use (?). How can I adjust my setup in order to make this work? I appreciate any help.

Advertising Init:

static void advertising_init(void)
{
    ret_code_t               err_code;
    ble_advdata_t            advdata;
    ble_advdata_t            srdata;
    ble_gap_adv_params_t     adv_params;
    ble_advdata_manuf_data_t adv_manuf_data;

    memset(&advdata, 0, sizeof(advdata));

    advdata.name_type          = BLE_ADVDATA_FULL_NAME;
    advdata.include_appearance = true;
    advdata.flags              = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;

    memset(&srdata, 0, sizeof(srdata));
    srdata.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
    srdata.uuids_complete.p_uuids  = m_adv_uuids;

    err_code = ble_advdata_encode(&advdata, m_adv_data.adv_data.p_data, &m_adv_data.adv_data.len);
    APP_ERROR_CHECK(err_code);

    err_code = ble_advdata_encode(&srdata, m_adv_data.scan_rsp_data.p_data, &m_adv_data.scan_rsp_data.len);
    APP_ERROR_CHECK(err_code);

    memset(&adv_params, 0, sizeof(adv_params));
    adv_params.p_peer_addr   = NULL;
    adv_params.filter_policy = BLE_GAP_ADV_FP_FILTER_CONNREQ;
    adv_params.interval      = APP_ADV_INTERVAL;

    adv_params.properties.type = BLE_GAP_ADV_TYPE_CONNECTABLE_SCANNABLE_UNDIRECTED;
    adv_params.duration        = APP_ADV_DURATION;
    adv_params.primary_phy     = BLE_GAP_PHY_1MBPS;

    err_code = sd_ble_gap_adv_set_configure(&m_adv_handle, &m_adv_data, &adv_params);
    APP_ERROR_CHECK(err_code);
}

Whitelisting:

static pm_peer_id_t m_peer_id;

static void whitelist_connected_peer()
{
    ret_code_t err_code;
    err_code = pm_whitelist_set(&m_peer_id, 1);
    APP_ERROR_CHECK(err_code);
}

Edit: Clear clumsy text.

Parents Reply Children
No Data
Related