From 24065824796b54d42fdb93457bf53d21656e473e Mon Sep 17 00:00:00 2001 From: Alessandro Gatti Date: Fri, 28 Mar 2025 15:30:29 +0100 Subject: [PATCH] esp32/network_common: Raise a memory error on ESP_ERR_NO_MEM. This commit changes the error handler for WiFi operations to recognise out of memory conditions reported by ESP-IDF functions, and report them as more descriptive exceptions rather than a generic "error 0x101". The error handler only provided a human-readable error description for WiFi-specific error codes (codes in the ESP_ERR_WIFI_BASE range), but WiFi functions are known to return other codes. Now ESP_ERR_NO_MEM is covered with a specific error message, making it easier to debug issues related to running out of ESP-IDF heap. Signed-off-by: Alessandro Gatti --- ports/esp32/network_common.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ports/esp32/network_common.c b/ports/esp32/network_common.c index e07d7a993..bd34f1b41 100644 --- a/ports/esp32/network_common.c +++ b/ports/esp32/network_common.c @@ -77,6 +77,8 @@ MP_NORETURN void esp_exceptions_helper(esp_err_t e) { mp_raise_msg(&mp_type_OSError, MP_ERROR_TEXT("Wifi Would Block")); case ESP_ERR_WIFI_NOT_CONNECT: mp_raise_msg(&mp_type_OSError, MP_ERROR_TEXT("Wifi Not Connected")); + case ESP_ERR_NO_MEM: + mp_raise_msg(&mp_type_OSError, MP_ERROR_TEXT("WiFi Out of Memory")); default: mp_raise_msg_varg(&mp_type_RuntimeError, MP_ERROR_TEXT("Wifi Unknown Error 0x%04x"), e); }