package com.ard.tianyu.netty.command; import io.netty.buffer.ByteBuf; import lombok.Data; @Data public class SubscribeReplyCommand extends BaseCommand { //云盒SN号 private String BoxSn; public SubscribeReplyCommand(String BoxSn) { setDataHeader((short) 0x6A77); // 设置帧头 setDataLength((short) (6 + BoxSn.getBytes().length)); // 数据长度 setCmdCode((byte) 0x03); // 设置命令编号 this.BoxSn = BoxSn; } @Override public void encode(ByteBuf out) { out.writeShort(getDataHeader()); // 写入帧头 out.writeShort(getDataLength()); // 写入数据长度 out.writeByte(getCmdCode()); // 写入指令编号 out.writeBytes(BoxSn.getBytes()); // 写入云盒SN号 } }