diff options
| author | Your Name <you@example.com> | 2026-05-18 22:55:37 +0530 |
|---|---|---|
| committer | Your Name <you@example.com> | 2026-05-18 22:55:37 +0530 |
| commit | 46e7dabaf80333ca045061ff480377a4186e5deb (patch) | |
| tree | 06bd62bed43e15c432cc27faf20993a50d7c3cee /main/tollgate_main.c | |
| parent | eb2ae72d91a4b2ec0333a2e6d18eeeeee6b60464 (diff) | |
feat: integrate touchscreen WiFi setup into display UI
- Add DISPLAY_WIFI_SETUP state with full rendering pipeline
- Touch init on display_init(), touch polling in display task
- WiFi scan triggered on setup entry, sorted AP list
- On-screen keyboard for password entry
- Connect result via WiFi event notifications
- Setup button on READY and ERROR screens
- Auto-enter WiFi setup on first boot with no credentials
- Save new WiFi credentials to SPIFFS config.json
Diffstat (limited to 'main/tollgate_main.c')
| -rw-r--r-- | main/tollgate_main.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/main/tollgate_main.c b/main/tollgate_main.c index 345295a..59d25f5 100644 --- a/main/tollgate_main.c +++ b/main/tollgate_main.c | |||
| @@ -54,6 +54,7 @@ static void wifi_event_handler(void *arg, esp_event_base_t event_base, | |||
| 54 | s_retry_count++; | 54 | s_retry_count++; |
| 55 | ESP_LOGW(TAG, "WiFi disconnected, retry %d/%d", s_retry_count, MAX_STA_RETRY); | 55 | ESP_LOGW(TAG, "WiFi disconnected, retry %d/%d", s_retry_count, MAX_STA_RETRY); |
| 56 | tollgate_client_on_sta_disconnected(); | 56 | tollgate_client_on_sta_disconnected(); |
| 57 | display_notify_wifi_disconnected(); | ||
| 57 | if (s_services_running) { | 58 | if (s_services_running) { |
| 58 | stop_services(); | 59 | stop_services(); |
| 59 | display_set_state(DISPLAY_ERROR); | 60 | display_set_state(DISPLAY_ERROR); |
| @@ -102,6 +103,10 @@ static void ip_event_handler(void *arg, esp_event_base_t event_base, | |||
| 102 | s_retry_count = 0; | 103 | s_retry_count = 0; |
| 103 | xEventGroupSetBits(s_wifi_event_group, WIFI_CONNECTED_BIT); | 104 | xEventGroupSetBits(s_wifi_event_group, WIFI_CONNECTED_BIT); |
| 104 | 105 | ||
| 106 | char ip_str[16]; | ||
| 107 | snprintf(ip_str, sizeof(ip_str), IPSTR, IP2STR(&event->ip_info.ip)); | ||
| 108 | display_notify_wifi_connected(ip_str); | ||
| 109 | |||
| 105 | esp_sntp_stop(); | 110 | esp_sntp_stop(); |
| 106 | esp_sntp_setoperatingmode(SNTP_OPMODE_POLL); | 111 | esp_sntp_setoperatingmode(SNTP_OPMODE_POLL); |
| 107 | esp_sntp_setservername(0, "pool.ntp.org"); | 112 | esp_sntp_setservername(0, "pool.ntp.org"); |
| @@ -320,7 +325,8 @@ void app_main(void) | |||
| 320 | tcfg->mint_url, tcfg->price_per_step, "connecting..."); | 325 | tcfg->mint_url, tcfg->price_per_step, "connecting..."); |
| 321 | 326 | ||
| 322 | if (tollgate_config_get_wifi(&(wifi_config_t){0}) != ESP_OK) { | 327 | if (tollgate_config_get_wifi(&(wifi_config_t){0}) != ESP_OK) { |
| 323 | ESP_LOGI(TAG, "No STA network configured, starting services immediately"); | 328 | ESP_LOGI(TAG, "No STA network configured, entering WiFi setup"); |
| 329 | display_enter_wifi_setup(); | ||
| 324 | xTaskCreate(services_start_task, "svc_start", 32768, NULL, 5, NULL); | 330 | xTaskCreate(services_start_task, "svc_start", 32768, NULL, 5, NULL); |
| 325 | } | 331 | } |
| 326 | 332 | ||