diff options
| author | Your Name <you@example.com> | 2026-05-16 11:56:43 +0530 |
|---|---|---|
| committer | Your Name <you@example.com> | 2026-05-16 11:56:43 +0530 |
| commit | 38aa9ec3801f5895e09866fe92cb8e44fb987cee (patch) | |
| tree | c702c27cd59fa0e73bc3e8665e1582e6b9509cf6 /main/config.c | |
| parent | ee4e13680f522253f94e8ebdea5df80332afc495 (diff) | |
Unique SSID/IP per board + captive detection fix + mint list in portal
- Derive unique SSID (TollGate-{MAC4}{MAC5}) and AP IP (10.{b5}.{subnet}.1)
from factory MAC — boards no longer conflict
- Board A: TollGate-377C @ 10.55.85.1, Board B: TollGate-5050 @ 10.80.10.1
- Captive portal detection URIs return 200 with portal HTML (matching
esp32-mesh working approach) instead of 302 redirect
- Dynamic AP IP in portal HTML via __AP_IP__ template substitution
- Supported mints section in portal page (shows mint URL, tap to copy)
- Fixed mint URL to testnut.cashu.space (was stale in SPIFFS)
- DoT reject server on port 853 for DNS-over-TLS fallback
- DNS hijack: NXDOMAIN for all non-A queries, no forwarding for unauthed
- Playwright tests updated for 200 response on detection URIs
- Phase 2 test suite: 20/21 pass (test 22 expiry ping route issue)
- Tests 25-27 deferred to Phase 3 (Board B as second client)
Diffstat (limited to 'main/config.c')
| -rw-r--r-- | main/config.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/main/config.c b/main/config.c index b44c3c5..d7837bc 100644 --- a/main/config.c +++ b/main/config.c | |||
| @@ -1,8 +1,12 @@ | |||
| 1 | #include "config.h" | 1 | #include "config.h" |
| 2 | #include "esp_log.h" | 2 | #include "esp_log.h" |
| 3 | #include "esp_spiffs.h" | 3 | #include "esp_spiffs.h" |
| 4 | #include "esp_system.h" | ||
| 5 | #include "esp_mac.h" | ||
| 6 | #include "lwip/ip4_addr.h" | ||
| 4 | #include "cJSON.h" | 7 | #include "cJSON.h" |
| 5 | #include <string.h> | 8 | #include <string.h> |
| 9 | #include <stdio.h> | ||
| 6 | 10 | ||
| 7 | static const char *TAG = "tollgate_config"; | 11 | static const char *TAG = "tollgate_config"; |
| 8 | static tollgate_config_t g_config; | 12 | static tollgate_config_t g_config; |
| @@ -140,3 +144,25 @@ esp_err_t tollgate_config_get_next_wifi(wifi_config_t *wifi_config) | |||
| 140 | g_config.current_network = (g_config.current_network + 1) % g_config.network_count; | 144 | g_config.current_network = (g_config.current_network + 1) % g_config.network_count; |
| 141 | return tollgate_config_get_wifi(wifi_config); | 145 | return tollgate_config_get_wifi(wifi_config); |
| 142 | } | 146 | } |
| 147 | |||
| 148 | void tollgate_config_derive_unique(tollgate_config_t *cfg) | ||
| 149 | { | ||
| 150 | if (cfg->unique_derived) return; | ||
| 151 | |||
| 152 | uint8_t mac[6]; | ||
| 153 | esp_read_mac(mac, ESP_MAC_WIFI_STA); | ||
| 154 | |||
| 155 | snprintf(cfg->ap_ssid + strlen(cfg->ap_ssid), | ||
| 156 | TOLLGATE_MAX_AP_SSID_LEN - strlen(cfg->ap_ssid), | ||
| 157 | "-%02X%02X", mac[4], mac[5]); | ||
| 158 | |||
| 159 | uint8_t b5 = mac[4]; | ||
| 160 | uint8_t b6 = mac[5]; | ||
| 161 | uint8_t subnet = (b5 ^ b6) % 200 + 10; | ||
| 162 | IP4_ADDR(&cfg->ap_ip, 10, b5, subnet, 1); | ||
| 163 | snprintf(cfg->ap_ip_str, sizeof(cfg->ap_ip_str), IPSTR, IP2STR(&cfg->ap_ip)); | ||
| 164 | |||
| 165 | cfg->unique_derived = true; | ||
| 166 | |||
| 167 | ESP_LOGI(TAG, "Unique config: SSID='%s', AP_IP=%s", cfg->ap_ssid, cfg->ap_ip_str); | ||
| 168 | } | ||