From 2ad2ed45f3ca82b1244a8b9e3e5efa89502413a9 Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 19 May 2026 02:44:17 +0530 Subject: feat: WPA auto-detect, STA connectivity fix, lwip crash fix - Add wifi_auth_mode config field (WPA2/WPA3) parsed from config.json - Default to WPA2 (accepts both WPA2 and WPA3 networks) - Replace hardcoded WIFI_AUTH_WPA3_PSK with runtime threshold mapping - Reduce MINT_HEALTH_PROBE_INTERVAL_S from 300 to 30 for testing - Add 3s delay before service start + 5s DNS stabilization for health probes - Fixes lwip mem_free crash caused by concurrent HTTP at boot Verified on hardware: - STA connects to WPA2 home router (Got IP:192.168.2.16) - All 4 mint health probes complete successfully - API endpoints return correct data with reachable mint filtering - 4/4 wallets initialized with real keysets from live mints --- main/config.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'main/config.c') diff --git a/main/config.c b/main/config.c index 54642a2..fe0ceba 100644 --- a/main/config.c +++ b/main/config.c @@ -35,6 +35,7 @@ esp_err_t tollgate_config_init(void) g_config.payout.mint_count = 0; g_config.cvm_enabled = true; strncpy(g_config.cvm_relays, "wss://relay.primal.net", sizeof(g_config.cvm_relays) - 1); + strncpy(g_config.wifi_auth_mode, "WPA2", sizeof(g_config.wifi_auth_mode) - 1); esp_vfs_spiffs_conf_t conf = { .base_path = "/spiffs", @@ -272,6 +273,11 @@ esp_err_t tollgate_config_init(void) } } + cJSON *auth_mode = cJSON_GetObjectItem(root, "wifi_auth_mode"); + if (auth_mode && cJSON_IsString(auth_mode)) { + strncpy(g_config.wifi_auth_mode, auth_mode->valuestring, sizeof(g_config.wifi_auth_mode) - 1); + } + 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); @@ -319,7 +325,13 @@ 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 = WIFI_AUTH_WPA2_PSK; + if (strstr(g_config.wifi_auth_mode, "WPA3")) { + wifi_config->sta.threshold.authmode = WIFI_AUTH_WPA3_PSK; + } else if (strstr(g_config.wifi_auth_mode, "WPA2")) { + wifi_config->sta.threshold.authmode = WIFI_AUTH_WPA2_PSK; + } + ESP_LOGI(TAG, "STA auth threshold: %s → %d", g_config.wifi_auth_mode, wifi_config->sta.threshold.authmode); return ESP_OK; } -- cgit v1.2.3