diff options
| author | Your Name <you@example.com> | 2026-05-19 02:44:17 +0530 |
|---|---|---|
| committer | Your Name <you@example.com> | 2026-05-19 02:44:17 +0530 |
| commit | 2ad2ed45f3ca82b1244a8b9e3e5efa89502413a9 (patch) | |
| tree | 0f423dce2c22f8483b0c9f3c1bb642bf9ea5b01b /main/config.c | |
| parent | a09be62cfab9a1d7f37c697c44c71aed70536e8c (diff) | |
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
Diffstat (limited to 'main/config.c')
| -rw-r--r-- | main/config.c | 14 |
1 files changed, 13 insertions, 1 deletions
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) | |||
| 35 | g_config.payout.mint_count = 0; | 35 | g_config.payout.mint_count = 0; |
| 36 | g_config.cvm_enabled = true; | 36 | g_config.cvm_enabled = true; |
| 37 | strncpy(g_config.cvm_relays, "wss://relay.primal.net", sizeof(g_config.cvm_relays) - 1); | 37 | strncpy(g_config.cvm_relays, "wss://relay.primal.net", sizeof(g_config.cvm_relays) - 1); |
| 38 | strncpy(g_config.wifi_auth_mode, "WPA2", sizeof(g_config.wifi_auth_mode) - 1); | ||
| 38 | 39 | ||
| 39 | esp_vfs_spiffs_conf_t conf = { | 40 | esp_vfs_spiffs_conf_t conf = { |
| 40 | .base_path = "/spiffs", | 41 | .base_path = "/spiffs", |
| @@ -272,6 +273,11 @@ esp_err_t tollgate_config_init(void) | |||
| 272 | } | 273 | } |
| 273 | } | 274 | } |
| 274 | 275 | ||
| 276 | cJSON *auth_mode = cJSON_GetObjectItem(root, "wifi_auth_mode"); | ||
| 277 | if (auth_mode && cJSON_IsString(auth_mode)) { | ||
| 278 | strncpy(g_config.wifi_auth_mode, auth_mode->valuestring, sizeof(g_config.wifi_auth_mode) - 1); | ||
| 279 | } | ||
| 280 | |||
| 275 | if (g_config.payout.mint_count == 0 && g_config.mint_url[0] != '\0') { | 281 | if (g_config.payout.mint_count == 0 && g_config.mint_url[0] != '\0') { |
| 276 | strncpy(g_config.payout.mints[0].url, g_config.mint_url, | 282 | strncpy(g_config.payout.mints[0].url, g_config.mint_url, |
| 277 | sizeof(g_config.payout.mints[0].url) - 1); | 283 | sizeof(g_config.payout.mints[0].url) - 1); |
| @@ -319,7 +325,13 @@ esp_err_t tollgate_config_get_wifi(wifi_config_t *wifi_config) | |||
| 319 | memset(wifi_config, 0, sizeof(wifi_config_t)); | 325 | memset(wifi_config, 0, sizeof(wifi_config_t)); |
| 320 | strncpy((char *)wifi_config->sta.ssid, g_config.networks[idx].ssid, sizeof(wifi_config->sta.ssid) - 1); | 326 | strncpy((char *)wifi_config->sta.ssid, g_config.networks[idx].ssid, sizeof(wifi_config->sta.ssid) - 1); |
| 321 | strncpy((char *)wifi_config->sta.password, g_config.networks[idx].password, sizeof(wifi_config->sta.password) - 1); | 327 | strncpy((char *)wifi_config->sta.password, g_config.networks[idx].password, sizeof(wifi_config->sta.password) - 1); |
| 322 | wifi_config->sta.threshold.authmode = WIFI_AUTH_WPA3_PSK; | 328 | wifi_config->sta.threshold.authmode = WIFI_AUTH_WPA2_PSK; |
| 329 | if (strstr(g_config.wifi_auth_mode, "WPA3")) { | ||
| 330 | wifi_config->sta.threshold.authmode = WIFI_AUTH_WPA3_PSK; | ||
| 331 | } else if (strstr(g_config.wifi_auth_mode, "WPA2")) { | ||
| 332 | wifi_config->sta.threshold.authmode = WIFI_AUTH_WPA2_PSK; | ||
| 333 | } | ||
| 334 | ESP_LOGI(TAG, "STA auth threshold: %s → %d", g_config.wifi_auth_mode, wifi_config->sta.threshold.authmode); | ||
| 323 | return ESP_OK; | 335 | return ESP_OK; |
| 324 | } | 336 | } |
| 325 | 337 | ||