From 38aa9ec3801f5895e09866fe92cb8e44fb987cee Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 16 May 2026 11:56:43 +0530 Subject: Unique SSID/IP per board + captive detection fix + mint list in portal MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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) --- main/config.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'main/config.c') 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 @@ #include "config.h" #include "esp_log.h" #include "esp_spiffs.h" +#include "esp_system.h" +#include "esp_mac.h" +#include "lwip/ip4_addr.h" #include "cJSON.h" #include +#include static const char *TAG = "tollgate_config"; static tollgate_config_t g_config; @@ -140,3 +144,25 @@ esp_err_t tollgate_config_get_next_wifi(wifi_config_t *wifi_config) g_config.current_network = (g_config.current_network + 1) % g_config.network_count; return tollgate_config_get_wifi(wifi_config); } + +void tollgate_config_derive_unique(tollgate_config_t *cfg) +{ + if (cfg->unique_derived) return; + + uint8_t mac[6]; + esp_read_mac(mac, ESP_MAC_WIFI_STA); + + snprintf(cfg->ap_ssid + strlen(cfg->ap_ssid), + TOLLGATE_MAX_AP_SSID_LEN - strlen(cfg->ap_ssid), + "-%02X%02X", mac[4], mac[5]); + + uint8_t b5 = mac[4]; + uint8_t b6 = mac[5]; + uint8_t subnet = (b5 ^ b6) % 200 + 10; + IP4_ADDR(&cfg->ap_ip, 10, b5, subnet, 1); + snprintf(cfg->ap_ip_str, sizeof(cfg->ap_ip_str), IPSTR, IP2STR(&cfg->ap_ip)); + + cfg->unique_derived = true; + + ESP_LOGI(TAG, "Unique config: SSID='%s', AP_IP=%s", cfg->ap_ssid, cfg->ap_ip_str); +} -- cgit v1.2.3