18045010223
2025-07-07 0d3a683a0c97154b1f2e6657398664537e4e3e82
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
27
28
package org.yzh.protocol.t808.T8900Lock;
 
import io.github.yezhihao.protostar.annotation.Field;
import lombok.Data;
 
@Data
public class T8900ReadDeviceID {
 
    @Field(index = 0, length = 2, desc = "读锁ID命令")
    private byte[] lockId = {(byte) 0xFF, (byte) 0xFF};
 
    @Field(index = 2, length = 1, desc = "命令类型")
    private byte commandType = 0x09;
 
    @Field(index = 3, length = 1, desc = "校验码")
    private byte checksum;
 
    /**
     * 计算校验和:(aa + aa + 02 + cc) & 0xFF
     */
    public byte calculateChecksum() {
        int sum = lockId[0] & 0xFF;
        sum += lockId[1] & 0xFF;
        sum += commandType & 0xFF;
        this.checksum = (byte) (sum & 0xFF);
        return this.checksum;// (byte) (sum & 0xFF); // 取低8位
    }
}