refactor(ota): 移除ESP32 OTA架构中的高危设计问题并优化状态管理
- 移除OtaRelay职责过载问题,将状态查询统一收口到OtaCoordinator::getSnapshot() - 新增OtaSnapshot结构体,一次性获取完整的OTA系统状态快照,避免分散读取 - 将GD32 APP探测逻辑从system_status_handler中分离,提供独立的/system/probe端点 - 修复并发安全隐患,确保processEvent()读取relayState时持有锁保护 - 优化SPI通信相关代码结构,提升系统稳定性 BREAKING CHANGE: 移除了原有的分散状态查询接口,统一使用快照方式获取状态
This commit is contained in:
@@ -517,20 +517,37 @@ esp_err_t WifiOta::httpServerStart()
|
||||
};
|
||||
httpd_register_uri_handler(WifiOta::instance().m_httpServer, &logs_options_uri);
|
||||
|
||||
httpd_uri_t system_status_uri = {
|
||||
// 系统状态查询端点
|
||||
httpd_uri_t status_uri = {
|
||||
.uri = "/system/status",
|
||||
.method = HTTP_GET,
|
||||
.handler = system_status_handler,
|
||||
.user_ctx = NULL
|
||||
};
|
||||
httpd_register_uri_handler(WifiOta::instance().m_httpServer, &system_status_uri);
|
||||
httpd_uri_t system_status_options_uri = {
|
||||
httpd_register_uri_handler(WifiOta::instance().m_httpServer, &status_uri);
|
||||
httpd_uri_t status_options_uri = {
|
||||
.uri = "/system/status",
|
||||
.method = HTTP_OPTIONS,
|
||||
.handler = http_options_handler,
|
||||
.user_ctx = NULL
|
||||
};
|
||||
httpd_register_uri_handler(WifiOta::instance().m_httpServer, &system_status_options_uri);
|
||||
httpd_register_uri_handler(WifiOta::instance().m_httpServer, &status_options_uri);
|
||||
|
||||
// PR2: GD32 APP 探测端点
|
||||
httpd_uri_t system_probe_uri = {
|
||||
.uri = "/system/probe",
|
||||
.method = HTTP_GET,
|
||||
.handler = system_probe_handler,
|
||||
.user_ctx = NULL
|
||||
};
|
||||
httpd_register_uri_handler(WifiOta::instance().m_httpServer, &system_probe_uri);
|
||||
httpd_uri_t system_probe_options_uri = {
|
||||
.uri = "/system/probe",
|
||||
.method = HTTP_OPTIONS,
|
||||
.handler = http_options_handler,
|
||||
.user_ctx = NULL
|
||||
};
|
||||
httpd_register_uri_handler(WifiOta::instance().m_httpServer, &system_probe_options_uri);
|
||||
|
||||
// CAN 帧转发
|
||||
httpd_uri_t can_send_uri = {
|
||||
@@ -564,7 +581,7 @@ esp_err_t WifiOta::httpServerStart()
|
||||
};
|
||||
httpd_register_uri_handler(WifiOta::instance().m_httpServer, &spi_send_options_uri);
|
||||
|
||||
DEBUG_INFO("WIFI", "注册端点: /ota/upload, /ota/relay, /ota/update, /restart, /logs, /system/status, /can/send, /spi/send");
|
||||
DEBUG_INFO("WIFI", "注册端点: /ota/upload, /ota/relay, /ota/update, /restart, /logs, /system/status, /system/probe, /can/send, /spi/send");
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user