summaryrefslogtreecommitdiff
path: root/extmod/modbluetooth_nimble.c
diff options
context:
space:
mode:
authorJim Mussared <jim.mussared@gmail.com>2019-11-13 11:53:41 +1100
committerDamien George <damien.p.george@gmail.com>2019-11-25 17:27:40 +1100
commit2ae755d9e1971437181097dbbf43e116ba8383d0 (patch)
treee1c9f75009bb801625ad2f63c21a51ef134ef707 /extmod/modbluetooth_nimble.c
parentd19c6d0519634851517bcf9e77f5d54d69084a5c (diff)
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.
Diffstat (limited to 'extmod/modbluetooth_nimble.c')
-rw-r--r--extmod/modbluetooth_nimble.c3
1 files changed, 3 insertions, 0 deletions
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();