feat: 添加时区设置功能,默认时区改为 CST-8
- 新增 set_timezone LLM 工具,支持通过对话设置时区 - 新增 set_timezone / timezone_show CLI 命令 - 默认时区从 PST 改为 CST-8(中国标准时间 UTC+8) - 支持 POSIX 格式和 18 个城市名映射(Asia/Shanghai 等) - 时区通过 NVS 持久化存储(system_config namespace) - config_show 中显示当前时区配置 - 更新 changelog.md 和 taolun.md 文档
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#include "mimi_config.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
#include <inttypes.h>
|
||||
#include "esp_log.h"
|
||||
#include "esp_wifi.h"
|
||||
@@ -12,6 +13,7 @@
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/event_groups.h"
|
||||
#include "freertos/timers.h"
|
||||
|
||||
static const char *TAG = "wifi";
|
||||
|
||||
@@ -20,6 +22,15 @@ static int s_retry_count = 0;
|
||||
static char s_ip_str[16] = "0.0.0.0";
|
||||
static bool s_connected = false;
|
||||
static bool s_reconnect_enabled = true;
|
||||
static TimerHandle_t s_retry_timer = NULL;
|
||||
|
||||
static void retry_timer_callback(TimerHandle_t xTimer)
|
||||
{
|
||||
(void)xTimer;
|
||||
if (s_reconnect_enabled && !s_connected) {
|
||||
esp_wifi_connect();
|
||||
}
|
||||
}
|
||||
|
||||
static const char *wifi_reason_to_str(wifi_err_reason_t reason)
|
||||
{
|
||||
@@ -77,9 +88,10 @@ static void event_handler(void *arg, esp_event_base_t event_base,
|
||||
}
|
||||
ESP_LOGW(TAG, "Disconnected, retry %d/%d in %" PRIu32 "ms",
|
||||
s_retry_count + 1, MIMI_WIFI_MAX_RETRY, delay_ms);
|
||||
vTaskDelay(pdMS_TO_TICKS(delay_ms));
|
||||
esp_wifi_connect();
|
||||
s_retry_count++;
|
||||
/* Use timer instead of blocking vTaskDelay in event handler */
|
||||
if (s_retry_timer) xTimerStop(s_retry_timer, 0);
|
||||
xTimerChangePeriod(s_retry_timer, pdMS_TO_TICKS(delay_ms), 0);
|
||||
} else {
|
||||
ESP_LOGE(TAG, "Failed to connect after %d retries", MIMI_WIFI_MAX_RETRY);
|
||||
xEventGroupSetBits(s_wifi_event_group, WIFI_FAIL_BIT);
|
||||
@@ -98,6 +110,7 @@ static void event_handler(void *arg, esp_event_base_t event_base,
|
||||
esp_err_t wifi_manager_init(void)
|
||||
{
|
||||
s_wifi_event_group = xEventGroupCreate();
|
||||
s_retry_timer = xTimerCreate("wifi_retry", pdMS_TO_TICKS(1000), pdFALSE, NULL, retry_timer_callback);
|
||||
|
||||
ESP_ERROR_CHECK(esp_netif_init());
|
||||
esp_netif_create_default_wifi_sta();
|
||||
|
||||
Reference in New Issue
Block a user