nRF5 SDK is not maintained anymore
More Info: Consider nRF Connect SDK for new designs

nrf_ble_scan fails to connect to devices that emit both connectable and non-connectable advertising packets

nrf5-sdk v16.0.0

If you use the nrf_ble_scan module to try and connect to a peripheral that emits both connectable and non-connectable advertising packets, the module does not check that the advertising report it receives is "connectable" before trying to initiate a connection.

If the device is currently only emitting non-connectable packets, the scanner tries to connect but will never succeed.

Attempts to stop and start the scan again fail.

sd_ble_nrf_ble_scan_start() (or whatever its called) just returns an invalid_state error until you explicitly call sd_ble_cancel_connect()

Seems like a bug to me, but the nrf_ble_scan module shouldn't attempt a connection to a non-connectable advertising packet in the first place. 

Checked the latest v17.1.0 code, looks like the issue would still persist there as well. 

Parents
  • Hi,

    I took a look at the code, and I agree. There is no check to see if ble_gap_adv_report_type_t ::connectable is 0 or 1 before attempting to connect. Either add a timeout(NRF_BLE_SCAN_SCAN_DURATION non 0), or set  automatic connection(connect_if_match) flag to false, and do the connection attempt yourself and the ble_gap_adv_report_type_t ::connectable check, in the scan_evt_handler() when you get the event NRF_BLE_SCAN_EVT_FILTER_MATCH

Reply
  • Hi,

    I took a look at the code, and I agree. There is no check to see if ble_gap_adv_report_type_t ::connectable is 0 or 1 before attempting to connect. Either add a timeout(NRF_BLE_SCAN_SCAN_DURATION non 0), or set  automatic connection(connect_if_match) flag to false, and do the connection attempt yourself and the ble_gap_adv_report_type_t ::connectable check, in the scan_evt_handler() when you get the event NRF_BLE_SCAN_EVT_FILTER_MATCH

Children
No Data
Related