extmod/modbluetooth_nimble: Make gap_scan_stop no-op if no scan ongoing.

No need for this to throw an exception if the intent (don't be scanning) is
clear, and avoids a race with the scan duration timeout.
This commit is contained in:
Jim Mussared 2019-11-13 11:53:41 +11:00 committed by Damien George
parent d19c6d0519
commit 2ae755d9e1

View File

@ -659,6 +659,9 @@ int mp_bluetooth_gap_scan_start(int32_t duration_ms, int32_t interval_us, int32_
}
int mp_bluetooth_gap_scan_stop(void) {
if (!ble_gap_disc_active()) {
return 0;
}
int err = ble_gap_disc_cancel();
if (err == 0) {
mp_bluetooth_gap_on_scan_complete();