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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package org.yzh.protocol.t808.T8900Lock;
 
import io.github.yezhihao.protostar.annotation.Field;
import lombok.Data;
 
/**
 * 设置离线开锁密码
 */
@Data
public class T8900SetPassword {
    @Field(index = 0, length = 2, desc = "读锁ID命令")
    private byte[] lockId;
    @Field(index = 1, length = 1, desc = "命令类型")
    private byte commandType = 0x04;
    @Field(index = 2, length = 6, desc = "密码1")
    private byte[] password1;
    @Field(index = 3, length = 6, desc = "密码2")
    private byte[] password2;
    @Field(index = 4, length = 6, desc = "密码3")
    private byte[] password3;
    @Field(index = 5, length = 6, desc = "密码4")
    private byte[] password4;
    @Field(index = 6, length = 6, desc = "密码5")
    private byte[] password5;
    @Field(index = 7, length = 6, desc = "密码6")
    private byte[] password6;
    @Field(index = 8, length = 6, desc = "密码7")
    private byte[] password7;
    @Field(index = 9, length = 6, desc = "密码8")
    private byte[] password8;
    @Field(index = 10, length = 6, desc = "密码9")
    private byte[] password9;
    @Field(index = 11, length = 6, desc = "密码10")
    private byte[] password10;
    @Field(index = 12, length = 1, desc = "校验码")
    private byte checksum;
 
    /**
     * 和校验码计算(取低8位)
     * @param data 要校验的数据
     * @return 校验码
     * */
    public byte calculateSUMChecksum(byte[] data) {
        int sum = 0;
        for (byte b : data) {
            sum += b & 0xFF; // 转换为无符号整数
        }
        return (byte) (sum & 0xFF); // 取低8位
    }
 
}