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

BLE central scan, receives exactly one report

Using Softdevice 132 version 6.1.0

I issue the request for scanning by calling

sd_ble_gap_scan_start() with:
ble_gap_scan_params_t scan_params = {
{
    .extended = 0,
    .report_incomplete_evts = 0,
    .active = 0,
    .filter_policy = BLE_GAP_SCAN_FP_ACCEPT_ALL, // 0
    .scan_phys = BLE_GAP_PHY_AUTO, // 0
    .interval = 64, // 40 msec
    .window = 48, // 30 msec
    .timeout = 0, // forever
    .channel_mask = {0}, // zero filled
    ._vptr.scan_parameters = 0x0
};



All starts well, I get an advertising report back via BLE event: 0x1d, the connection handle is 0xffff (this makes sense, there is no connection) and a valid RSSI. There are no unexpected asserts, nor any other unexpected behavior.

But I only ever receive one report. Exactly one.
I see in ble_gap.h, this comment on line 1228:

/* @note When ble_gap_adv_report_type_t::status is not set to @ref BLE_GAP_ADV_DATA_STATUS_INCOMPLETE_MORE_DATA,
 *       scanning will be paused. To continue scanning, call @ref sd_ble_gap_scan_start.
 */

OK - well that would explain it. So within the callback of the report I again call sd_ble_gap_scan_start() with the same settings. This time the return value is NRF_ERROR_INVALID_STATE (8) indicating that scanning is already in progress.

And yet, there are no more reports.

Any thoughts on what might be going on?

I also tried setting the scan timeout to 0xFFFFu and still no change in behavior.

Parents Reply
  • Hi,

    According to the sd_ble_gap_scan_start() documentation, when using sd_ble_gap_scan_start() to continue scanning you should set the p_scan_params argument to NULL. If you had a timeout for the scan, the "old" timeout will still be running in the background. (I.e. the timeout will be from the point in time that you first started the scan.)

    If you provide a non-null p_scan_params in paused state you will get NRF_ERROR_INVALID_STATE and the scan will not continue.

    The wording in the documentation looks to be a bit imprecise on the NRF_ERROR_INVALID_STATE reasons listed. I will file an internal request for documentation improvement.

    Regards,
    Terje

Children
Related