蓝牙小优化,App隐藏时断开设备连接
This commit is contained in:
@ -11,7 +11,8 @@ class BleReceive {
|
||||
'/pages/670/HBY670': this.Receive_670.bind(this),
|
||||
'/pages/4877/BJQ4877': this.Receive_4877.bind(this),
|
||||
'/pages/100/HBY100': this.Receive_100.bind(this),
|
||||
'/pages/102/HBY102': this.Receive_102.bind(this)
|
||||
'/pages/102/HBY102': this.Receive_102.bind(this),
|
||||
'/pages/6170/deviceControl/index':this.Receive_6170.bind(this)
|
||||
};
|
||||
}
|
||||
|
||||
@ -671,6 +672,43 @@ class BleReceive {
|
||||
}
|
||||
|
||||
|
||||
Receive_6170(receive, f, path, recArr) {
|
||||
let receiveData = {};
|
||||
|
||||
try {
|
||||
console.log("订阅消息者:", path);
|
||||
console.log("设备收到消息:", f);
|
||||
console.log("消息内容:", receive);
|
||||
receiveData = JSON.parse(receive.str);
|
||||
|
||||
let recCnt = recArr.find(v => {
|
||||
return v.key.replace(/\//g, "").toLowerCase() == f.device.detailPageUrl
|
||||
.replace(/\//g, "").toLowerCase();
|
||||
});
|
||||
if (!recCnt) {
|
||||
if (receiveData.sta_PowerPercent <= 20) {
|
||||
uni.showModal({
|
||||
title: "提示",
|
||||
content: "设备'" + f.device.deviceName + "'电量低",
|
||||
showCancel: false
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} catch (error) {
|
||||
receiveData = {};
|
||||
console.error("文本解析失败", error)
|
||||
}
|
||||
return receiveData;
|
||||
|
||||
}
|
||||
|
||||
Receive_102(receive, f, path, recArr) {
|
||||
let receiveData = {};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user