From a3dbbf1170028eaa6864cbe1bc2b245dba4a322a Mon Sep 17 00:00:00 2001 From: jedarden Date: Fri, 17 Apr 2026 08:42:04 -0400 Subject: [PATCH] fix: support special characters in WiFi credentials MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - SSID input: add autocorrect=off, autocapitalize=none, spellcheck=false to prevent mobile browsers from silently altering SSIDs with special chars - Password input: same attrs for consistency - Firmware: accept WPA/WPA2 mixed mode (WIFI_AUTH_WPA_WPA2_PSK) so networks with special characters in the password connect regardless of WPA version - Firmware: detect open networks (empty password) and use WIFI_AUTH_OPEN so passwordless networks are not rejected by the auth threshold JSON encoding path (JSON.stringify → TextEncoderStream → cJSON) already handles all characters correctly; these changes prevent browser-side mangling and firmware-side connection rejection. --- dashboard/js/onboard.js | 4 ++-- firmware/main/wifi.c | 12 ++++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/dashboard/js/onboard.js b/dashboard/js/onboard.js index c92fcad..84e85d2 100644 --- a/dashboard/js/onboard.js +++ b/dashboard/js/onboard.js @@ -660,11 +660,11 @@ '
' + '
' + '' + - '' + + '' + '
' + '
' + '' + - '' + + '' + '
' + '
' + 'Advanced: Mothership Address' + diff --git a/firmware/main/wifi.c b/firmware/main/wifi.c index 3a1625d..42f4361 100644 --- a/firmware/main/wifi.c +++ b/firmware/main/wifi.c @@ -156,11 +156,19 @@ esp_err_t wifi_start_connect(void) { wifi_config_t wifi_config = {0}; strncpy((char *)wifi_config.sta.ssid, ssid, sizeof(wifi_config.sta.ssid) - 1); strncpy((char *)wifi_config.sta.password, password, sizeof(wifi_config.sta.password) - 1); - wifi_config.sta.threshold.authmode = WIFI_AUTH_WPA2_PSK; + + // Accept open networks when no password is set; otherwise allow WPA or WPA2 + // so networks with special characters in the password work regardless of AP mode. + if (strlen(password) == 0) { + wifi_config.sta.threshold.authmode = WIFI_AUTH_OPEN; + } else { + wifi_config.sta.threshold.authmode = WIFI_AUTH_WPA_WPA2_PSK; + } wifi_config.sta.pmf_cfg.capable = true; wifi_config.sta.pmf_cfg.required = false; - ESP_LOGI(TAG, "Connecting to WiFi: %s", ssid); + ESP_LOGI(TAG, "Connecting to WiFi: %s (authmode: %s)", ssid, + strlen(password) == 0 ? "open" : "WPA/WPA2"); ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA)); ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, &wifi_config));