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-18 19:07:08 +0530
committerYour Name <you@example.com>2026-05-18 19:07:08 +0530
commit859f9b14e033de9a0690ccbbb975b4b472b688ce (patch)
tree678b248420886b1a17fbd32fc796cb2029863bf6 /main/tollgate_main.c
parent6e6d24169fe7ac8960236293bd39a4532f08f65b (diff)
Move /mints to API server (port 2121), fix services persistence
- /mints handler moved from captive portal (port 80) to API server (port 2121) where it belongs (JSON endpoint, matches portal JS fetch URL) - Remove stop_services() from STA disconnect and IP loss handlers - Services now persist across WiFi STA reconnections - Reduce MAX_STA_RETRY from 5 to 3
Diffstat (limited to 'main/tollgate_main.c')
-rw-r--r--main/tollgate_main.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/main/tollgate_main.c b/main/tollgate_main.c
index 5f3e0e1..018d934 100644
--- a/main/tollgate_main.c
+++ b/main/tollgate_main.c
@@ -26,7 +26,7 @@
26#include "cvm_server.h" 26#include "cvm_server.h"
27#include "display.h" 27#include "display.h"
28 28
29#define MAX_STA_RETRY 5 29#define MAX_STA_RETRY 3
30static const char *TAG = "tollgate_main"; 30static const char *TAG = "tollgate_main";
31 31
32static EventGroupHandle_t s_wifi_event_group; 32static EventGroupHandle_t s_wifi_event_group;
@@ -55,7 +55,6 @@ static void wifi_event_handler(void *arg, esp_event_base_t event_base,
55 s_retry_count++; 55 s_retry_count++;
56 ESP_LOGW(TAG, "WiFi disconnected, retry %d/%d", s_retry_count, MAX_STA_RETRY); 56 ESP_LOGW(TAG, "WiFi disconnected, retry %d/%d", s_retry_count, MAX_STA_RETRY);
57 tollgate_client_on_sta_disconnected(); 57 tollgate_client_on_sta_disconnected();
58 if (s_services_running) stop_services();
59 if (s_retry_count < MAX_STA_RETRY) { 58 if (s_retry_count < MAX_STA_RETRY) {
60 esp_wifi_connect(); 59 esp_wifi_connect();
61 } else { 60 } else {
@@ -112,7 +111,6 @@ static void ip_event_handler(void *arg, esp_event_base_t event_base,
112 } else if (event_base == IP_EVENT && event_id == IP_EVENT_STA_LOST_IP) { 111 } else if (event_base == IP_EVENT && event_id == IP_EVENT_STA_LOST_IP) {
113 ESP_LOGW(TAG, "Lost IP address"); 112 ESP_LOGW(TAG, "Lost IP address");
114 xEventGroupClearBits(s_wifi_event_group, WIFI_CONNECTED_BIT); 113 xEventGroupClearBits(s_wifi_event_group, WIFI_CONNECTED_BIT);
115 stop_services();
116 } 114 }
117} 115}
118 116
@@ -319,10 +317,8 @@ void app_main(void)
319 317
320 ESP_LOGI(TAG, "WiFi AP+STA started, waiting for connection..."); 318 ESP_LOGI(TAG, "WiFi AP+STA started, waiting for connection...");
321 319
322 if (tollgate_config_get_wifi(&(wifi_config_t){0}) != ESP_OK) { 320 xTaskCreate(services_start_task, "svc_start", 32768, NULL, 5, NULL);
323 ESP_LOGI(TAG, "No STA network configured, starting services immediately"); 321 ESP_LOGI(TAG, "Services starting immediately (AP-only mode, STA will connect when available)");
324 xTaskCreate(services_start_task, "svc_start", 32768, NULL, 5, NULL);
325 }
326 322
327 while (1) { 323 while (1) {
328 vTaskDelay(pdMS_TO_TICKS(1000)); 324 vTaskDelay(pdMS_TO_TICKS(1000));