From af0da04e7d8a1084a7480bce92348b8f278eb4b2 Mon Sep 17 00:00:00 2001 From: GW_MC <72297530+GWMCwing@users.noreply.github.com> Date: Wed, 4 Feb 2026 11:54:28 +0800 Subject: [PATCH] feat(main): Add SNTP configuration for time synchronization and update event wait conditions --- main/main.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/main/main.cpp b/main/main.cpp index 9d3e900..19c2877 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -28,6 +28,7 @@ #include #include "lvgl.h" +#include // nvs storage namespaces, 15 characters max #define DEFAULT_STORAGE_NAMESPACE "storage" @@ -43,7 +44,9 @@ void init_queues( void app_main(void) { display_chip_info(); - + // set to hkt + setenv("TZ", "HKT-8", 1); + tzset(); // Initialize default event loop early - required for UI events esp_err_t err = esp_event_loop_create_default(); if (err != ESP_OK && err != ESP_ERR_INVALID_STATE) { @@ -105,13 +108,15 @@ void app_main(void) { ESP_LOGI(TAG, "Waiting for system to be ready...\n"); xEventGroupWaitBits( system_event_group, - // DISPLAY_READY_BIT | STORAGE_READY_BIT | NETWORK_READY_BIT, - DISPLAY_READY_BIT, + DISPLAY_READY_BIT | NETWORK_READY_BIT, // do not clear on exit, require explicit reset pdFALSE, pdTRUE, portMAX_DELAY ); + esp_sntp_config_t config = ESP_NETIF_SNTP_DEFAULT_CONFIG("pool.ntp.org"); + esp_netif_sntp_init(&config); + ESP_LOGI(TAG, "System is ready. Starting main application...\n"); AppRegistry& app_registry = AppRegistry::instance();