1
0
forked from dyf/APP

修复670灯光问题

This commit is contained in:
liub
2025-12-03 10:20:11 +08:00
parent cd6d529523
commit e2d07e984f
6 changed files with 38 additions and 17 deletions

View File

@ -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) {

View File

@ -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];

View File

@ -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;