1
0
forked from dyf/APP

670完成

This commit is contained in:
liub
2025-08-27 09:08:59 +08:00
parent dfb6f29683
commit cd912b861e
9 changed files with 369 additions and 143 deletions

View File

@ -45,21 +45,23 @@ class BleReceive {
ReceiveData(receive,f,path) {
if(f && f.macAddress && f.id){
if(f && f.macAddress && f.id){
let data={};
if(f.detailPageUrl=='/pages/6155/deviceDetail'){
console.log("该设备是6155");
return this.Receive_6155(receive,f,path);
data= this.Receive_6155(receive,f,path);
}
if(f.detailPageUrl=='/pages/650/HBY650'){
console.log("该设备是650");
return this.Receive_650(receive,f,path);
data= this.Receive_650(receive,f,path);
}
if(f.detailPageUrl=='/pages/670/HBY670'){
console.log("该设备是670");
return this.Receive_670(receive,f,path);
data= this.Receive_670(receive,f,path);
}
console.log("收到数据并处理完毕,",data);
return data;
}
console.log("已收到该消息,但无法处理",f);
@ -242,7 +244,7 @@ class BleReceive {
}
let data=parseData();
let data=parseData(receive.bytes);
console.log("data=",data);
return data;
@ -251,10 +253,11 @@ class BleReceive {
Receive_670(receive,f,path){
var todo = (bytes) =>{
console.log("todo");
let receiveData = {};
if (bytes[0] == 0x55) {
try {
console.log("todo");
// 跳过帧头(第一个字节),从第二个字节开始解析
let staticLevelByte = bytes[1];
let staticLevelText = '';
@ -272,7 +275,7 @@ class BleReceive {
staticLevelText = 'close';
break
}
console.log("todo");
// 解析照明档位
let lightingLevelByte = bytes[2];
let lightingLevelText = lightingLevelByte === 0x6d ? 'hight': lightingLevelByte === 0x6e ? 'low': 'close';
@ -284,24 +287,24 @@ class BleReceive {
let batteryLevelByte = bytes[5];
let batteryLevel = Math.max(0, Math.min(100, batteryLevelByte));
console.log("todo");
let warn = bytes[6];
// if (warn == 0x00) {
// warn = '无预警';
// } else if (warn == 0x01) {
// warn = '弱预警';
// } else if (warn == 0x02) {
// warn = '中预警';
// } else if (warn == 0x03) {
// warn = '强预警';
// } else if (warn == 0x04) {
// warn = '非常强预警';
// }
if (warn == 0x00) {
warn = 'none';
} else if (warn == 0x01) {
warn = 'ruo';
} else if (warn == 0x02) {
warn = 'center';
} else if (warn == 0x03) {
warn = 'hight';
} else if (warn == 0x04) {
warn = 'veryhight';
}
let staticWarn = bytes[7] == 0x01;//静止报警
let fourGStrenth = bytes[8]; //4g信号强度
let sosTxt = bytes[9] == 0x00 ? '关闭' : bytes[9] == 0x01 ? 'sg' : 'rb';
let sosTxt = bytes[9] == 0x00 ? 'close' : bytes[9] == 0x01 ? 'sg' : 'rb';
console.log("todo");
receiveData.modeCurr = staticLevelText;
receiveData.lightCurr = lightingLevelText;
receiveData.xuhang = lightingTime ;
@ -313,6 +316,7 @@ class BleReceive {
} catch(error) {
console.log('数据解析错误:', error);
}
console.log("todo");
} else {
try {
let uint8Array = new Uint8Array(receive.value);
@ -325,7 +329,7 @@ class BleReceive {
receiveData.macAddress = str.split(':').slice(1).join(":");
console.log('收到mac地址:', +this.receiveData.macAddress);
} else if (str.indexOf('imei:') == 0) {
receiveData.IMEI = str.split(':')[1];
receiveData.imei = str.split(':')[1];
console.log('收到IEMI:', +this.receiveData.macAddress);
} else if (str.indexOf('longitude:') == 0) {
@ -376,13 +380,13 @@ class BleReceive {
console.log('将数据转文本失败', ex);
}
}
console.log("todo",receiveData);
this.setBleFormData(receiveData,f);
return receiveData;
}
let data=todo();
let data=todo(receive.bytes);
return data;
}