I always have to stop scanning before making a connection. If i keep the scanning on, the two devices wouldn't connect.
I always have to stop scanning before making a connection. If i keep the scanning on, the two devices wouldn't connect.
When you call sd_ble_gap_connect
it should be still sending scanning events to your app until target device is seen and CONNECT_REQ packet issued. At that moment you will get BLE_GAP_EVT_CONNECTED
event and scanning will stop. If you want to continue you need to open new scanner slot which means you need to previously enable multiple roles during Soft Device init.
Btw. none of nRF5 SDK examples need to stop scanning before issuing sd_ble_gap_connect
, it should be possible to call directly from BLE_GAP_EVT_ADV_REPORT
event handler. How exactly you test this so you can claim that without stopping scanning it doesn't connect?
I was convinced that when sd_ble_gap_connect() is called it will stop the normal scanning. It will then start scanning with the scanning parameters given to it. It will filter out any advertising packets that is not the specific peer address it wants to connect to, so advertising reports will not be forwarded to the application.
Which SDK and SoftDevice version are you using? Could you include some code? Are you saying that you have to call sd_ble_gap_scan_stop() before you call sd_ble_gap_connect()? Does sd_ble_gap_connect() return an error code if you don't call sd_ble_gap_scan_stop() first?
My bad, I've thought that scanning works even during waiting for target of connect request...
Hi I am using zephyr OS 1.8 V. I am using bt_conn_create_le() to make connection. For this to work i have to call bt_le_scan_stop() before that.