feat(main): Add SNTP configuration for time synchronization and update event wait conditions

This commit is contained in:
GW_MC
2026-02-04 11:54:28 +08:00
parent a93b7fe029
commit af0da04e7d

View File

@@ -28,6 +28,7 @@
#include <esp_task_wdt.h> #include <esp_task_wdt.h>
#include "lvgl.h" #include "lvgl.h"
#include <esp_netif_sntp.h>
// nvs storage namespaces, 15 characters max // nvs storage namespaces, 15 characters max
#define DEFAULT_STORAGE_NAMESPACE "storage" #define DEFAULT_STORAGE_NAMESPACE "storage"
@@ -43,7 +44,9 @@ void init_queues(
void app_main(void) { void app_main(void) {
display_chip_info(); display_chip_info();
// set to hkt
setenv("TZ", "HKT-8", 1);
tzset();
// Initialize default event loop early - required for UI events // Initialize default event loop early - required for UI events
esp_err_t err = esp_event_loop_create_default(); esp_err_t err = esp_event_loop_create_default();
if (err != ESP_OK && err != ESP_ERR_INVALID_STATE) { 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"); ESP_LOGI(TAG, "Waiting for system to be ready...\n");
xEventGroupWaitBits( xEventGroupWaitBits(
system_event_group, system_event_group,
// DISPLAY_READY_BIT | STORAGE_READY_BIT | NETWORK_READY_BIT, DISPLAY_READY_BIT | NETWORK_READY_BIT,
DISPLAY_READY_BIT,
// do not clear on exit, require explicit reset // do not clear on exit, require explicit reset
pdFALSE, pdFALSE,
pdTRUE, pdTRUE,
portMAX_DELAY 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"); ESP_LOGI(TAG, "System is ready. Starting main application...\n");
AppRegistry& app_registry = AppRegistry::instance(); AppRegistry& app_registry = AppRegistry::instance();