sd_ble_gap_scan_start and timeout

My product is very similar to the PCA10056 and uses NRF52840 and Soft Device S140.  The firmware uses NRF5 SDK 17.1.x.

I am trying to set up a periodic scanning feature. Since I did not find any simple approach to set up the NRF SDK scanning module to filter for a specific prefix in the BLE GAP name, I decided to directly invoke the low level Soft Device scanning API 'sd_ble_gap_scan_start'

I have a timer that times out at a fixed interval, say every 15 seconds. I have set up the scan parameters for a scan timeout of 1 second. 

The typical flow is to wait for and process the BLE event ''BLE_GAP_EVT_ADV_REPORT" or "BLE_GAP_EVT_TIMEOUT". 
This works fine if the first incoming BLE PDU matches our firmware requirements. 
If, however, it does not then it appears to be the case that the scanning is STOPPED and needs to be resumed.
Should one then call the function 'sd_ble_gap_scan_start' again?

If one repeatedly calls the API function then how does the 'scanning timeout' even play a role in this whole workflow? 
Does the scanning timeout restart after every invocation of 'sd_ble_gap_scan_start'? 
If so then how does one even enforce the idea of a 'scan timeout' while also supporting repeated relaunches of the scanning API?

Cheers

RVM

Parents Reply Children
Related