增加蓝牙设备人员信息登记上传
This commit is contained in:
@ -45,25 +45,27 @@ class BleReceive {
|
||||
|
||||
|
||||
ReceiveData(receive,f,path) {
|
||||
if(f && f.macAddress && f.id){
|
||||
if(f && f.macAddress && f.device && f.device.id){
|
||||
let data={};
|
||||
if(f.detailPageUrl=='/pages/6155/deviceDetail'){
|
||||
if(f.device.detailPageUrl=='/pages/6155/deviceDetail'){
|
||||
// console.log("该设备是6155");
|
||||
data= this.Receive_6155(receive,f,path);
|
||||
}
|
||||
|
||||
if(f.detailPageUrl=='/pages/650/HBY650'){
|
||||
if(f.device.detailPageUrl=='/pages/650/HBY650'){
|
||||
// console.log("该设备是650");
|
||||
data= this.Receive_650(receive,f,path);
|
||||
}
|
||||
if(f.detailPageUrl=='/pages/670/HBY670'){
|
||||
if(f.device.detailPageUrl=='/pages/670/HBY670'){
|
||||
// console.log("该设备是670");
|
||||
data= this.Receive_670(receive,f,path);
|
||||
}
|
||||
// console.log("收到数据并处理完毕,",data);
|
||||
return data;
|
||||
}else{
|
||||
console.log("已收到该消息,但无法处理",receive);
|
||||
}
|
||||
// console.log("已收到该消息,但无法处理",receive);
|
||||
|
||||
return receive;
|
||||
|
||||
}
|
||||
@ -392,8 +394,81 @@ class BleReceive {
|
||||
|
||||
return data;
|
||||
}
|
||||
Receive_6155() {
|
||||
console.log("通用程序正在处理6155的数据");
|
||||
Receive_6155(receive,f,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 + "分钟";
|
||||
let formData={};
|
||||
formData.mode = staticLevelText;
|
||||
formData.fuMode = lightingLevelText;
|
||||
formData.battary = batteryLevel;
|
||||
formData.statu = warn;
|
||||
formData.xuhang = lightingTime;
|
||||
|
||||
if (batteryLevel <= 20) {
|
||||
uni.showModal({
|
||||
content:"设备电量低",
|
||||
title:"提示"
|
||||
});
|
||||
|
||||
}
|
||||
this.setBleFormData(formData,f);
|
||||
return formData;
|
||||
} catch (error) {
|
||||
console.log('数据解析错误:', error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user