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

The scanning for the slave devices suddenly stops working during connection to any slave.

Hi everyone,

We develop the project on chip NRF52832 with SDK v14.0.

The chip in this project works in multirole mode. During the work it must scan the devices to acquire the brief real-time information from advertising data and to connect to them when needed.

But sometimes during the connection, characteristics’ discovery or reading / writing the information the scanning can stop working and the real-time-adv-data information from other disconnected slaves cannot be acquired anymore.

In the project the scanning is established at startup with the define SCAN_TIMEOUT = 0.

According to the manual the function “sd_ble_gap_connect()” stops the scanning during the connection establishment and (practically) returns it back only after connection success. So in case of the error the scanning can be not returned.

But practically the scanning the connection can be stopped working also in other cases when connection was lost and sending receiving air data was unsuccessful.

Due to this reason I must ask you some questions:

  1. Which procedure/function detects if the scanning works without checking absence of scan responding event for a long time.
  2. Which other functions except “sd_ble_gap_connect()” can stop the scanning?
  3. Is it possible to return the scanning when the function “sd_ble_gap_connect()” is busy or it can cause any error?
  • Hi,

    1) 

    There are no explicit functions for this. You could perhaps set a variable to true when sd_ble_gap_scan_start() is called(and it returns NRF_SUCCESS). And then set the variable to false when the scanning is stopped.

    2)

    The scanner will automatically stop in the following cases:

    sd_ble_gap_connect is called.

    sd_ble_gap_scan_stop is called.

    A BLE_GAP_EVT_TIMEOUT with source set to BLE_GAP_TIMEOUT_SRC_SCAN is received.

    3)

    Yes, you can start the scanning again after calling sd_ble_gap_connect(), even if it returns busy. But, sd_ble_gap_scan_start could also return busy.

    Remember to check the return code.

        ret = sd_ble_gap_scan_start(&m_scan_param);
    
        APP_ERROR_CHECK(ret);

Related