feat: 添加局域网设备发现功能和链路胶囊优化

- 实现局域网设备发现面板,支持探测ESP32中继板并自动切换端点
- 添加POST /api/lan/probe接口用于设备探测,返回三态判决结果
- 实现快扫和全段扫描两种模式,支持种子地址优先探测
- 添加端点唯一写手机制,防止多处同时修改设备IP
- 优化链路胶囊UI显示WiFi/EtherCAT/BLE连接状态和设备名称
- 修复EtherCAT链路OTA刷写期间PDO循环暂停和AL状态处理问题
- 调整PDO周期设置范围为0.125-4ms,支持亚毫秒显示为微秒
- 添加ESP32 WiFi使能开关控件样式和数据来源角标显示
This commit is contained in:
cbb
2026-10-13 00:48:34 +08:00
parent 514070b36d
commit eac3717f9a
41 changed files with 4229 additions and 934 deletions
+21 -7
View File
@@ -110,12 +110,24 @@ export function setReadyHint(html) {
export function setConnectionState(connected) {
const idle = connected && state.selectedFile && !state.uploading;
// BLE 模式:连接状态只写顶栏胶囊,避免下方重复文案
window.__bleConnState = !!connected;
// 顶栏 BLE 胶囊:连接后显示「设备名 · 设备ID」,未连接显示「未连接」
var pc = document.getElementById('pillBle');
var pct = document.getElementById('pillBleTxt');
if (pc) pc.className = 'pill link-pill ' + (connected ? 'online' : 'offline');
if (pct) {
if (connected) {
var nm = window.__bleDeviceName || '已连接';
var id = window.__bleDeviceId;
pct.textContent = id ? (nm + ' · ' + id) : nm;
} else {
pct.textContent = '未连接';
}
}
try {
if (window.updateLinkPills) window.updateLinkPills(null, !!connected);
} catch (_) {}
if (typeof connectionMode !== 'undefined' && connectionMode === 'ble') {
var pc = document.getElementById('pillConn');
var pct = document.getElementById('pillConnTxt');
if (pc) pc.className = connected ? 'pill online' : 'pill offline';
if (pct) pct.textContent = connected ? 'BLE 已连接' : 'BLE 未连接';
if (els.connState) {
els.connState.textContent = connected ? '已连接' : '未连接';
if (els.connState.parentElement) {
@@ -141,6 +153,8 @@ export function setConnectionState(connected) {
els.abortBtn.disabled = !state.uploading;
if (!connected) {
window.__bleDeviceName = '';
window.__bleDeviceId = '';
setReadyHint('当前未连接设备。建议顺序:连接设备 → 选择固件 → 开始刷写。');
} else if (!state.notificationsEnabled) {
setReadyHint('设备已连接,正在自动准备刷写通道。若长时间无响应,请断开后重连。');
@@ -164,8 +178,8 @@ export function resetUiAfterDisconnect() {
state.lastUploadStatus = 'idle';
state.deviceSha256 = null;
if (typeof connectionMode === 'undefined' || connectionMode === 'ble') {
els.deviceName.textContent = '-';
els.deviceId.textContent = '-';
window.__bleDeviceName = '';
window.__bleDeviceId = '';
if (els.versionText) els.versionText.textContent = '未读取';
var pv = document.getElementById('pillVer');
if (pv) pv.textContent = 'v--';