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

How to determine if central fails to connect to peripheral

I am using a central S130 softdevice in an nRF51822. I connect to a peripheral using sd_ble_gap_connect(&m_peripheral_address, &m_scan_param, &m_connection_param). If it is able to establish a connection to the peripheral, everything proceeds as expected. However, if for some reason, it can't connect (e.g. the peripheral has moved out of range), sd_ble_gap_connect still returns NRF_SUCCESS, and I see no events that indicate that the connection failed, even after an extended period of time. My connection parameters are min_conn_interval = 6, max_conn_interval = 24, slave_latency = 0 and conn_sup_timeout = 400.

Is there any mechanism for communicating back that a connection couldn't be made? Thanks!

  • Yes set the timeout parameter in the p_scan_params of the sd_ble_gap_connect() call to something other than zero, which means try forever. p_conn_params are the parameters to use for the connection when connected, it's the scan parameters which determine how long to search for the peripheral before connecting and when to time that process out and return error

    This is in the Message Sequence Chart for GAP Central Connection Establishment And Cancellation

Related