7305添加文字发送、图片发送。蓝牙通用模块增加连接/断开订阅
This commit is contained in:
@ -430,86 +430,24 @@
|
||||
},
|
||||
bleValueNotify: function(receive, device, path) {
|
||||
|
||||
let str = recei.ReceiveData(receive, device, path);
|
||||
|
||||
console.log("处理接收到的数据:" + str);
|
||||
return;
|
||||
let data = recei.ReceiveData(receive, device, path);
|
||||
let bytes = receive.bytes;
|
||||
|
||||
if (bytes[0] == 0xFB && bytes[1] == 0x64 && bytes.length >= 8) {
|
||||
try {
|
||||
|
||||
let staticLevelByte = bytes[2];
|
||||
let getName = function(type) {
|
||||
let name = "";
|
||||
switch (type) {
|
||||
case 0x02:
|
||||
name = '弱光';
|
||||
break;
|
||||
case 0x04:
|
||||
name = '工作光';
|
||||
break;
|
||||
case 0x01:
|
||||
name = '强光';
|
||||
break;
|
||||
case 0x03:
|
||||
name = '爆闪';
|
||||
break;
|
||||
case 0x00:
|
||||
name = '关闭';
|
||||
break;
|
||||
}
|
||||
return name;
|
||||
}
|
||||
let staticLevelText = getName(staticLevelByte);
|
||||
|
||||
// 解析照明档位
|
||||
let lightingLevelByte = bytes[3];
|
||||
let lightingLevelText = getName(lightingLevelByte);
|
||||
|
||||
|
||||
// 解析剩余电量
|
||||
let batteryLevelByte = bytes[4];
|
||||
// 电量百分比范围检查
|
||||
let batteryLevel = Math.max(0, Math.min(100, batteryLevelByte));
|
||||
|
||||
|
||||
|
||||
|
||||
//充电状态
|
||||
let warn = bytes[5];
|
||||
if (warn == 0x00) {
|
||||
warn = '未充电';
|
||||
} else if (warn == 0x01) {
|
||||
warn = '充电中';
|
||||
}
|
||||
|
||||
// 解析剩余照明时间(第三和第四字节,小端序)
|
||||
let lightingTime = "";
|
||||
let HH = Math.max(0, Math.min(100, bytes[6]));
|
||||
let mm = Math.max(0, Math.min(100, bytes[7]));
|
||||
lightingTime = HH + "小时" + mm + "分钟";
|
||||
|
||||
this.formData.mode = staticLevelText;
|
||||
this.formData.fuMode = lightingLevelText;
|
||||
this.formData.battary = batteryLevel;
|
||||
this.formData.statu = warn;
|
||||
this.formData.xuhang = lightingTime;
|
||||
|
||||
if (batteryLevel <= 20) {
|
||||
this.showPop({
|
||||
message: "设备电量低",
|
||||
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
});
|
||||
}
|
||||
|
||||
this.setBleFormData();
|
||||
} catch (error) {
|
||||
console.log('数据解析错误:', error);
|
||||
}
|
||||
let json = recei.ReceiveData(receive, device, path);
|
||||
if(!json){
|
||||
return;
|
||||
}
|
||||
let keys=Object.keys(json);
|
||||
keys.forEach((key)=>{
|
||||
if(key in these.formData){
|
||||
these.formData[key] = json[key];
|
||||
}
|
||||
});
|
||||
|
||||
if (this.formData.battary <= 20) {
|
||||
this.showPop({
|
||||
message: "设备电量低",
|
||||
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
});
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user