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.