Scan gets interrupted when connecting to a device.

Hi ,

I am using SDK nRF5_SDK_17.0.2 with nrf52840 for one of my projects and as part of the requirement I need a scanner that keeps scanning for sensors and collects data from the advertised packet and at regular intervals I need to connect to these sensors one by one and extract some extra data through BLE services while keeping the scanner alive.

Now the issue is that when I call the connect function( sd_ble_gap_connect ) the scan gets interrupted and I need to restart the scan once the connection is established. Therefore I am not able to receive the advertisement data during the time frame for which the connection is being established.

I am using the sd_ble_gap_connect  api to connect to the sensors and I can see from the documentation calling sd_ble_gap_connect will interrupt the scanning process(to start scanning I am using the sd_ble_gap_scan_start function call ). Is there any option where I can keep the scanning alive while trying to connect to a device ? Is this the limitation of SDK or the Bluetooth protocol ?

  • Hi Kirankumar, 

    Unfortunately it's not possible to do both scanning and connecting at the same time. It's the limitation of the BLE stack. The only option if you use the softdevice is to start scanning right after it's connected. And use a short connecting timeout to avoid scan being blocked for a long time if the connection can't be established. 

Related