Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

problem on SoftDevice V6 scan_start/stop

I have problem on SoftDevice V6.0.0(nrf52832) scan_start/stop.

modified ble_app_blinky_c(ble_central)
1. app_timer add (20ms cyclic)
2. app_timer handler, run sd_ble_gap_scan_start() or sd_ble_gap_scan_stop() Alternately
   start->stop->start->stop cyclic
3. if after sd_ble_gap_scan_start() run, ADVERTISE_REPORT is received.
4. if after sd_ble_gap_scan_stop() run, ADVERTISE_REPORT is not received.

But Rarecase,
When after sd_ble_gap_scan_stop(), ADVERTISE_REPORT is received.

Is sd_ble_gap_scan_stop() not stop scanning Immediately?

  • Hi,

    The SoftDevice puts events in an event queue, and those events are not handled until you call nrf_sdh_evts_poll().

    Since the SoftDevice runs at higher priority, it means it can preempt your thread at any point in time. It can put advertisement report events into the event queue at any point in time as long as scan is active at that point in time. When your thread runs, scan is active up until the point where you call sd_ble_gap_scan_stop(). Any advertising report before that point will queue an event.

    You can not change SoftDevice priority. This means the correct way to handle this is to empty the events queue after stopping scanning, but before freeing the buffer. Like this:

    1. sd_ble_gap_scan_stop()
    2. nrf_sdh_evts_poll()
    3. free the buffer

    That way you make sure that there are no advertising report events in the queue when you free the buffer.

    Regards,
    Terje

  • OK I understand.
    That is,
    After scan_stop(), 'receive a advertise-report' is normal operation.

    On Older SoftDevice version, scan_start() not give a buffer.
    So that It's no problem.

    But, On SD V6,
    After scan_stop(),
    It is a fatal problem that we can not know if we can release the buffer.

    I hope update.

    (I suggestion that add IdnitityNumber in scan_start()/advertise_report.)


    Thank you.

Related