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