纯前端上位机界面 + esp32_server.py 静态服务/桌面窗口外壳, 不含固件、 不直接访问硬件; 业务 API 由 ESP32_COMM 固件 80 端口跨域提供。 - tabs.html 单窗口多标签外壳, iframe 承载各功能页 - index.html OTA 中继(ESP32 WiFi / GD32 relay / BLE), js/ota + js/ble - can.html / can_monitor.html CAN 通信与接收监控, js/can - motor.html 电机 CAN FD 控制台, js/motor - continuity_test.html LAN9252 通断测试, spi_test.html SPI 测速(临时, 自包含) - 三入口: esp32_app.vbs 桌面窗口 / esp32_web.vbs 浏览器 / serve.bat 控制台调试 - 补 README(页面与目录约定、?v= 缓存版本等改动须知)、.gitignore、 .gitattributes(* -text 保持 Windows 换行原样)
61 lines
2.4 KiB
JavaScript
61 lines
2.4 KiB
JavaScript
// ==================== BLE OTA 协议常量 ====================
|
|
// 与 WiFi OTA 共享界面元素:进度条、阶段流程、日志面板、连接状态、文件选择。
|
|
// 仅传输层不同 (GATT vs HTTP)。通过 connectionMode 变量判断当前模式。
|
|
|
|
export const UUIDS = {
|
|
service: 0xFFFF,
|
|
ctrl: 0x0001,
|
|
dataIn: 0x0002,
|
|
dataOut: 0x0003,
|
|
version: 0x0004,
|
|
};
|
|
|
|
export const UI_BUILD = '2026-07-18-ble-log-trim';
|
|
export const BLE_OTA_NOTIFY_ACK = 0xA1;
|
|
export const BLE_OTA_NOTIFY_FINISH = 0xB1;
|
|
export const BLE_OTA_NOTIFY_SHA256 = 0xC1;
|
|
// ★ 须与后端 main/include/app_config.h BLE_OTA_ACK_WINDOW 保持一致
|
|
// 64:实测 Windows 瓶颈在每窗口 ACK 往返,窗口 32→64 提速 ~10%,再试 96 无收益。
|
|
export const BLE_OTA_ACK_WINDOW = 64;
|
|
export const BLE_OTA_FINISH_ESP32_DONE = 0x02;
|
|
export const BLE_OTA_FINISH_REBOOT_NOW = 0x07;
|
|
export const BLE_OTA_FINISH_GD32_RELAY_START = 0x10;
|
|
export const BLE_OTA_FINISH_GD32_RELAY_DONE = 0x11;
|
|
export const BLE_OTA_FINISH_ABORTED = 0x20; // 用户主动中止(BLE 不断开)
|
|
export const BLE_OTA_CTRL_ABORT_OTA = 0xFB; // 中止当前 OTA(不断开 BLE)
|
|
export const BLE_OTA_FINISH_ERR_FINALIZE = 0x81;
|
|
export const BLE_OTA_FINISH_ERR_MUTEX = 0x83;
|
|
export const BLE_OTA_FINISH_ERR_GD32_SIZE = 0x84;
|
|
export const BLE_OTA_FINISH_ERR_SHA_MISMATCH = 0x85;
|
|
export const BLE_OTA_FINISH_ERR_GD32_RELAY = 0x86;
|
|
export const BLE_OTA_FINISH_ERR_FW_IDENTITY = 0x87; // 包身份不符(疑似 Bootloader/非 APP 包),拒绝中继
|
|
|
|
export const TARGETS = {
|
|
gd32: {
|
|
label: 'GD32',
|
|
packetCmd: 0x00,
|
|
ctrlHex: 'F7',
|
|
recommendedPayload: 480,
|
|
finishText: '自动触发中继',
|
|
hint: '当前目标:<b>GD32</b>。页面会使用 <b>cmd=0x00</b> 发送数据,写入完成后自动触发 SPI OTA 中继。',
|
|
verifyStage: 6,
|
|
finalizeStage: 5,
|
|
stage5Label: '完成触发',
|
|
stage6Label: '校验比对'
|
|
},
|
|
esp32: {
|
|
label: 'ESP32',
|
|
packetCmd: 0x01,
|
|
ctrlHex: 'F8',
|
|
recommendedPayload: 480,
|
|
finishText: '自动完成 OTA',
|
|
hint: '当前目标:ESP32。页面会使用 <b>cmd=0x01</b> 发送数据,写入完成后发 <b>0xF8</b> + 32 字节 SHA-256 触发设备端收尾:设备端读 OTA 分区算 SHA 并比对,一致则 end+set_boot+reboot;不一致上报 0x85,不重启。',
|
|
verifyStage: 5,
|
|
finalizeStage: 6,
|
|
stage5Label: '校验比对',
|
|
stage6Label: '完成触发'
|
|
}
|
|
};
|
|
|
|
export const MAX_LOG_LINES = 1000;
|