|
@@ -5,25 +5,24 @@ import io.netty.channel.Channel;
|
|
|
import lombok.Getter;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
-import java.nio.ByteBuffer;
|
|
|
-import java.nio.ByteOrder;
|
|
|
-
|
|
|
@Slf4j
|
|
|
@Getter
|
|
|
public class SigFramePacket {
|
|
|
protected final long recvTime;
|
|
|
protected final Channel channel;
|
|
|
- private byte[] packets;
|
|
|
- private int msgLen;
|
|
|
-
|
|
|
- private byte stx;
|
|
|
- private byte opCode;
|
|
|
- private short year, month, day, hour, min, sec;
|
|
|
- private int sequence;
|
|
|
- private int regionId;
|
|
|
- private int dataLength;
|
|
|
- private int count;
|
|
|
- private ByteBuffer data;
|
|
|
+ private final int msgLen;
|
|
|
+
|
|
|
+ private final byte stx;
|
|
|
+ private final byte opCode;
|
|
|
+ private final String commDate;
|
|
|
+ private final short year, month, day, hour, min, sec;
|
|
|
+ private final int sequence;
|
|
|
+ private final int regionId;
|
|
|
+ private final int dataLength;
|
|
|
+ private final int count;
|
|
|
+
|
|
|
+ private final byte chkSum;
|
|
|
+ private final byte etx;
|
|
|
// pr
|
|
|
// STX - 1 byte
|
|
|
// OpCode - 1 byte
|
|
@@ -40,21 +39,45 @@ public class SigFramePacket {
|
|
|
this.channel = channel;
|
|
|
this.msgLen = byteBuf.readableBytes();
|
|
|
|
|
|
- this.stx = byteBuf.getByte(0);
|
|
|
- this.opCode = byteBuf.getByte(1);
|
|
|
- this.year = byteBuf.getUnsignedByte(2);
|
|
|
- this.month = byteBuf.getUnsignedByte(3);
|
|
|
- this.day = byteBuf.getUnsignedByte(4);
|
|
|
- this.hour = byteBuf.getUnsignedByte(5);
|
|
|
- this.min = byteBuf.getUnsignedByte(6);
|
|
|
- this.sec = byteBuf.getUnsignedByte(7);
|
|
|
- this.sequence = byteBuf.getUnsignedShort(8);
|
|
|
- this.regionId = byteBuf.getUnsignedShort(10);
|
|
|
- this.dataLength = byteBuf.getUnsignedShort(12);
|
|
|
- this.count = byteBuf.getUnsignedShort(14);
|
|
|
- ByteBuf body = byteBuf.readBytes(16);
|
|
|
- log.
|
|
|
- this.data = ByteBuffer.allocate(dataLength);
|
|
|
- this.data.order(ByteOrder.BIG_ENDIAN);
|
|
|
+ log.error("ReadableBytes: {} Bytes.", byteBuf.readableBytes());
|
|
|
+ log.error("readerIndex: {}", byteBuf.readerIndex());
|
|
|
+ log.error("writerIndex: {}", byteBuf.writerIndex());
|
|
|
+
|
|
|
+ this.stx = byteBuf.readByte();
|
|
|
+ this.opCode = byteBuf.readByte();
|
|
|
+ this.year = byteBuf.readUnsignedByte();
|
|
|
+ this.month = byteBuf.readUnsignedByte();
|
|
|
+ this.day = byteBuf.readUnsignedByte();
|
|
|
+ this.hour = byteBuf.readUnsignedByte();
|
|
|
+ this.min = byteBuf.readUnsignedByte();
|
|
|
+ this.sec = byteBuf.readUnsignedByte();
|
|
|
+ this.commDate = String.format("%4d%02d%02d%02d%02d%02d", this.year+2000, this.month, this.day, this.hour, this.min, this.sec);
|
|
|
+ this.sequence = byteBuf.readUnsignedShort();
|
|
|
+ this.regionId = byteBuf.readUnsignedShort();
|
|
|
+ this.dataLength = byteBuf.readUnsignedShort();
|
|
|
+ this.count = byteBuf.readUnsignedShort();
|
|
|
+
|
|
|
+ log.error("{}/{}/{} {}:{}:{}", this.year+2000, this.month, this.day, this.hour, this.min, this.sec);
|
|
|
+ log.error("{}", this.commDate);
|
|
|
+ log.error("Sequence: {}, RegionId: {}, DataLength: {}, Count: {}", this.sequence, this.regionId, this.dataLength, this.count);
|
|
|
+
|
|
|
+ // SIG_LOGIN
|
|
|
+ if (this.dataLength != 32 + 32 + 32) {
|
|
|
+ log.error("SIG_LOGIN Data Received. But Data Length Error: Required {} Bytes, Received {} Bytes.", 64, this.dataLength);
|
|
|
+ }
|
|
|
+ byte[] loginIdArr = new byte[32];
|
|
|
+ byteBuf.readBytes(loginIdArr);
|
|
|
+ byte[] loginPswdArr = new byte[32];
|
|
|
+ byteBuf.readBytes(loginPswdArr);
|
|
|
+ byte[] loginCdArr = new byte[32];
|
|
|
+ byteBuf.readBytes(loginCdArr);
|
|
|
+ String loginId = new String(loginIdArr);
|
|
|
+ String loginPswd = new String(loginPswdArr);
|
|
|
+ String loginCd = new String(loginCdArr);
|
|
|
+
|
|
|
+ this.chkSum = byteBuf.readByte();
|
|
|
+ this.etx = byteBuf.readByte();
|
|
|
+
|
|
|
+ log.error("{}, {}, {}", loginId, loginPswd, loginCd);
|
|
|
}
|
|
|
}
|