添加报警功能

This commit is contained in:
liub
2025-08-28 14:05:06 +08:00
parent c2aa8bfa2f
commit 9846fe2315
18 changed files with 1212 additions and 444 deletions

View File

@ -48,22 +48,23 @@ class BleReceive {
if(f && f.macAddress && f.id){
let data={};
if(f.detailPageUrl=='/pages/6155/deviceDetail'){
console.log("该设备是6155");
// console.log("该设备是6155");
data= this.Receive_6155(receive,f,path);
}
if(f.detailPageUrl=='/pages/650/HBY650'){
console.log("该设备是650");
// console.log("该设备是650");
data= this.Receive_650(receive,f,path);
}
if(f.detailPageUrl=='/pages/670/HBY670'){
console.log("该设备是670");
// console.log("该设备是670");
data= this.Receive_670(receive,f,path);
}
console.log("收到数据并处理完毕,",data);
// console.log("收到数据并处理完毕,",data);
return data;
}
console.log("已收到该消息,但无法处理",f);
// console.log("已收到该消息,但无法处理",receive);
return receive;
}
@ -253,11 +254,11 @@ class BleReceive {
Receive_670(receive,f,path){
var todo = (bytes) =>{
console.log("todo");
// console.log("todo",receive);
let receiveData = {};
if (bytes[0] == 0x55) {
try {
console.log("todo");
// console.log("todo");
// 跳过帧头(第一个字节),从第二个字节开始解析
let staticLevelByte = bytes[1];
let staticLevelText = '';
@ -275,7 +276,7 @@ class BleReceive {
staticLevelText = 'close';
break
}
console.log("todo");
// console.log("todo");
// 解析照明档位
let lightingLevelByte = bytes[2];
let lightingLevelText = lightingLevelByte === 0x6d ? 'hight': lightingLevelByte === 0x6e ? 'low': 'close';
@ -287,7 +288,7 @@ class BleReceive {
let batteryLevelByte = bytes[5];
let batteryLevel = Math.max(0, Math.min(100, batteryLevelByte));
console.log("todo");
// console.log("todo");
let warn = bytes[6];
if (warn == 0x00) {
warn = 'none';
@ -304,7 +305,7 @@ class BleReceive {
let staticWarn = bytes[7] == 0x01;//静止报警
let fourGStrenth = bytes[8]; //4g信号强度
let sosTxt = bytes[9] == 0x00 ? 'close' : bytes[9] == 0x01 ? 'sg' : 'rb';
console.log("todo");
// console.log("todo");
receiveData.modeCurr = staticLevelText;
receiveData.lightCurr = lightingLevelText;
receiveData.xuhang = lightingTime ;
@ -316,7 +317,7 @@ class BleReceive {
} catch(error) {
console.log('数据解析错误:', error);
}
console.log("todo");
// console.log("todo");
} else {
try {
let uint8Array = new Uint8Array(receive.value);
@ -340,6 +341,7 @@ class BleReceive {
console.log('收到纬度:', +this.receiveData.macAddress);
} else {
try {
// console.log("str=",str);
let json=JSON.parse(str);
if("staBlue_picture" in json){
//重发图片
@ -372,7 +374,7 @@ class BleReceive {
} catch (error) {
receiveData={};
console.log("文本解析失败")
// console.log("文本解析失败",error)
}
}
} catch(ex) {
@ -380,7 +382,7 @@ class BleReceive {
console.log('将数据转文本失败', ex);
}
}
console.log("todo",receiveData);
// console.log("todo",receiveData);
this.setBleFormData(receiveData,f);
return receiveData;
}