java交通809协议登录,gps定位发送,使用大端字节传输
数据结构类
Message.java
import io.netty.buffer.ByteBuf;
import java.io.Serializable;
import java.util.Arrays;
public class Message implements Serializable {
private static final long serialVersionUID = 4398559115325723920L;
public static final int MSG_HEAD = 0x5b;
public static final int MSG_TALL = 0x5d;
//报文中除数据体外,固定的数据长度
public static final int MSG_FIX_LENGTH = 26;
private static int internalMsgNo = 0;
private long msgLength;
private long encryptFlag = 1;
private int msgGesscenterId;
private long encryptKey;
private int crcCode;
private int msgId;
private int msgSn;
private ByteBuf msgBody;
private byte[] versionFlag = {0, 0, 1};
//下行报文标识,值为1时,代表发送的数据;默认为0,代表接收的报文
// private int downFlag = 0;
public Message2() {
}
public Message2(int msgId, Integer internalMsgNo) {
//下行报文需要填充报文序列号
this.msgSn = internalMsgNo;
this.msgId = msgId;
}
public static int getInternalMsgNo() {
return internalMsgNo;
}
public static void setInternalMsgNo(int internalMsgNo) {
Message2.internalMsgNo = internalMsgNo;
}
public long getMsgLength() {
return msgLength;
}
public void setMsgLength(long msgLength) {
this.msgLength = msgLength;
}
public long getEncryptFlag() {
return encryptFlag;
}
public void setEncryptFlag(long encryptFlag) {
this.encryptFlag = encryptFlag;
}
public int getMsgGesscenterId() {
return msgGesscenterId;
}
public void setMsgGesscenterId(int msgGesscenterId) {
this.msgGesscenterId = msgGesscenterId;
}
public void setMsgGesscenterId(long msgGesscenterId) {
this.msgGesscenterId = (int) msgGesscenterId;
}
public long getEncryptKey() {
return encryptKey;
}
public void setEncryptKey(long encryptKey) {
this.encryptKey = encryptKey;
}
public int getCrcCode() {
return crcCode;
}
public void setCrcCode(int crcCode) {
this.crcCode = crcCode;
}
public int getMsgId() {
return msgId;
}
public void setMsgId(int msgId) {
this.msgId = msgId;
}
public int getMsgSn() {
return msgSn;
}
public void setMsgSn(int msgSn) {
this.msgSn = msgSn;
}
public ByteBuf getMsgBody() {
return msgBody;
}
public void setMsgBody(ByteBuf msgBody) {
this.msgBody = msgBody;
}
public byte[] getVersionFlag(