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