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

nrf52840 can we scan while connected to a device in BLE

I always have to stop scanning before making a connection. If i keep the scanning on, the two devices wouldn't connect.

Parents
  • 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?

Reply
  • 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?

Children
Related