From c45ff321d88c08cf1e72b5d7c6af21d6b82d2380 Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Thu, 29 Aug 2024 20:13:30 +0100 Subject: [PATCH] On ESP32C3, don't allow AP *AND* STA mode at the same time - solves issues when just calling 'wifi.connect' at boot --- ChangeLog | 1 + libs/network/esp32/jswrap_esp32_network.c | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index c5fde50ff..398e72e82 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,7 @@ : ESP32C3: Get analogRead working correctly Graphics: Adjust image alignment when rotating images to avoid cropping (fix #2535) Bangle.js1: Switch to space-optimised sin/atan/atan2 to save enough space to continue building + ESP32C3: don't allow AP *AND* STA mode at the same time - solves issues when just calling 'wifi.connect' at boot 2v24 : Bangle.js2: Add 'Bangle.touchRd()', 'Bangle.touchWr()' Bangle.js2: After Bangle.showTestScreen, put Bangle.js into a hard off state (not soft off) diff --git a/libs/network/esp32/jswrap_esp32_network.c b/libs/network/esp32/jswrap_esp32_network.c index 98945eaed..00b5e0253 100644 --- a/libs/network/esp32/jswrap_esp32_network.c +++ b/libs/network/esp32/jswrap_esp32_network.c @@ -879,7 +879,11 @@ void jswrap_wifi_connect( break; case WIFI_MODE_APSTA: case WIFI_MODE_AP: +#if CONFIG_IDF_TARGET_ESP32C3 + mode = WIFI_MODE_STA; // C3 doesn't like AP and station at once +#else mode = WIFI_MODE_APSTA; +#endif break; default: jsError( "jswrap_wifi_connect: Unexpected mode type: %d", mode); @@ -1108,7 +1112,9 @@ void jswrap_wifi_startAP( wifi_mode_t mode; err = esp_wifi_get_mode(&mode); - +#if CONFIG_IDF_TARGET_ESP32C3 + if (mode == WIFI_MODE_STA) mode = WIFI_MODE_NULL; // C3 doesn't like AP and station at once +#endif err = esp_wifi_set_mode( mode | WIFI_MODE_AP); if (err != ESP_OK) { jsError( "jswrap_wifi_startAP: esp_wifi_set_mode: %d(%s)", err,wifiErrorToString(err));