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

Why does `sd_ble_gap_connect()` require the scan params?

The footprint of sd_ble_gap_connect() is:

uint32_t, sd_ble_gap_connect(ble_gap_addr_t const *p_peer_addr, ble_gap_scan_params_t const *p_scan_params, ble_gap_conn_params_t const *p_conn_params)

  • why does the connect function also requires the scan parameters?
  • must the scan parameters be exactly the same as the ones used for actual scanning (i.e. the ones used in sd_ble_gap_scan_start())?
Parents
  • Hi,

    • why does the connect function also requires the scan parameters?

    I believe this is because central device before sending connection request needs to receive advertising packets from the peripheral device that should advertise in connectable mode. In order to receive anything it has to scan. What is more also advertiser (in connectable mode) is managing short scans (probably about 150us) after every ADV packet broadcasted. This is because the advertiser also has to be "informed" that there is some central device trying to connect in order to start connection procedure.

    • must the scan parameters be exactly the same as the ones used for actual scanning

    No, you can use completely different parameters. I belive that those parameters have an impact on how fast connection will be established. Of course it's also depends on advertising parameters.

    Cheers, ad

  • Thanks Adriand. Does this mean that if I want to scan and connect to a know peripheral, I don't have to first call sd_ble_gap_scan_start()? Namely, can I scan-and-connect, even with new scan parameters, with sd_ble_gap_connect()?

Reply Children
No Data
Related