Files
ESP32_COMM/main/server/http_handlers.h
T
小龙虾 ef6d3a4be3 feat(can): 添加跨通道CAN突发发送功能支持多电机同步驱动
- 新增 /can/send_burst HTTP接口,支持一次SPI事务批量发送多帧CAN消息
- 实现canFdSendBurst函数,通过0xC7 SPI类型实现背靠背装载各通道邮箱
- 添加canBurstCapacity函数计算单次突发最大帧数限制
- 突发发送期间暂停can_feedback_task避免SPI抢占冲突

refactor(can_feedback_task): 改造为周期查询+事件消费模式

- 0xC4/0xC5从GD32主动推送改为ESP32周期查询(250ms/1s)
- 0xC6/0xD2仍保留事件驱动推送模式,由任务消费处理
- 消除OTA期间GD32悬空按铃导致的超时刷屏问题
- 电机OTA期间也暂停任务避免与0xD1抢夺SPI资源

perf(ota_relay): 增加重发次数上限提升传输可靠性

- 将kMaxDataSends从3次增加到5次,提高数据包传输成功率

chore(version): 更新固件版本号至0.3.78

- 版本查询checkVersionWait移到tickInFlight释放后异步触发
- 避免/motor/version请求拖长tick导致tickStuck误报通道闪黄
2026-08-10 00:54:12 +08:00

47 lines
1.9 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#ifndef HTTP_HANDLERS_H
#define HTTP_HANDLERS_H
#include "esp_http_server.h"
// HTTP CORS and options
void http_set_cors_headers(httpd_req_t *req);
/** @brief 给 GET 轮询接口加 Connection: keep-alive,让浏览器复用 TCP 连接,
* 省 4Hz 轮询的握手开销。OTA/relay 等需 close 的 handler 不要调用。 */
void http_set_keepalive_hdr(httpd_req_t *req);
esp_err_t http_options_handler(httpd_req_t *req);
// OTA handlers
esp_err_t esp32_ota_update_handler(httpd_req_t *req);
esp_err_t ota_upload_handler(httpd_req_t *req);
esp_err_t ota_relay_trigger_handler(httpd_req_t *req);
esp_err_t restart_handler(httpd_req_t *req);
// Utility handlers
esp_err_t logs_handler(httpd_req_t *req);
/** @brief CAN 发送(唯一入口):同通道 1~N 帧,单帧即 frames 长度为 1。 */
esp_err_t can_send_batch_handler(httpd_req_t *req);
/** @brief CAN 跨通道突发发送:多帧经 0xC7 一次/多次 SPI 事务背靠背发出,近同时。 */
esp_err_t can_send_burst_handler(httpd_req_t *req);
esp_err_t spi_send_handler(httpd_req_t *req);
esp_err_t system_status_handler(httpd_req_t *req);
esp_err_t system_probe_handler(httpd_req_t *req);
/** @brief GET /system/heap_low_log — 返回设备侧最新 1 条创新低上下文。 */
esp_err_t system_heap_low_log_handler(httpd_req_t *req);
// CAN 反馈快照(被动 0xC1)与接收模式
esp_err_t can_feedback_handler(httpd_req_t *req);
esp_err_t can_mode_handler(httpd_req_t *req);
// 多电机状态(被动 0xC5)
esp_err_t motor_state_handler(httpd_req_t *req);
// 多电机版本(被动 0xC6,事件驱动)
esp_err_t motor_version_handler(httpd_req_t *req);
esp_err_t motor_ota_upload_handler(httpd_req_t *req);
esp_err_t motor_ota_relay_handler(httpd_req_t *req);
esp_err_t motor_ota_status_handler(httpd_req_t *req);
esp_err_t motor_ota_cancel_handler(httpd_req_t *req);
#endif // HTTP_HANDLERS_H