From 2ae755d9e1971437181097dbbf43e116ba8383d0 Mon Sep 17 00:00:00 2001 From: Jim Mussared Date: Wed, 13 Nov 2019 11:53:41 +1100 Subject: [PATCH] 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. --- extmod/modbluetooth_nimble.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/extmod/modbluetooth_nimble.c b/extmod/modbluetooth_nimble.c index 33dac5a42..d0c3a3d81 100644 --- a/extmod/modbluetooth_nimble.c +++ b/extmod/modbluetooth_nimble.c @@ -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();