fix: 工牌鉴权注册逻辑
All checks were successful
iot-test-platform CI/CD / build-and-deploy (push) Successful in 24s
All checks were successful
iot-test-platform CI/CD / build-and-deploy (push) Successful in 24s
This commit is contained in:
@@ -42,9 +42,9 @@ public class RegisterPack extends DataPack {
|
||||
private int cityId;
|
||||
// 制造商ID(BYTE[5]) 5 个字节,终端制造商编码
|
||||
private String manufacturerId;
|
||||
// 终端型号(BYTE[8]) 八个字节, 此终端型号 由制造商自行定义 位数不足八位的,补空格。
|
||||
// 终端型号(BYTE[20]) 20个字节,此终端型号由制造商自行定义,位数不足时,后补“0X00”。
|
||||
private String terminalType;
|
||||
// 终端ID(BYTE[7]) 七个字节, 由大写字母 和数字组成, 此终端 ID由制造 商自行定义
|
||||
// 终端ID(BYTE[7]) 7个字节,由大写字母和数字组成,此终端ID由制造商自行定义,位数不足时,后补“0X00”。
|
||||
private String terminalId;
|
||||
/**
|
||||
*
|
||||
|
||||
@@ -195,17 +195,17 @@ public class DataDecoder {
|
||||
// byte[] tmp = new byte[5];
|
||||
body.setManufacturerId(this.parseStringFromBytes(data, 4, 5));
|
||||
|
||||
// 4. byte[9-16] 终端型号(BYTE[8]) 八个字节, 此终端型号 由制造商自行定义 位数不足八位的,补空格。
|
||||
body.setTerminalType(this.parseStringFromBytes(data, 9, 8));
|
||||
// 4. byte[9-28] 终端型号(BYTE[20]) 20个字节,此终端型号由制造商自行定义,位数不足时,后补“0X00”。
|
||||
body.setTerminalType(this.parseStringFromBytes(data, 9, 20));
|
||||
|
||||
// 5. byte[17-23] 终端ID(BYTE[7]) 七个字节, 由大写字母 和数字组成, 此终端 ID由制造 商自行定义
|
||||
body.setTerminalId(this.parseStringFromBytes(data, 17, 7));
|
||||
// 5. byte[29-35] 终端ID(BYTE[7]) 7个字节,由大写字母和数字组成,此终端ID由制造商自行定义,位数不足时,后补“0X00”。
|
||||
body.setTerminalId(this.parseStringFromBytes(data, 29, 7));
|
||||
|
||||
// 6. byte[24] 车牌颜色(BYTE) 车牌颜 色按照JT/T415-2006 中5.4.12 的规定
|
||||
body.setLicensePlateColor(this.parseIntFromBytes(data, 24, 1));
|
||||
// 6. byte[36] 车牌颜色(BYTE) 车牌颜色,按照JT/T415-2006的5.4.12。未上牌时,取值为0。
|
||||
body.setLicensePlateColor(this.parseIntFromBytes(data, 36, 1));
|
||||
|
||||
// 7. byte[25-x] 车牌(STRING) 公安交 通管理部门颁 发的机动车号牌
|
||||
body.setLicensePlate(this.parseStringFromBytes(data, 25, data.length - 25));
|
||||
// 7. byte[37-x] 车辆标识(STRING) 车牌颜色为0时,表示车辆VIN;否则,表示公安交通管理部门颁发的机动车号牌。
|
||||
body.setLicensePlate(this.parseStringFromBytes(data, 37, data.length - 37));
|
||||
|
||||
ret.setTerminalRegInfo(body);
|
||||
return ret;
|
||||
|
||||
@@ -40,9 +40,9 @@ public class DataEncoder {
|
||||
Consts.CMD_TEXT_INFO_DOWN, msgBody, msgBodyProps, session.currentFlowId());
|
||||
byte[] headerAndBody = this.bitUtil.concatAll(msgHeader, msgBody);
|
||||
|
||||
// 校验码
|
||||
int checkSum = this.bitUtil.getCheckSum4JT808(headerAndBody, 0, headerAndBody.length - 1);
|
||||
return this.doEncode(headerAndBody, checkSum);
|
||||
// 校验码
|
||||
int checkSum = this.bitUtil.getCheckSum4JT808(headerAndBody, 0, headerAndBody.length);
|
||||
return this.doEncode(headerAndBody, checkSum);
|
||||
}
|
||||
|
||||
public byte[] encode4LocationInquiry(LocationInquiryPack req, Session session) throws Exception {
|
||||
@@ -55,7 +55,7 @@ public class DataEncoder {
|
||||
byte[] headerAndBody = this.bitUtil.concatAll(msgHeader, msgBody);
|
||||
|
||||
// 校验码
|
||||
int checkSum = this.bitUtil.getCheckSum4JT808(headerAndBody, 0, headerAndBody.length - 1);
|
||||
int checkSum = this.bitUtil.getCheckSum4JT808(headerAndBody, 0, headerAndBody.length);
|
||||
return this.doEncode(headerAndBody, checkSum);
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ public class DataEncoder {
|
||||
byte[] headerAndBody = this.bitUtil.concatAll(msgHeader, msgBody);
|
||||
|
||||
// 校验码
|
||||
int checkSum = this.bitUtil.getCheckSum4JT808(headerAndBody, 0, headerAndBody.length - 1);
|
||||
int checkSum = this.bitUtil.getCheckSum4JT808(headerAndBody, 0, headerAndBody.length);
|
||||
// 连接并且转义
|
||||
return this.doEncode(headerAndBody, checkSum);
|
||||
}
|
||||
@@ -105,7 +105,7 @@ public class DataEncoder {
|
||||
Consts.CMD_COMMON_RESP, msgBody, msgBodyProps, flowId);
|
||||
byte[] headerAndBody = this.bitUtil.concatAll(msgHeader, msgBody);
|
||||
// 校验码
|
||||
int checkSum = this.bitUtil.getCheckSum4JT808(headerAndBody, 0, headerAndBody.length - 1);
|
||||
int checkSum = this.bitUtil.getCheckSum4JT808(headerAndBody, 0, headerAndBody.length);
|
||||
// 连接并且转义
|
||||
return this.doEncode(headerAndBody, checkSum);
|
||||
}
|
||||
@@ -118,7 +118,7 @@ public class DataEncoder {
|
||||
// 连接消息头和消息体
|
||||
byte[] headerAndBody = this.bitUtil.concatAll(msgHeader, msgBodyBytes);
|
||||
// 校验码
|
||||
int checkSum = this.bitUtil.getCheckSum4JT808(headerAndBody, 0, headerAndBody.length - 1);
|
||||
int checkSum = this.bitUtil.getCheckSum4JT808(headerAndBody, 0, headerAndBody.length);
|
||||
// 连接并且转义
|
||||
return this.doEncode(headerAndBody, checkSum);
|
||||
}
|
||||
|
||||
@@ -44,9 +44,9 @@ public class RegisterHandler extends MessageHandler {
|
||||
RegisterBodyPack respMsgBody = new RegisterBodyPack();
|
||||
respMsgBody.setReplyCode(RegisterBodyPack.success);
|
||||
respMsgBody.setReplyFlowId(msg.getPackHead().getFlowId());
|
||||
// 使用手机号作为鉴权码
|
||||
respMsgBody.setReplyToken(msg.getPackHead().getTerminalPhone());
|
||||
|
||||
// TODO 鉴权码暂时写死
|
||||
respMsgBody.setReplyToken("123");
|
||||
int flowId = super.getFlowId(msg.getChannel());
|
||||
byte[] bs = this.msgEncoder.encode4TerminalRegisterResp(msg, respMsgBody, flowId);
|
||||
|
||||
@@ -57,4 +57,5 @@ public class RegisterHandler extends MessageHandler {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -111,6 +111,9 @@ public class JT808Util {
|
||||
if (bs[i] == 0x7e) {
|
||||
baos.write(0x7d);
|
||||
baos.write(0x02);
|
||||
} else if (bs[i] == 0x7d) {
|
||||
baos.write(0x7d);
|
||||
baos.write(0x01);
|
||||
} else {
|
||||
baos.write(bs[i]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user