diff options
Diffstat (limited to 'main/tollgate_main.c')
| -rw-r--r-- | main/tollgate_main.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/main/tollgate_main.c b/main/tollgate_main.c index dda4142..346e1c0 100644 --- a/main/tollgate_main.c +++ b/main/tollgate_main.c | |||
| @@ -47,8 +47,9 @@ static void wifi_event_handler(void *arg, esp_event_base_t event_base, | |||
| 47 | } | 47 | } |
| 48 | esp_wifi_connect(); | 48 | esp_wifi_connect(); |
| 49 | } else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_DISCONNECTED) { | 49 | } else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_DISCONNECTED) { |
| 50 | wifi_event_sta_disconnected_t *disconn = (wifi_event_sta_disconnected_t *)event_data; | ||
| 50 | s_retry_count++; | 51 | s_retry_count++; |
| 51 | ESP_LOGW(TAG, "WiFi disconnected, retry %d/%d", s_retry_count, MAX_STA_RETRY); | 52 | ESP_LOGW(TAG, "WiFi disconnected, reason=%d, retry %d/%d", disconn->reason, s_retry_count, MAX_STA_RETRY); |
| 52 | tollgate_client_on_sta_disconnected(); | 53 | tollgate_client_on_sta_disconnected(); |
| 53 | if (s_retry_count < MAX_STA_RETRY) { | 54 | if (s_retry_count < MAX_STA_RETRY) { |
| 54 | esp_wifi_connect(); | 55 | esp_wifi_connect(); |
| @@ -285,6 +286,15 @@ void app_main(void) | |||
| 285 | if (tollgate_config_get_wifi(&(wifi_config_t){0}) != ESP_OK) { | 286 | if (tollgate_config_get_wifi(&(wifi_config_t){0}) != ESP_OK) { |
| 286 | ESP_LOGI(TAG, "No STA network configured, starting services immediately"); | 287 | ESP_LOGI(TAG, "No STA network configured, starting services immediately"); |
| 287 | xTaskCreate(services_start_task, "svc_start", 32768, NULL, 5, NULL); | 288 | xTaskCreate(services_start_task, "svc_start", 32768, NULL, 5, NULL); |
| 289 | } else { | ||
| 290 | ESP_LOGI(TAG, "STA configured, waiting up to 30s for connection..."); | ||
| 291 | for (int i = 0; i < 30 && !s_services_running; i++) { | ||
| 292 | vTaskDelay(pdMS_TO_TICKS(1000)); | ||
| 293 | } | ||
| 294 | if (!s_services_running) { | ||
| 295 | ESP_LOGW(TAG, "STA not connected after 30s, starting services anyway"); | ||
| 296 | xTaskCreate(services_start_task, "svc_start", 32768, NULL, 5, NULL); | ||
| 297 | } | ||
| 288 | } | 298 | } |
| 289 | 299 | ||
| 290 | while (1) { | 300 | while (1) { |