纯前端上位机界面 + 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 换行原样)
43 lines
1.4 KiB
JavaScript
43 lines
1.4 KiB
JavaScript
/**
|
|
* ble_ota.js - BLE OTA 控制台入口
|
|
*
|
|
* 薄入口:import 所有 ble/* 模块,组装并导出 window.bleOta API 对象,
|
|
* 调用 init() 完成事件绑定与 UI 初始化。
|
|
*/
|
|
import { UI_BUILD } from './ble/constants.js';
|
|
import {
|
|
state, els, bleLog, refreshTargetUi, setConnectionState,
|
|
resetUiAfterDisconnect
|
|
} from './ble/state.js';
|
|
import { resetBleStages } from './ble/stages.js';
|
|
import { connectBle, disconnectBle } from './ble/gatt.js';
|
|
import { clearSelectedFile, notifyFileChange } from './ble/file.js';
|
|
import { autoFlash } from './ble/transfer.js';
|
|
import { abortTask, bindEvents } from './ble/session.js';
|
|
import { showToast } from './common/toast.js';
|
|
|
|
window.bleOta = {
|
|
init: function() {
|
|
bindEvents();
|
|
refreshTargetUi();
|
|
setConnectionState(false);
|
|
resetBleStages();
|
|
bleLog('SYS', `Web Bluetooth 刷写控制台已就绪 (${UI_BUILD})`);
|
|
},
|
|
state: state,
|
|
disconnect: disconnectBle,
|
|
showToast: showToast,
|
|
notifyFileChange: notifyFileChange,
|
|
clearFile: clearSelectedFile,
|
|
refreshButtons: function() {
|
|
setConnectionState(!!state.server);
|
|
},
|
|
refreshTargetUi: refreshTargetUi,
|
|
// ★ 暴露上传状态查询,供 index.html 的 selectFlashTarget 等外部守卫使用
|
|
isUploading: function() {
|
|
return !!(state.uploading || state.autoFlashing);
|
|
},
|
|
};
|
|
|
|
// 脚本以 type="module" 加载(默认 defer),DOM 元素已就绪,直接初始化
|
|
window.bleOta.init(); |