This commit is contained in:
fengerli
2025-11-05 11:13:35 +08:00

View File

@ -333,6 +333,13 @@
console.log("连接成功");
these.formData.bleStatu = true;
// 连接成功后同步BleHelper中的连接状态
if (f) {
f.Linked = true;
ble.updateCache();
console.log("页面初始化连接成功同步BleHelper连接状态为已连接");
}
// 确保订阅消息已开启
let linkedDevice = ble.data.LinkedList.find(v => v.deviceId == f.deviceId);
if (linkedDevice && !linkedDevice.notifyState) {
@ -413,8 +420,15 @@
if (res.deviceId == these.formData.deviceId) {
this.formData.bleStatu = true;
// 连接恢复后,确保重新订阅消息以接收设备上报的数据
// 连接恢复后,同步BleHelper中的连接状态
let f = this.getDevice();
if (f) {
f.Linked = true;
ble.updateCache();
console.log("设备连接恢复同步BleHelper连接状态为已连接");
}
// 连接恢复后,确保重新订阅消息以接收设备上报的数据
if (f && (f.notifyServiceid || f.notifyCharactId)) {
console.log("连接恢复,重新订阅消息");
ble.subScribe(res.deviceId, true).then(() => {
@ -474,6 +488,13 @@
});
ble.LinkBlue(these.formData.deviceId).then(() => {
these.formData.bleStatu = true;
// 连接成功后同步BleHelper中的连接状态
let f = this.getDevice();
if (f) {
f.Linked = true;
ble.updateCache();
console.log("蓝牙状态恢复后连接成功同步BleHelper连接状态为已连接");
}
updateLoading(these, {
text: '连接成功'
});
@ -982,6 +1003,13 @@
return;
}
// 发送前确保连接状态同步:如果页面显示已连接,同步更新 BleHelper 中的 Linked 状态
if (this.formData.bleStatu && f) {
f.Linked = true;
ble.updateCache();
console.log("发送模式指令前同步连接状态为已连接");
}
showLoading(these, {
text: "请稍候..."
});
@ -1113,6 +1141,14 @@
text: "请稍候..."
});
this.setBleFormData();
// 发送前确保连接状态同步:如果页面显示已连接,同步更新 BleHelper 中的 Linked 状态
if (this.formData.bleStatu && f) {
f.Linked = true;
ble.updateCache();
console.log("发送人员信息前同步连接状态为已连接");
}
let task = async () => {
var sendTxtPackge = (rgbdata, type, str, lineIndex) => {
@ -1320,6 +1356,13 @@
let f = this.getDevice();
if (f) {
// 发送前确保连接状态同步:如果页面显示已连接,同步更新 BleHelper 中的 Linked 状态
if (this.formData.bleStatu && f) {
f.Linked = true;
ble.updateCache();
console.log("发送亮度指令前同步连接状态为已连接");
}
// 发送数据
ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId, 100).catch(ex => {
@ -1369,6 +1412,13 @@
dataView.setUint8(3, '9C41'); // 数据长度
let f = this.getDevice();
if (f) {
// 发送前确保连接状态同步:如果页面显示已连接,同步更新 BleHelper 中的 Linked 状态
if (this.formData.bleStatu && f) {
f.Linked = true;
ble.updateCache();
console.log("发送命令前同步连接状态为已连接");
}
// 发送数据
ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId, 100).catch(ex => {