diff options
| author | Your Name <you@example.com> | 2026-05-19 13:21:25 +0530 |
|---|---|---|
| committer | Your Name <you@example.com> | 2026-05-19 13:31:08 +0530 |
| commit | eeba74a4a1c011e85e33dea4252b381e35a64ea4 (patch) | |
| tree | 14862e7d300511e28e214c743fd2f699bc54c5b8 /main/tollgate_main.c | |
| parent | b0d9d494f00ee77f9efc22d1ef2ea3c94b23ddbd (diff) | |
feat: multi-mint wallet with health tracking, WPA auto-detect, display gating
Squash merge of feature/multi-mint-support (21 commits):
Multi-mint wallet:
- Accept payments from 4 mints: minibits, coinos, 21mint, lnvoltz
- Periodic health probing (300s interval, 3 recovery threshold)
- Multi-wallet init with nucula_wallet_init_multi()
- /mints and /wallet API endpoints
WPA auto-detect:
- wifi_auth_mode config field (default WPA2, supports WPA3)
- Runtime mapping to wifi_auth_mode_t in STA config
Display gating:
- display_enabled config field (default true)
- Guards display_init/display_update per-board
Bug fixes:
- 3s delay before service start prevents lwip mem_free assertion
- Real npub in discovery (identity_get()->npub_hex)
- Health probe interval 300s (production value)
- Duplicate services_start_task call removed
- UTF-8 arrow replaced with ASCII in log message
Tests: 61+14 unit tests passing, firmware builds clean
Diffstat (limited to 'main/tollgate_main.c')
| -rw-r--r-- | main/tollgate_main.c | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/main/tollgate_main.c b/main/tollgate_main.c index f062cb6..33e5b90 100644 --- a/main/tollgate_main.c +++ b/main/tollgate_main.c | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | #include "esp_wifi.h" | 5 | #include "esp_wifi.h" |
| 6 | #include "esp_event.h" | 6 | #include "esp_event.h" |
| 7 | #include "esp_log.h" | 7 | #include "esp_log.h" |
| 8 | #include "esp_system.h" | ||
| 8 | #include "nvs_flash.h" | 9 | #include "nvs_flash.h" |
| 9 | #include "esp_netif.h" | 10 | #include "esp_netif.h" |
| 10 | #include "lwip/netif.h" | 11 | #include "lwip/netif.h" |
| @@ -22,6 +23,7 @@ | |||
| 22 | #include "wifistr.h" | 23 | #include "wifistr.h" |
| 23 | #include "tollgate_client.h" | 24 | #include "tollgate_client.h" |
| 24 | #include "lightning_payout.h" | 25 | #include "lightning_payout.h" |
| 26 | #include "mint_health.h" | ||
| 25 | #include "cvm_server.h" | 27 | #include "cvm_server.h" |
| 26 | #include "display.h" | 28 | #include "display.h" |
| 27 | #include "local_relay.h" | 29 | #include "local_relay.h" |
| @@ -119,6 +121,7 @@ static void wifi_event_handler(void *arg, esp_event_base_t event_base, | |||
| 119 | 121 | ||
| 120 | static void services_start_task(void *pvParameters) | 122 | static void services_start_task(void *pvParameters) |
| 121 | { | 123 | { |
| 124 | vTaskDelay(pdMS_TO_TICKS(3000)); | ||
| 122 | start_services(); | 125 | start_services(); |
| 123 | vTaskDelete(NULL); | 126 | vTaskDelete(NULL); |
| 124 | } | 127 | } |
| @@ -187,7 +190,15 @@ static void start_services(void) | |||
| 187 | session_manager_init(); | 190 | session_manager_init(); |
| 188 | 191 | ||
| 189 | const tollgate_config_t *cfg = tollgate_config_get(); | 192 | const tollgate_config_t *cfg = tollgate_config_get(); |
| 190 | nucula_wallet_init(cfg->mint_url); | 193 | |
| 194 | mint_health_init(cfg->accepted_mints, cfg->accepted_mint_count); | ||
| 195 | mint_health_start(); | ||
| 196 | |||
| 197 | if (cfg->accepted_mint_count > 1) { | ||
| 198 | nucula_wallet_init_multi(cfg->accepted_mints, cfg->accepted_mint_count); | ||
| 199 | } else { | ||
| 200 | nucula_wallet_init(cfg->mint_url); | ||
| 201 | } | ||
| 191 | lightning_payout_init(&cfg->payout); | 202 | lightning_payout_init(&cfg->payout); |
| 192 | 203 | ||
| 193 | dns_server_start(ap_ip_info.ip, upstream_dns); | 204 | dns_server_start(ap_ip_info.ip, upstream_dns); |
| @@ -216,10 +227,12 @@ static void start_services(void) | |||
| 216 | if (s_services_mutex) xSemaphoreGive(s_services_mutex); | 227 | if (s_services_mutex) xSemaphoreGive(s_services_mutex); |
| 217 | ESP_LOGI(TAG, "=== TollGate services started ==="); | 228 | ESP_LOGI(TAG, "=== TollGate services started ==="); |
| 218 | 229 | ||
| 219 | display_set_state(DISPLAY_READY); | 230 | if (tollgate_config_get()->display_enabled) { |
| 220 | char portal_url[128]; | 231 | display_set_state(DISPLAY_READY); |
| 221 | snprintf(portal_url, sizeof(portal_url), "http://%s/", cfg->ap_ip_str); | 232 | char portal_url[128]; |
| 222 | display_update(cfg->ap_ssid, 0, 0, portal_url); | 233 | snprintf(portal_url, sizeof(portal_url), "http://%s/", cfg->ap_ip_str); |
| 234 | display_update(cfg->ap_ssid, 0, 0, portal_url); | ||
| 235 | } | ||
| 223 | } | 236 | } |
| 224 | 237 | ||
| 225 | static void stop_services(void) | 238 | static void stop_services(void) |
| @@ -306,8 +319,10 @@ void app_main(void) | |||
| 306 | { | 319 | { |
| 307 | ESP_LOGI(TAG, "=== TollGate ESP32 Starting ==="); | 320 | ESP_LOGI(TAG, "=== TollGate ESP32 Starting ==="); |
| 308 | 321 | ||
| 309 | display_init(); | 322 | if (tollgate_config_get()->display_enabled) { |
| 310 | display_set_state(DISPLAY_BOOT); | 323 | display_init(); |
| 324 | display_set_state(DISPLAY_BOOT); | ||
| 325 | } | ||
| 311 | 326 | ||
| 312 | esp_err_t ret = nvs_flash_init(); | 327 | esp_err_t ret = nvs_flash_init(); |
| 313 | if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) { | 328 | if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) { |