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>
This commit is contained in:
committed by
Damien George
parent
17898f8607
commit
d5f2fc239a
@@ -705,12 +705,12 @@ int mp_bluetooth_init(void) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void mp_bluetooth_deinit(void) {
|
||||
int mp_bluetooth_deinit(void) {
|
||||
DEBUG_printf("mp_bluetooth_deinit\n");
|
||||
|
||||
// Nothing to do if not initialised.
|
||||
if (!MP_STATE_PORT(bluetooth_btstack_root_pointers)) {
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
mp_bluetooth_gap_advertise_stop();
|
||||
@@ -737,6 +737,9 @@ void mp_bluetooth_deinit(void) {
|
||||
deinit_stack();
|
||||
|
||||
DEBUG_printf("mp_bluetooth_deinit: complete\n");
|
||||
|
||||
bool timeout = mp_bluetooth_btstack_state == MP_BLUETOOTH_BTSTACK_STATE_TIMEOUT;
|
||||
return timeout ? MP_ETIMEDOUT : 0;
|
||||
}
|
||||
|
||||
bool mp_bluetooth_is_active(void) {
|
||||
|
||||
Reference in New Issue
Block a user