feat(lcd): display synchronized wall clock
This commit is contained in:
@@ -156,6 +156,14 @@
|
||||
#define CONFIG_TQ_LOCAL_TASK_CORE 1
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_TQ_TIME_SNTP_SERVER
|
||||
#define CONFIG_TQ_TIME_SNTP_SERVER "ntp.aliyun.com"
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_TQ_TIME_POSIX_TZ
|
||||
#define CONFIG_TQ_TIME_POSIX_TZ "CST-8"
|
||||
#endif
|
||||
|
||||
#if CONFIG_TQ_NETWORK_TASK_CORE < 0
|
||||
#define CONTROL_PLANE_NETWORK_TASK_CORE tskNO_AFFINITY
|
||||
#else
|
||||
@@ -168,10 +176,6 @@
|
||||
#define CONTROL_PLANE_LOCAL_TASK_CORE ((BaseType_t)CONFIG_TQ_LOCAL_TASK_CORE)
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_FORTUNE_SNTP_SERVER
|
||||
#define CONFIG_FORTUNE_SNTP_SERVER "ntp.aliyun.com"
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_FORTUNE_USER_CONFIG_HTTP_PORT
|
||||
#define CONFIG_FORTUNE_USER_CONFIG_HTTP_PORT 80
|
||||
#endif
|
||||
@@ -188,8 +192,6 @@
|
||||
#define CONTROL_PLANE_FORTUNE_CONNECT_POLL_MS 1000
|
||||
#define CONTROL_PLANE_FORTUNE_REFRESH_POLL_MS 1000
|
||||
#define CONTROL_PLANE_FORTUNE_WS_SETTLE_MAX_MS (30 * 1000)
|
||||
/* China Standard Time (UTC+8, no DST). Used to detect local midnight. */
|
||||
#define CONTROL_PLANE_FORTUNE_POSIX_TZ "CST-8"
|
||||
#endif
|
||||
|
||||
static const char *TAG = "cp_rt_workers";
|
||||
@@ -2004,6 +2006,16 @@ static void control_plane_stop_user_config_server(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
static void control_plane_start_wall_clock_sync(void)
|
||||
{
|
||||
esp_err_t err = domain_runtime_time_sync_start(CONFIG_TQ_TIME_SNTP_SERVER,
|
||||
CONFIG_TQ_TIME_POSIX_TZ);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGW(TAG, "Start wall-clock synchronization failed: %s",
|
||||
esp_err_to_name(err));
|
||||
}
|
||||
}
|
||||
|
||||
static void control_plane_wifi_state_task(void *arg)
|
||||
{
|
||||
(void)arg;
|
||||
@@ -2047,6 +2059,7 @@ static void control_plane_wifi_state_task(void *arg)
|
||||
disconnected_expression_active = true;
|
||||
last_disconnected_request_tick = xTaskGetTickCount();
|
||||
} else {
|
||||
control_plane_start_wall_clock_sync();
|
||||
(void)control_plane_schedule_websocket_wait_task();
|
||||
esp_err_t web_err = control_plane_ensure_user_config_server();
|
||||
if (web_err != ESP_OK) {
|
||||
@@ -2208,6 +2221,7 @@ static void control_plane_wifi_state_task(void *arg)
|
||||
|
||||
if (connected && (!was_connected || disconnected_expression_active)) {
|
||||
ESP_LOGI(TAG, "Wi-Fi STA connected; restoring idle expression");
|
||||
control_plane_start_wall_clock_sync();
|
||||
control_plane_request_wifi_state_expression(DOMAIN_EXPRESSION_IDLE,
|
||||
DOMAIN_EXPRESSION_TRIGGER_WIFI_RECONNECTED,
|
||||
"Wi-Fi reconnected");
|
||||
@@ -2318,8 +2332,8 @@ static void control_plane_fortune_delay_ms(uint32_t delay_ms)
|
||||
|
||||
static esp_err_t control_plane_wait_for_synced_time(void)
|
||||
{
|
||||
esp_err_t err = domain_runtime_time_sync_start(CONFIG_FORTUNE_SNTP_SERVER,
|
||||
CONTROL_PLANE_FORTUNE_POSIX_TZ);
|
||||
esp_err_t err = domain_runtime_time_sync_start(CONFIG_TQ_TIME_SNTP_SERVER,
|
||||
CONFIG_TQ_TIME_POSIX_TZ);
|
||||
if (err != ESP_OK) {
|
||||
return err;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user