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

sd_ble_gap_connect: NRF_ERROR_INVALID_PARAM

Hello,

I'm trying to use `sd_ble_gap_connect` to connect to a peer I discovered using `nrf_ble_scan`.

nrf_ble_scan_init_t scan_init{};
scan_init.p_scan_param = &m_scan_param;
scan_init.conn_cfg_tag = 1;

nrf_ble_scan_init(&m_scan, &scan_init, scan_handler);

nrf_ble_scan_start(&m_scan);
Once I find a suitable peer, I do the following to connect to it:
nrf_ble_scan_stop();

res = sd_ble_gap_connect(&buf[last_seen].peer_addr,
&m_scan.scan_params,
&m_scan.conn_params,
m_scan.conn_cfg_tag);

if (res != NRF_SUCCESS) {
printf("sd_ble_gap_connect failed %s", nrf_strerror_get(res));
}
However, I always get 0x7 (invalid param) as my result. I checked my config and I have 5 central links configured. I tried passing NULL as the scan_params and conn_params to scan_init to use the default ones, but that did not help either.
Is there anything obvious that I'm missing?
Parents
  • Can you show me a code snippet of your scan and conn_params, as I think you've used invalid parameters somewhere in there.

    Only one device identity list can be used at a time and the list is shared between the BLE roles. The device identity list cannot be set if a BLE role is using the list.
     
    Best regards,
    Simon
Reply
  • Can you show me a code snippet of your scan and conn_params, as I think you've used invalid parameters somewhere in there.

    Only one device identity list can be used at a time and the list is shared between the BLE roles. The device identity list cannot be set if a BLE role is using the list.
     
    Best regards,
    Simon
Children
  • static ble_gap_scan_params_t const m_scan_param = {
    .active = 0x01,
    .filter_policy = BLE_GAP_SCAN_FP_ACCEPT_ALL,
    .scan_phys = BLE_GAP_PHY_1MBPS,
    .interval = NRF_BLE_SCAN_SCAN_INTERVAL,
    .window = NRF_BLE_SCAN_SCAN_WINDOW,
    .timeout = NRF_BLE_SCAN_SCAN_DURATION,
    };

    For conn_params, I'm just letting nrf_scan initialize it with the defaults. I did try with manual parameters as well but did not make a difference.

    I feel like I'm missing what the identity list is for, and I do not set it up right now. Do I need it and if so, how should I do that? For instance, if I set connect_if_match in nrf_scan, how does that work?

Related