1
0
forked from dyf/APP

670完成

This commit is contained in:
liub
2025-08-26 15:42:26 +08:00
parent c9996748eb
commit dfb6f29683
22 changed files with 767 additions and 1046 deletions

View File

@ -362,6 +362,7 @@ class BleHelper {
success: (args) => {
console.log("蓝牙初始化成功:" + JSON.stringify(args));
this.data.isOpenBlue = true;
this.data.available=true;
resolve(true);
if (this.data.isSubscribe) { //整个App生命周期只订阅一次
@ -939,6 +940,10 @@ class BleHelper {
resolve(false);
return;
}
if(!this.data.available){
reject(this.getError({code:10001}));
return;
}
console.log("正在连接" + deviceId);
uni.createBLEConnection({
deviceId: deviceId,

View File

@ -257,25 +257,25 @@ class BleReceive {
try {
// 跳过帧头(第一个字节),从第二个字节开始解析
let staticLevelByte = bytes[1];
let staticLevelText = '未知';
let staticLevelText = '';
switch (staticLevelByte) {
case 0x65:
staticLevelText = '高档';
staticLevelText = 'hight';
break
case 0x66:
staticLevelText = '中档';
staticLevelText = 'center';
break
case 0x67:
staticLevelText = '低档';
staticLevelText = 'low';
break
case 0x68:
staticLevelText = '关闭';
staticLevelText = 'close';
break
}
// 解析照明档位
let lightingLevelByte = bytes[2];
let lightingLevelText = lightingLevelByte === 0x6d ? '强光': lightingLevelByte === 0x6e ? '弱光': '关闭';
let lightingLevelText = lightingLevelByte === 0x6d ? 'hight': lightingLevelByte === 0x6e ? 'low': 'close';
// 解析剩余照明时间(第三和第四字节,小端序)
let lightingTime = (bytes[3] << 8) | bytes[4];
@ -286,26 +286,26 @@ class BleReceive {
let batteryLevel = Math.max(0, Math.min(100, batteryLevelByte));
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 = '无预警';
// } else if (warn == 0x01) {
// warn = '弱预警';
// } else if (warn == 0x02) {
// warn = '中预警';
// } else if (warn == 0x03) {
// warn = '强预警';
// } else if (warn == 0x04) {
// warn = '非常强预警';
// }
let staticWarn = bytes[7] == 0x01 ? '静止报警': '无静止报警';
let staticWarn = bytes[7] == 0x01;//静止报警
let fourGStrenth = bytes[8]; //4g信号强度
let sosTxt = bytes[9] == 0x00 ? '关闭' : bytes[9] == 0x01 ? '爆闪模式' : '红蓝模式';
let sosTxt = bytes[9] == 0x00 ? '关闭' : bytes[9] == 0x01 ? 'sg' : 'rb';
receiveData.staticLevel = staticLevelText;
receiveData.lightingLevel = lightingLevelText;
receiveData.lightingTime = lightingTime ;
receiveData.batteryLevel = batteryLevel;
receiveData.modeCurr = staticLevelText;
receiveData.lightCurr = lightingLevelText;
receiveData.xuhang = lightingTime ;
receiveData.battary = batteryLevel;
receiveData.warnLevel = warn;
receiveData.staticWarn = staticWarn;
receiveData.fourGStrenth = fourGStrenth;