From 08d7df158acf92399acdbb8a527620a6b1a94f16 Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 19 May 2026 03:14:53 +0530 Subject: feat: WPA auto-detect from SPIFFS config.json Parse wifi_auth_mode from config.json to set STA auth threshold. Defaults to WPA2-PSK (fixes reason=211 with WPA2-only routers). SPIFFS generated by Makefile auto-detects WPA2/WPA3 from host scan. Root cause: config.c hardcoded WIFI_AUTH_WPA3_PSK threshold, making WPA2-only APs invisible during ESP32 scan (reason=211 NO_AP_FOUND). With this fix, STA connects to WPA2 upstream and Cashu payment verification works end-to-end. --- main/config.c | 13 ++++++++++++- main/config.h | 2 ++ 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'main') diff --git a/main/config.c b/main/config.c index 3a42293..d871a31 100644 --- a/main/config.c +++ b/main/config.c @@ -18,6 +18,7 @@ esp_err_t tollgate_config_init(void) g_config.max_retry = 5; g_config.ap_channel = 10; g_config.ap_max_conn = 4; + g_config.wifi_auth_threshold = WIFI_AUTH_WPA2_PSK; g_config.price_per_step = 21; g_config.step_size_ms = 60000; g_config.step_size_bytes = 22020096; @@ -245,6 +246,16 @@ esp_err_t tollgate_config_init(void) } } + cJSON *auth_mode = cJSON_GetObjectItem(root, "wifi_auth_mode"); + if (auth_mode && cJSON_IsString(auth_mode)) { + if (strcmp(auth_mode->valuestring, "WPA3") == 0) { + g_config.wifi_auth_threshold = WIFI_AUTH_WPA3_PSK; + } else { + g_config.wifi_auth_threshold = WIFI_AUTH_WPA2_PSK; + } + ESP_LOGI(TAG, "WiFi auth threshold from config: %s", auth_mode->valuestring); + } + if (g_config.payout.mint_count == 0 && g_config.mint_url[0] != '\0') { strncpy(g_config.payout.mints[0].url, g_config.mint_url, sizeof(g_config.payout.mints[0].url) - 1); @@ -286,7 +297,7 @@ esp_err_t tollgate_config_get_wifi(wifi_config_t *wifi_config) memset(wifi_config, 0, sizeof(wifi_config_t)); strncpy((char *)wifi_config->sta.ssid, g_config.networks[idx].ssid, sizeof(wifi_config->sta.ssid) - 1); strncpy((char *)wifi_config->sta.password, g_config.networks[idx].password, sizeof(wifi_config->sta.password) - 1); - wifi_config->sta.threshold.authmode = WIFI_AUTH_WPA3_PSK; + wifi_config->sta.threshold.authmode = g_config.wifi_auth_threshold; return ESP_OK; } diff --git a/main/config.h b/main/config.h index b8a3136..173019b 100644 --- a/main/config.h +++ b/main/config.h @@ -62,6 +62,8 @@ typedef struct { payout_config_t payout; + wifi_auth_mode_t wifi_auth_threshold; + bool cvm_enabled; char cvm_relays[256]; } tollgate_config_t; -- cgit v1.2.3