Merge branch 'new-20250827' of http://47.107.152.87:3000/liubiao/APP into new-20250827
This commit is contained in:
@ -630,20 +630,38 @@ class BleHelper {
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
if (this.data.isOpenBlue) {
|
||||
const runInit = () => {
|
||||
this.CheckBlue().then((res) => {
|
||||
return init();
|
||||
}).then(resolve).catch((ex) => {
|
||||
console.error("异常:", ex);
|
||||
reject(ex);
|
||||
});
|
||||
};
|
||||
if (!this.data.isOpenBlue) {
|
||||
runInit();
|
||||
return;
|
||||
}
|
||||
// 已打开过仍须向系统确认可用:关蓝牙再开后 isOpenBlue 可能未及时被置 false,或状态回调未送达
|
||||
if (typeof uni.getBluetoothAdapterState !== 'function') {
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
this.CheckBlue().then((res) => {
|
||||
// console.log("res=", res)
|
||||
return init();
|
||||
}).then(resolve).catch((ex) => {
|
||||
console.error("异常:", ex);
|
||||
reject(ex);
|
||||
uni.getBluetoothAdapterState({
|
||||
success: (info) => {
|
||||
this.data.available = !!info.available;
|
||||
if (info.available) {
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
this.data.isOpenBlue = false;
|
||||
runInit();
|
||||
},
|
||||
fail: () => {
|
||||
this.data.isOpenBlue = false;
|
||||
runInit();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@ -865,6 +883,9 @@ class BleHelper {
|
||||
|
||||
|
||||
if (!state.available) { //蓝牙状态不可用了,将所有设备标记为断开连接
|
||||
// 系统关蓝牙后原生 BLE 适配器已销毁;若仍认为 isOpenBlue=true,OpenBlue 会跳过重开,
|
||||
// 再开蓝牙后无法 createBLEConnection / 一直报 10001 适配器不可用
|
||||
this.data.isOpenBlue = false;
|
||||
console.log("蓝牙模块不可用了,将所有设备标记为断开连接");
|
||||
this.data.connectingDevices = {}; //清空连接锁
|
||||
this.data.LinkedList.filter((v) => {
|
||||
|
||||
Reference in New Issue
Block a user