修复部分机型蓝牙报错的问题
This commit is contained in:
@ -184,22 +184,22 @@
|
||||
},
|
||||
onLoad(option) {
|
||||
eventChannel = this.getOpenerEventChannel();
|
||||
|
||||
|
||||
eventChannel.on('detailData', function(rec) {
|
||||
console.log("接收到父页面的参数:", rec);
|
||||
these.device = rec.data;
|
||||
if (rec.data.bluetoothName) {
|
||||
these.search = rec.data.bluetoothName;
|
||||
}else if(rec.data.deviceName){
|
||||
} else if (rec.data.deviceName) {
|
||||
these.search = rec.data.deviceName;
|
||||
}
|
||||
|
||||
|
||||
startValidDevice();
|
||||
|
||||
|
||||
});
|
||||
let search = option.search;
|
||||
these = this;
|
||||
|
||||
|
||||
const systemInfo = uni.getSystemInfoSync();
|
||||
|
||||
ble = bleTool.getBleTool(); // Ensure ble is initialized
|
||||
@ -464,7 +464,7 @@
|
||||
|
||||
StartSubsrib();
|
||||
|
||||
|
||||
|
||||
|
||||
},
|
||||
|
||||
@ -533,21 +533,15 @@
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
ble.StopSearch().finally(() => {
|
||||
|
||||
let disconnectPromises = [];
|
||||
if (ble.data && ble.data.LinkedList) {
|
||||
ble.data.LinkedList.forEach(device => {
|
||||
console.log(`Requesting disconnect for ${device.deviceId}`);
|
||||
disconnectPromises.push(ble.disconnectDevice(device.deviceId));
|
||||
});
|
||||
showLoading(these,{text:'正在刷新'})
|
||||
let time = null;
|
||||
let startSearch = () => {
|
||||
|
||||
if(time){
|
||||
clearTimeout(time);
|
||||
}
|
||||
|
||||
Promise.allSettled(disconnectPromises).finally(() => {
|
||||
|
||||
|
||||
time = setTimeout(() => {
|
||||
these.EquipMents = [];
|
||||
these.PairEquip = [];
|
||||
|
||||
@ -563,8 +557,31 @@
|
||||
content: '开始搜索失败:' + err.msg
|
||||
});
|
||||
}
|
||||
}).finally(()=>{
|
||||
hideLoading(these);
|
||||
});
|
||||
});
|
||||
}, 500);
|
||||
|
||||
}
|
||||
|
||||
ble.StopSearch().finally(() => {
|
||||
|
||||
let disconnectPromises = [];
|
||||
if (ble.data && ble.data.LinkedList) {
|
||||
ble.data.LinkedList.forEach(device => {
|
||||
if (device.Linked) {
|
||||
disconnectPromises.push(ble.disconnectDevice(device.deviceId));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (disconnectPromises.length > 0) {
|
||||
Promise.allSettled(disconnectPromises).finally(() => {
|
||||
startSearch();
|
||||
});
|
||||
} else {
|
||||
startSearch();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@ -678,12 +695,11 @@
|
||||
console.log("客户端验证失败");
|
||||
deviceInvalid();
|
||||
return;
|
||||
}
|
||||
else if (f.macAddress == these.device.deviceMac){
|
||||
} else if (f.macAddress == these.device.deviceMac) {
|
||||
console.log("客户端验证成功");
|
||||
deviceOK();
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
} else {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user