summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrobert-hh <robert@hammelrath.com>2023-01-19 12:42:09 +0100
committerrobert-hh <robert@hammelrath.com>2023-01-19 21:31:46 +0100
commitd6bc34a13aa734d8b32e5768c021377ac4815029 (patch)
tree21439c92189cc9fa1d8afd70a190802fbfba652e
parent30db33d1e024c9c16140ed8f44283728b1428fac (diff)
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.
-rw-r--r--ports/esp32/network_wlan.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/ports/esp32/network_wlan.c b/ports/esp32/network_wlan.c
index f0b458e6d..e4b34b220 100644
--- a/ports/esp32/network_wlan.c
+++ b/ports/esp32/network_wlan.c
@@ -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;