upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/main/config.c
diff options
context:
space:
mode:
authorYour Name <you@example.com>2026-05-19 03:14:53 +0530
committerYour Name <you@example.com>2026-05-19 03:14:53 +0530
commit08d7df158acf92399acdbb8a527620a6b1a94f16 (patch)
tree2a9f2b5b585b5a8bb21287420520ad1065f988e3 /main/config.c
parentd9ce038191ff2262356f67147553048357040701 (diff)
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.
Diffstat (limited to 'main/config.c')
-rw-r--r--main/config.c13
1 files changed, 12 insertions, 1 deletions
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)
18 g_config.max_retry = 5; 18 g_config.max_retry = 5;
19 g_config.ap_channel = 10; 19 g_config.ap_channel = 10;
20 g_config.ap_max_conn = 4; 20 g_config.ap_max_conn = 4;
21 g_config.wifi_auth_threshold = WIFI_AUTH_WPA2_PSK;
21 g_config.price_per_step = 21; 22 g_config.price_per_step = 21;
22 g_config.step_size_ms = 60000; 23 g_config.step_size_ms = 60000;
23 g_config.step_size_bytes = 22020096; 24 g_config.step_size_bytes = 22020096;
@@ -245,6 +246,16 @@ esp_err_t tollgate_config_init(void)
245 } 246 }
246 } 247 }
247 248
249 cJSON *auth_mode = cJSON_GetObjectItem(root, "wifi_auth_mode");
250 if (auth_mode && cJSON_IsString(auth_mode)) {
251 if (strcmp(auth_mode->valuestring, "WPA3") == 0) {
252 g_config.wifi_auth_threshold = WIFI_AUTH_WPA3_PSK;
253 } else {
254 g_config.wifi_auth_threshold = WIFI_AUTH_WPA2_PSK;
255 }
256 ESP_LOGI(TAG, "WiFi auth threshold from config: %s", auth_mode->valuestring);
257 }
258
248 if (g_config.payout.mint_count == 0 && g_config.mint_url[0] != '\0') { 259 if (g_config.payout.mint_count == 0 && g_config.mint_url[0] != '\0') {
249 strncpy(g_config.payout.mints[0].url, g_config.mint_url, 260 strncpy(g_config.payout.mints[0].url, g_config.mint_url,
250 sizeof(g_config.payout.mints[0].url) - 1); 261 sizeof(g_config.payout.mints[0].url) - 1);
@@ -286,7 +297,7 @@ esp_err_t tollgate_config_get_wifi(wifi_config_t *wifi_config)
286 memset(wifi_config, 0, sizeof(wifi_config_t)); 297 memset(wifi_config, 0, sizeof(wifi_config_t));
287 strncpy((char *)wifi_config->sta.ssid, g_config.networks[idx].ssid, sizeof(wifi_config->sta.ssid) - 1); 298 strncpy((char *)wifi_config->sta.ssid, g_config.networks[idx].ssid, sizeof(wifi_config->sta.ssid) - 1);
288 strncpy((char *)wifi_config->sta.password, g_config.networks[idx].password, sizeof(wifi_config->sta.password) - 1); 299 strncpy((char *)wifi_config->sta.password, g_config.networks[idx].password, sizeof(wifi_config->sta.password) - 1);
289 wifi_config->sta.threshold.authmode = WIFI_AUTH_WPA3_PSK; 300 wifi_config->sta.threshold.authmode = g_config.wifi_auth_threshold;
290 return ESP_OK; 301 return ESP_OK;
291} 302}
292 303