BLE scan not respecting scan timeout

Working with the tracker one, I am finding that running a BLE.scan() typically does not appear to run for the amount of time specified by the scan timeout.

Given the following main loop which tries to run an 8 second scan

void loop()
{
    BLE.setScanTimeout(800);

    system_tick_t start = millis();
    Vector<BleScanResult> results = BLE.scan();
    system_tick_t end = millis();
    Log.info("Scan duration: %ld", end - start);
}

The logs are showing that the scan duration varies between 2-8 seconds:

0000004810 [app] INFO: Scan duration: 2920
0000009924 [app] INFO: Scan duration: 5112
0000012754 [app] INFO: Scan duration: 2827
0000015875 [app] INFO: Scan duration: 3119
0000019305 [app] INFO: Scan duration: 3427
0000023562 [app] INFO: Scan duration: 4254
0000028683 [app] INFO: Scan duration: 5016
0000036600 [app] INFO: Scan duration: 7914

Is this expected behaviour?

1 Like