esp32: Add a small delay before leaving wlan.active().

The delay is 1 ms. It avoids the crashes reported by the
issues #8289, #8792 and #9236 with esp-idf versions >= 4.2, but does
not solve an underlying problem in the esp-idf.
This commit is contained in:
robert-hh 2023-01-19 12:42:09 +01:00
parent 30db33d1e0
commit d6bc34a13a

View File

@ -35,6 +35,7 @@
#include "py/objlist.h"
#include "py/runtime.h"
#include "py/mphal.h"
#include "modnetwork.h"
#include "esp_wifi.h"
@ -210,6 +211,12 @@ STATIC mp_obj_t network_wlan_active(size_t n_args, const mp_obj_t *args) {
wifi_started = true;
}
}
// This delay is a band-aid patch for issues #8289, #8792 and #9236,
// allowing the esp data structures to settle. It looks like some
// kind of race condition, which is not yet found. But at least
// this small delay seems not hurt much, since wlan.active() is
// usually not called in a time critical part of the code.
mp_hal_delay_ms(1);
}
return (mode & bit) ? mp_const_true : mp_const_false;