upleb.uk

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

summaryrefslogtreecommitdiff
path: root/main/tollgate_main.c
diff options
context:
space:
mode:
authorYour Name <you@example.com>2026-05-17 14:49:16 +0530
committerYour Name <you@example.com>2026-05-17 14:49:16 +0530
commit3342c8e7b4f645c75470d3d893d09037a672cfd2 (patch)
tree0cee003b894525a6097b43ff5ccc0c35c9949900 /main/tollgate_main.c
parent4fb44e7aa8f4643f5027a41e81e96c9ca303930d (diff)
Bug fixes: reset_auth clears sessions, port 80 /usage shows real data, metric defaults to milliseconds, fix sys_evt stack overflow
Diffstat (limited to 'main/tollgate_main.c')
-rw-r--r--main/tollgate_main.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/main/tollgate_main.c b/main/tollgate_main.c
index 6adb0ec..2670f05 100644
--- a/main/tollgate_main.c
+++ b/main/tollgate_main.c
@@ -79,6 +79,12 @@ static void wifi_event_handler(void *arg, esp_event_base_t event_base,
79 } 79 }
80} 80}
81 81
82static void services_start_task(void *pvParameters)
83{
84 start_services();
85 vTaskDelete(NULL);
86}
87
82static void ip_event_handler(void *arg, esp_event_base_t event_base, 88static void ip_event_handler(void *arg, esp_event_base_t event_base,
83 int32_t event_id, void *event_data) 89 int32_t event_id, void *event_data)
84{ 90{
@@ -88,16 +94,11 @@ static void ip_event_handler(void *arg, esp_event_base_t event_base,
88 s_retry_count = 0; 94 s_retry_count = 0;
89 xEventGroupSetBits(s_wifi_event_group, WIFI_CONNECTED_BIT); 95 xEventGroupSetBits(s_wifi_event_group, WIFI_CONNECTED_BIT);
90 96
91 const tollgate_config_t *cfg = tollgate_config_get();
92 nucula_wallet_init(cfg->mint_url);
93
94 lightning_payout_init(&cfg->payout);
95
96 char gw_ip_str[16]; 97 char gw_ip_str[16];
97 snprintf(gw_ip_str, sizeof(gw_ip_str), IPSTR, IP2STR(&event->ip_info.gw)); 98 snprintf(gw_ip_str, sizeof(gw_ip_str), IPSTR, IP2STR(&event->ip_info.gw));
98 tollgate_client_on_sta_connected(gw_ip_str); 99 tollgate_client_on_sta_connected(gw_ip_str);
99 100
100 start_services(); 101 xTaskCreate(services_start_task, "svc_start", 32768, NULL, 5, NULL);
101 } else if (event_base == IP_EVENT && event_id == IP_EVENT_STA_LOST_IP) { 102 } else if (event_base == IP_EVENT && event_id == IP_EVENT_STA_LOST_IP) {
102 ESP_LOGW(TAG, "Lost IP address"); 103 ESP_LOGW(TAG, "Lost IP address");
103 xEventGroupClearBits(s_wifi_event_group, WIFI_CONNECTED_BIT); 104 xEventGroupClearBits(s_wifi_event_group, WIFI_CONNECTED_BIT);
@@ -141,6 +142,9 @@ static void start_services(void)
141 session_manager_init(); 142 session_manager_init();
142 143
143 const tollgate_config_t *cfg = tollgate_config_get(); 144 const tollgate_config_t *cfg = tollgate_config_get();
145 nucula_wallet_init(cfg->mint_url);
146 lightning_payout_init(&cfg->payout);
147
144 dns_server_start(ap_ip_info.ip, upstream_dns); 148 dns_server_start(ap_ip_info.ip, upstream_dns);
145 captive_portal_start(cfg->ap_ip_str); 149 captive_portal_start(cfg->ap_ip_str);
146 tollgate_api_start(); 150 tollgate_api_start();