feat: 添加健康监控系统并重构代码结构

- 新增health_monitor模块,包含温度、电压、WiFi RSSI监控功能
- 移除旧的app_main.h/app_main.c和debug模块,将调试日志移动到monitor目录
- 在main.cpp中替换system_monitor_task为health_monitor_task
- 更新CMakeLists.txt依赖项,添加esp_driver_tsens和esp_driver_uart
- 修改WiFi配置参数,更新SSID和密码设置方式
- 在Python工具中修复OTA客户端重新连接逻辑
- 调整任务优先级分配,统一使用核心0以适配ESP32-C3单核架构
This commit is contained in:
小龙虾
2026-04-27 02:34:47 +08:00
parent bcfe130451
commit 7bb28cee1e
32 changed files with 177 additions and 191 deletions
+20 -25
View File
@@ -8,17 +8,15 @@
#include "esp_log.h"
#include "esp_chip_info.h"
#include "core/app_main.h"
#include "ota_relay.h"
#include "spi_master.h"
#include "wifi_ota.h"
#include "ble_ota.h"
#include "protocol.h"
#include "debug_log.h"
#include "monitor/health_monitor.h"
#include "relay/ota_relay.h"
#include "transport/spi_master.h"
#include "server/wifi_ota.h"
#include "server/ble_ota.h"
#include "transport/protocol.h"
#include "monitor/debug_log.h"
extern "C" void app_main(void);
void app_main(void)
extern "C" void app_main(void)
{
esp_chip_info_t chip_info;
esp_chip_info(&chip_info);
@@ -31,6 +29,17 @@ void app_main(void)
DEBUG_INFO("MAIN", "Free heap: %lu bytes", esp_get_free_heap_size());
DEBUG_INFO("MAIN", "========================================");
// 健康监控任务(温度 + 电压 + WiFi RSSI)
xTaskCreatePinnedToCore(
health_monitor_task,
"health_mon",
4096,
NULL,
configMAX_PRIORITIES - 4,
NULL,
0
);
// 初始化协议层(CRC、AES)
protocol_init();
DEBUG_INFO("MAIN", "协议层初始化完成");
@@ -46,20 +55,6 @@ void app_main(void)
// 创建 FreeRTOS 任务
BaseType_t xRet;
// 系统监控任务(最高优先级)
xRet = xTaskCreatePinnedToCore(
system_monitor_task,
"sys_monitor",
4096,
NULL,
configMAX_PRIORITIES - 1,
NULL,
1 // 核1
);
if (xRet != pdPASS) {
DEBUG_ERR("MAIN", "创建 system_monitor_task 失败");
}
// OTA 中继任务(中高优先级)
xRet = xTaskCreatePinnedToCore(
ota_relay_task,
@@ -96,7 +91,7 @@ void app_main(void)
NULL,
configMAX_PRIORITIES - 3,
NULL,
1
0 // ESP32-C3 单核,固定核0
);
if (xRet != pdPASS) {
DEBUG_ERR("MAIN", "创建 ble_ota_task 失败");