Skip to content

Commit

Permalink
On ESP32C3, don't allow AP *AND* STA mode at the same time - solves i…
Browse files Browse the repository at this point in the history
…ssues when just calling 'wifi.connect' at boot
  • Loading branch information
gfwilliams committed Aug 29, 2024
1 parent 6773fed commit c45ff32
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
8 changes: 7 additions & 1 deletion libs/network/esp32/jswrap_esp32_network.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit c45ff32

Please sign in to comment.