liusuyi
2024-10-23 2b43275bd260eda468f305ebca4b4f4291b0605d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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号
    }
}