1、优化配置应答处理
This commit is contained in:
parent
3cd8277586
commit
77cc7707ee
@ -3,7 +3,6 @@ package com.imdroid.secapi.dto;
|
|||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.imdroid.common.util.ByteUtil;
|
|
||||||
import com.imdroid.common.util.HexUtil;
|
import com.imdroid.common.util.HexUtil;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@ -103,10 +102,9 @@ public class GnssDevice {
|
|||||||
return cmdList;
|
return cmdList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean clearChangeFlag(String ack){
|
public boolean clearChangeFlag(byte[] ackBytes){
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
if(change_flag!=0) {
|
if(change_flag!=0) {
|
||||||
byte[] ackBytes = ByteUtil.hexStringTobyte(ack);
|
|
||||||
if(ackBytes[ackBytes.length-1] == 1) {
|
if(ackBytes[ackBytes.length-1] == 1) {
|
||||||
if (ackBytes[8] == 0x55) {
|
if (ackBytes[8] == 0x55) {
|
||||||
change_flag &= ~PARA_MASK_HAS_BATTERY;
|
change_flag &= ~PARA_MASK_HAS_BATTERY;
|
||||||
|
|||||||
@ -44,20 +44,24 @@ public class APIController extends BasicController {
|
|||||||
GnssDevice device = deviceMapper.queryByDeviceId(deviceId);
|
GnssDevice device = deviceMapper.queryByDeviceId(deviceId);
|
||||||
if (device == null) return null;
|
if (device == null) return null;
|
||||||
|
|
||||||
int msgType = Integer.parseInt(configAck.substring(0, 4), 16);
|
byte[] hexValues = ByteUtil.hexStringTobyte(configAck);
|
||||||
|
// d3 12 00 12 00 81 e7 6f
|
||||||
|
if(hexValues.length < 9) return null;
|
||||||
|
|
||||||
|
int msgType = ByteUtil.getUnsignedShort(hexValues[0],hexValues[1]);
|
||||||
|
byte code = hexValues[8];
|
||||||
// 配置是否成功
|
// 配置是否成功
|
||||||
if (msgType == 0xd311) {
|
if (msgType == 0xd311) {
|
||||||
//最后一个字节为1表示配置成功,0表示配置失败
|
//最后一个字节为1表示配置成功,0表示配置失败
|
||||||
if (configAck.endsWith("01")) {
|
if (hexValues[hexValues.length-1] == 1) {
|
||||||
device.setSyn(true);
|
device.setSyn(true);
|
||||||
deviceMapper.updateById(device);
|
deviceMapper.updateById(device);
|
||||||
}
|
}
|
||||||
} else if (msgType == 0xd312) {
|
} else if (msgType == 0xd312 || msgType == 0xd313) {
|
||||||
// 工作周期一致性检查
|
// 工作周期一致性检查
|
||||||
checkWorkCycle(device, configAck);
|
if(msgType == 0xd312 && code == 1) checkWorkCycle(device, hexValues);
|
||||||
} else if (msgType == 0xd313) {
|
else if((code&0xF0) == 0x50 && device.getChange_flag()!=0){
|
||||||
if(device.getChange_flag()!=0) {
|
if(device.clearChangeFlag(hexValues)){
|
||||||
if(device.clearChangeFlag(configAck)){
|
|
||||||
deviceMapper.updateById(device);
|
deviceMapper.updateById(device);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -90,10 +94,9 @@ public class APIController extends BasicController {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
void checkWorkCycle(GnssDevice device, String cfgData) {
|
void checkWorkCycle(GnssDevice device, byte[] hexValues) {
|
||||||
// d3 12 00 12 00 81 e7 6f 01 0a09000001c2dd7ae1419ee148
|
// d3 12 00 12 00 81 e7 6f 01 0a09000001c2dd7ae1419ee148
|
||||||
int pos = 9;
|
int pos = 9;
|
||||||
byte[] hexValues = ByteUtil.hexStringTobyte(cfgData);
|
|
||||||
byte workCycle = hexValues[pos++];
|
byte workCycle = hexValues[pos++];
|
||||||
byte workDur = hexValues[pos++];
|
byte workDur = hexValues[pos++];
|
||||||
byte workOffset = hexValues[pos++];
|
byte workOffset = hexValues[pos++];
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user