feat(link): DeviceLink 外壳单例统一 ESP32/ECAT/BLE 健康态

各页只共用 IP、各自 fetch 导致同屏「已连接/连接失败」分裂。
外壳 Owner 轮询 /system/status 与 EtherCAT 状态,BroadcastChannel
广播快照;连接灯只认共享层,SPI 失败单独文案不覆盖设备离线。
This commit is contained in:
cbb
2026-09-16 02:50:12 +08:00
parent be26f4daa2
commit 670b833dc6
6 changed files with 422 additions and 10 deletions
+4
View File
@@ -33,6 +33,7 @@ import {
import { setBleStage, setBleStageError, setBleStageText, setBleStageStatus, resetBleStages } from './stages.js';
import { setProgress, updateProgressFromAck } from './transfer.js';
import { showBleVerifyInfo } from './verify.js';
import { deviceLink } from '../common/device-link.js';
import {
clearOtaResultWaiter,
resolveOtaResult,
@@ -104,6 +105,7 @@ export async function connectBle() {
setBleStage(2, '已就绪', null);
setConnectionState(true);
try { deviceLink.reportBle(true, device.name || ''); } catch (_) {}
bleLog('BLE', 'GATT 服务与特征获取完成');
await enableNotifications();
// ★ enableNotifications 内部已包含重试 + 主动断开逻辑;
@@ -129,6 +131,7 @@ export async function connectBle() {
export function onDisconnected() {
bleLog('BLE', '设备已断开', 'W');
var wasExpected = state.expectedReboot;
try { deviceLink.reportBle(false, ''); } catch (_) {}
resetUiAfterDisconnect();
if (wasExpected && state.device) {
// 是主动重启引起的断开,启动自动重连
@@ -151,6 +154,7 @@ export async function disconnectBle() {
if (state.device && state.device.gatt && state.device.gatt.connected) {
state.device.gatt.disconnect();
}
try { deviceLink.reportBle(false, ''); } catch (_) {}
resetUiAfterDisconnect();
}