| | |
| | | import io.netty.buffer.Unpooled; |
| | | import lombok.Data; |
| | | |
| | | import java.io.UnsupportedEncodingException; |
| | | |
| | | /** |
| | | * 上报驾驶员身份信息请求 |
| | | * |
| | |
| | | */ |
| | | public byte[] encode() { |
| | | ByteBuf byteBuf = Unpooled.buffer(28); |
| | | byte[] bytes1 = this.getVehicleNo().getBytes(); |
| | | for (byte b : bytes1) { |
| | | byteBuf.writeByte(b); |
| | | byte[] bytes1 = new byte[0]; |
| | | try { |
| | | bytes1 = this.getVehicleNo().getBytes("GBK"); |
| | | } catch (UnsupportedEncodingException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | for (int i = 0; i < 21; i++) { |
| | | if (i < bytes1.length) { |
| | | byteBuf.writeByte(bytes1[i]); |
| | | } else { |
| | | byteBuf.writeByte(0x00); |
| | | } |
| | | } |
| | | byteBuf.writeByte(this.getVehicleColor()); |
| | | byteBuf.writeByte(this.getDataType()); |
| | | byteBuf.writeShort(this.getDataType()); |
| | | byteBuf.writeInt(this.getDataLength()); |
| | | byte[] bytes = ByteBufUtil.getBytes(byteBuf); |
| | | byteBuf.release(); |