合并代码
This commit is contained in:
@ -36,7 +36,7 @@ class BleHelper {
|
||||
linkedDevices = uni.getStorageSync(this.StorageKey);
|
||||
}
|
||||
if (linkedDevices && linkedDevices.length && linkedDevices.length > 0) {
|
||||
console.log("111111", linkedDevices);
|
||||
// console.log("111111", linkedDevices);
|
||||
linkedDevices = linkedDevices.filter((v) => {
|
||||
if (v) {
|
||||
v.Linked = false;
|
||||
@ -613,13 +613,13 @@ class BleHelper {
|
||||
if (this.data.isSubscribe) { //整个App生命周期,只订阅一次
|
||||
return;
|
||||
}
|
||||
console.error("开始订阅各类变化消息");
|
||||
// console.error("开始订阅各类变化消息");
|
||||
this.data.isSubscribe = true;
|
||||
this.BleStateChange(); //蓝牙适配器变化
|
||||
this.BleConnChange(); //蓝牙连接变化
|
||||
this.BleDeviceFound(); //发现新设备
|
||||
this.BleReceive(); //收到消息
|
||||
console.error("订阅各类变化消息完成");
|
||||
// console.error("订阅各类变化消息完成");
|
||||
},
|
||||
fail: (ex2) => {
|
||||
console.error("蓝牙模块启动失败", ex2);
|
||||
@ -962,7 +962,7 @@ class BleHelper {
|
||||
}
|
||||
|
||||
} else {
|
||||
console.log("蓝牙连接已恢复", res);
|
||||
// console.log("蓝牙连接已恢复", res);
|
||||
// 系统级连接恢复:更新 LinkedList 并通知业务层,避免 sendData 误判未连接而重复 createBLEConnection
|
||||
let f = this.data.LinkedList.find(v => v.deviceId == res.deviceId);
|
||||
if (f) {
|
||||
@ -1098,7 +1098,7 @@ class BleHelper {
|
||||
services: [],
|
||||
allowDuplicatesKey: true,
|
||||
success: (res) => {
|
||||
console.log('开始搜索蓝牙设备成功');
|
||||
// console.log('开始搜索蓝牙设备成功');
|
||||
resolve(res);
|
||||
|
||||
},
|
||||
@ -1237,11 +1237,11 @@ class BleHelper {
|
||||
characteristicId: characteristicId,
|
||||
state: state,
|
||||
success: (res) => {
|
||||
if (state) {
|
||||
console.log("订阅消息成功", res);
|
||||
} else {
|
||||
console.log("取消订阅成功", res);
|
||||
}
|
||||
// if (state) {
|
||||
// console.log("订阅消息成功", res);
|
||||
// } else {
|
||||
// console.log("取消订阅成功", res);
|
||||
// }
|
||||
|
||||
this.data.LinkedList.find((v) => {
|
||||
if (v.deviceId == deviceId) {
|
||||
@ -1311,13 +1311,13 @@ class BleHelper {
|
||||
|
||||
results.forEach((result, index) => {
|
||||
if (result.status === "fulfilled") {
|
||||
console.log(`订阅消息操作${index + 1}成功:`, result.value);
|
||||
// console.log(`订阅消息操作${index + 1}成功:`, result.value);
|
||||
} else {
|
||||
console.error(`订阅消息操作${index + 1}失败:`, result
|
||||
.reason);
|
||||
}
|
||||
});
|
||||
console.log("订阅消息完成,deviceId:", deviceId);
|
||||
// console.log("订阅消息完成,deviceId:", deviceId);
|
||||
resolve();
|
||||
}).catch((ex) => {
|
||||
console.error("异常,ex=", ex);
|
||||
|
||||
@ -14,8 +14,7 @@ class BleReceive {
|
||||
'/pages/100/HBY100': this.Receive_100.bind(this),
|
||||
'/pages/102/HBY102': this.Receive_102.bind(this),
|
||||
'/pages/6170/deviceControl/index':this.Receive_6170.bind(this),
|
||||
'/pages/100J/HBY100-J': this.Receive_100J.bind(this),
|
||||
'/pages/102/HBY102': this.Receive_102.bind(this)
|
||||
'/pages/100J/HBY100-J': this.Receive_100J.bind(this)
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user