diff options
author | Andrew Leech <andrew.leech@planetinnovation.com.au> | 2025-05-07 09:11:25 +1000 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2025-06-04 02:21:32 +1000 |
commit | d5f2fc239af2d69407170fa290ba6752c8f1790c (patch) | |
tree | f765b059b0887de6e8f7f0f10bb5541c47bd5b95 /extmod/modbluetooth.c | |
parent | 17898f8607dc4fb881e860719cc1906d304e60f4 (diff) |
extmod/modbluetooth: Add timeout to deinit.
If the BLE radio stops responding before deinit is called the function can
get stuck waiting for an event that is never received, particularly if the
radio is external or on a separate core.
This commit adds a timeout, similar to the timeout already used in the init
function. Updated for nimble, btstack, esp32 and zephyr bindings.
Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
Diffstat (limited to 'extmod/modbluetooth.c')
-rw-r--r-- | extmod/modbluetooth.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/extmod/modbluetooth.c b/extmod/modbluetooth.c index b95c42a4e..ffa407809 100644 --- a/extmod/modbluetooth.c +++ b/extmod/modbluetooth.c @@ -290,12 +290,13 @@ static mp_obj_t bluetooth_ble_make_new(const mp_obj_type_t *type, size_t n_args, static mp_obj_t bluetooth_ble_active(size_t n_args, const mp_obj_t *args) { if (n_args == 2) { // Boolean enable/disable argument supplied, set current state. + int err; if (mp_obj_is_true(args[1])) { - int err = mp_bluetooth_init(); - bluetooth_handle_errno(err); + err = mp_bluetooth_init(); } else { - mp_bluetooth_deinit(); + err = mp_bluetooth_deinit(); } + bluetooth_handle_errno(err); } // Return current state. return mp_obj_new_bool(mp_bluetooth_is_active()); |