| | |
| | | package com.ruoyi.dataInterchange.util.jtt809.decoder; |
| | | |
| | | import com.ruoyi.dataInterchange.util.jtt809.common.ByteArrayUtil; |
| | | import com.ruoyi.dataInterchange.util.jtt809.common.Jtt809Constant; |
| | | import com.ruoyi.dataInterchange.util.jtt809.common.Jtt809Util; |
| | | import com.ruoyi.dataInterchange.util.jtt809.gnsscenter.GnssCenterService; |
| | |
| | | } |
| | | byte[] readableBytes = new byte[msg.readableBytes()]; |
| | | msg.readBytes(readableBytes); |
| | | log.info("接收到数据包, packetLen : {}, packet : {}", readableBytes.length, ByteArrayUtil.bytes2HexStr(readableBytes)); |
| | | // log.info("接收到数据包, packetLen : {}, packet : {}", readableBytes.length, ByteArrayUtil.bytes2HexStr(readableBytes)); |
| | | // 反转义处理 |
| | | byte[] bytes = Jtt809Util.unescape(readableBytes); |
| | | ByteBuf byteBuf = Unpooled.wrappedBuffer(bytes); |
| | | log.info("反转义后数据包, packetLen : {}, packet : {}", bytes.length, ByteArrayUtil.bytes2HexStr(bytes)); |
| | | // log.info("反转义后数据包, packetLen : {}, packet : {}", bytes.length, ByteArrayUtil.bytes2HexStr(bytes)); |
| | | // 判断包头 |
| | | if (byteBuf.readByte() != Jtt809Constant.PACKET_HEAD_FLAG) { |
| | | byteBuf.resetReaderIndex(); |
| | |
| | | int id = byteBuf.readUnsignedShort(); |
| | | // 下级平台接入码 |
| | | int gnsscenterId = byteBuf.readInt(); |
| | | ctx.channel().attr(Jtt809Constant.NettyAttribute.GNSS_CENTER_ID).setIfAbsent(String.valueOf(gnsscenterId)); |
| | | // 协议版本号标识 |
| | | String version = "v" + byteBuf.readByte() + "." + byteBuf.readByte() + "." + byteBuf.readByte(); |
| | | // 报文加密标识位 |