fix(link): ECAT 轮询必重挂;连接灯不覆盖语义文案;BLE 通知成功后再上报

This commit is contained in:
cbb
2026-09-16 02:53:53 +08:00
parent 670b833dc6
commit 6b5a9f9adc
3 changed files with 9 additions and 8 deletions
+3 -1
View File
@@ -105,19 +105,21 @@ export async function connectBle() {
setBleStage(2, '已就绪', null);
setConnectionState(true);
try { deviceLink.reportBle(true, device.name || ''); } catch (_) {}
bleLog('BLE', 'GATT 服务与特征获取完成');
await enableNotifications();
// ★ enableNotifications 内部已包含重试 + 主动断开逻辑;
// 若返回时仍为 false,说明连接半死,UI 已被断开事件重置,不要继续推进到 Stage 3
if (!state.notificationsEnabled) {
try { deviceLink.reportBle(false, ''); } catch (_) {}
bleLog('BLE', '连接就绪但 DATA_OUT 通知开启失败,等待用户重连', 'E');
return;
}
try { deviceLink.reportBle(true, device.name || ''); } catch (_) {}
// Mark stages 1-2 as done
setBleStage(3, '', null);
setBleStageText('BLE 连接就绪,请选择固件文件');
} catch (err) {
try { deviceLink.reportBle(false, ''); } catch (_) {}
bleLog('BLE', `连接失败: ${err.message}`, 'E');
if (err.name !== 'NotFoundError') {
setBleStageError(err.message);