修复670灯光问题
This commit is contained in:
@ -799,7 +799,7 @@
|
||||
return className;
|
||||
},
|
||||
handleRightClick: function(s, e) {
|
||||
|
||||
|
||||
if (s === 0) {
|
||||
console.log("消息");
|
||||
uni.navigateTo({
|
||||
@ -832,9 +832,8 @@
|
||||
},
|
||||
|
||||
initMQ() {
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
if (mqttClient) {
|
||||
// console.log("无需再次初始化")
|
||||
resolve();
|
||||
@ -953,7 +952,7 @@
|
||||
|
||||
if ("sta_LightGrade" in json) {
|
||||
|
||||
let lightingLevelText = json.sta_LightGrade === 1 ? 'hight' : json.sta_LightGrade === 2 ? 'low' :
|
||||
let lightingLevelText = json.sta_LightGrade === 1 ? 'qiang' : json.sta_LightGrade === 2 ? 'ruo' :
|
||||
'close';
|
||||
receiveData.lightCurr = lightingLevelText;
|
||||
}
|
||||
|
||||
@ -602,7 +602,7 @@
|
||||
}
|
||||
|
||||
console.log("f=", f);
|
||||
if (f.macAddress) {
|
||||
if (f && f.macAddress) {
|
||||
|
||||
|
||||
if (f.macAddress != these.device.deviceMac) {
|
||||
@ -650,7 +650,7 @@
|
||||
}
|
||||
return false;
|
||||
});
|
||||
if (!f.macAddress) {
|
||||
if (!(f && f.macAddress)) {
|
||||
removeLink();
|
||||
updateLoading(these, {
|
||||
text: "出现错误,未收到设备Mac地址"
|
||||
|
||||
@ -398,9 +398,25 @@
|
||||
// 处理新的扫码结果
|
||||
const cleanedResult = res.result.trim();
|
||||
console.log('扫码结果:', cleanedResult);
|
||||
let url=`/pages/common/qrcode/qrcode?deviceId=${encodeURIComponent(cleanedResult)}`;
|
||||
try{
|
||||
let json=JSON.parse(cleanedResult);
|
||||
if('imei' in json){
|
||||
url=`/pages/common/qrcode/qrcode?deviceId=${encodeURIComponent(json.imei)}`;
|
||||
}else if('blue' in json){
|
||||
if(!json.blue.includes(':')){
|
||||
json.blue=json.blue.replace(
|
||||
/(.{2})/g, '$1:')
|
||||
.slice(0, -1)
|
||||
}
|
||||
url=`/pages/common/addBLE/LinkBle?mac=${encodeURIComponent(json.blue)}`;
|
||||
}
|
||||
}catch(ex){
|
||||
|
||||
}
|
||||
// 跳转并传递扫描结果
|
||||
uni.navigateTo({
|
||||
url: `/pages/common/qrcode/qrcode?deviceId=${encodeURIComponent(cleanedResult)}`
|
||||
url: url
|
||||
});
|
||||
},
|
||||
fail: (err) => {
|
||||
@ -461,7 +477,7 @@
|
||||
// 关闭所有滑动项
|
||||
this.$refs.swipeAction.closeAll();
|
||||
|
||||
ble && ble.DropDevice(data.id);
|
||||
ble && ble.DropDevice(null,data.id);
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
@ -980,6 +996,8 @@
|
||||
margin-left: 15rpx;
|
||||
padding: 10rpx 0rpx;
|
||||
font-size: 28rpx;
|
||||
text-align: left;
|
||||
text-indent: 5rpx;
|
||||
}
|
||||
|
||||
.svg {
|
||||
|
||||
@ -145,7 +145,7 @@ class BleHelper {
|
||||
let item = this.data.LinkedList[i];
|
||||
if (deviceId && item.device) {
|
||||
if (item.device.id == deviceId) {
|
||||
console.log("找到要删除的设备", item);
|
||||
console.error("找到要删除的设备", item);
|
||||
this.data.LinkedList.splice(i, 1);
|
||||
this.disconnectDevice(item.deviceId);
|
||||
flag = true;
|
||||
@ -154,7 +154,7 @@ class BleHelper {
|
||||
|
||||
} else {
|
||||
if (bleId && item.deviceId == bleId) {
|
||||
console.log("找到要删除的设备1,", item)
|
||||
console.error("找到要删除的设备1,", item)
|
||||
this.data.LinkedList.splice(i, 1);
|
||||
this.disconnectDevice(item.deviceId);
|
||||
flag = true;
|
||||
@ -638,7 +638,7 @@ class BleHelper {
|
||||
}, 0);
|
||||
});
|
||||
|
||||
console.log("111111111")
|
||||
|
||||
uni.onBluetoothDeviceFound((res) => {
|
||||
//console.log("发现新设备:" + JSON.stringify(res,'name'));
|
||||
let arr = [];
|
||||
@ -816,7 +816,7 @@ class BleHelper {
|
||||
str: str,
|
||||
hexs: hexs
|
||||
};
|
||||
// console.log("监听到特征值:" + JSON.stringify(recData));
|
||||
console.log("监听到特征值:" + JSON.stringify(recData));
|
||||
if (this.cfg.receivDataCallback) {
|
||||
|
||||
if (this.cfg.receivDataCallback.length > 0) {
|
||||
|
||||
@ -256,7 +256,7 @@ class BleReceive {
|
||||
}
|
||||
|
||||
Receive_670(receive, f, path, recArr) {
|
||||
console.log("pagh=", path);
|
||||
// console.log("pagh=", path);
|
||||
var todo = (bytes) => {
|
||||
// console.log("todo",receive);
|
||||
let receiveData = {};
|
||||
@ -283,8 +283,8 @@ class BleReceive {
|
||||
// console.log("todo");
|
||||
// 解析照明档位
|
||||
let lightingLevelByte = bytes[2];
|
||||
let lightingLevelText = lightingLevelByte === 0x6d ? 'hight' : lightingLevelByte === 0x6e ?
|
||||
'low' : 'close';
|
||||
let lightingLevelText = lightingLevelByte === 0x6d ? 'qiang' : lightingLevelByte === 0x6e ?
|
||||
'ruo' : 'close';
|
||||
|
||||
// 解析剩余照明时间(第三和第四字节,小端序)
|
||||
let lightingTime = (bytes[3] << 8) | bytes[4];
|
||||
|
||||
@ -281,11 +281,15 @@ class MqttClient {
|
||||
}
|
||||
}
|
||||
|
||||
publish(topic, message) {
|
||||
publish(topic, message,retained) {
|
||||
if (this.client && this.client.isConnected()) {
|
||||
const mqttMessage = new Paho.Message(message);
|
||||
mqttMessage.destinationName = topic;
|
||||
mqttMessage.qos = 1;
|
||||
if(typeof(retained)==='boolean'){
|
||||
mqttMessage.retained=retained;
|
||||
}
|
||||
|
||||
this.client.send(mqttMessage);
|
||||
console.log(`成功发布消息到主题 ${topic}: ${message}`);
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user