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

Use of whitelist

I m using The nRF52840 + STM32 with serialization library. My device is set in central mode and i want to active whitelist,

the configuration seems to be applied correctly: no error are shown on any side but i don't receive any advertisement frame.

    _scan_param.extended = 1;                // Set if accept extended advertising packetets.
    _scan_param.report_incomplete_evts = 0;  // Set if report inomplete reports.
    _scan_param.active = 1;                  // Set if active scanning.
    _scan_param.filter_policy = BLE_GAP_SCAN_FP_WHITELIST;
    _scan_param.scan_phys = BLE_GAP_PHY_1MBPS;
    _scan_param.interval = (uint16_t) SCAN_INTERVAL;
    _scan_param.window = (uint16_t) SCAN_WINDOW;
    _scan_param.timeout = (uint16_t) SCAN_TIMEOUT;

    ble_gap_addr_t wl_addr_array[BLE_GAP_WHITELIST_ADDR_MAX_COUNT];
    ble_gap_addr_t *array[BLE_GAP_WHITELIST_ADDR_MAX_COUNT];

    for (size_t i = 0; i < _devices.size(); i ++) {
        array[i] = &wl_addr_array[i];
        memcpy(wl_addr_array[i].addr, _devices[i]->get_address(), BLE_BD_ADDR_LEN);
        wl_addr_array[i].addr_id_peer = 0;
        wl_addr_array[i].addr_type = BLE_GAP_ADDR_TYPE_PUBLIC;//BLE_GAP_ADDR_TYPE_RANDOM_STATIC
    }

    uint32_t rc = sd_ble_gap_whitelist_set(wl_addr_array, length);

    if (rc != NRF_SUCCESS) {
        tr_error("Failed to set whitelist: %" PRIu32, rc);
    }

    uint32_t error_code = sd_ble_gap_scan_start(&_scan_param, &_adv_report_buffer);

    if (error_code != NRF_SUCCESS) {
        tr_error("Initial scan start failed: %"  PRIu32, error_code);
    }

The example provided in the following link explains that it is necessary to give the scan event handler as a parameter .

is there an equivalent to the function below use in serialization library?

err_code = nrf_ble_scan_init(&m_scan, &scan_init, scan_evt_handler)

https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v15.3.0%2Flib_ble_scan.html

https://jimmywongiot.com/2019/10/18/ble-scanning-with-whitelist/

Do you think that my configuration is correct?

Do you have an example on the use of whitelist in serialization mode?

Thank you

Related