2021与蓝度共同重构项目,服务端
Van333
2022-12-29 727a69f859060093e685582fa10e5de82dcc138a
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
package com.sandu.ximon.admin.manager.iot.frame.inner.report;
 
import com.sandu.common.execption.BusinessException;
import com.sandu.ximon.admin.manager.iot.frame.inner.BaseResponseInnerFrame;
import com.sandu.ximon.admin.manager.iot.rrpc.util.CRC32Utils;
import lombok.Data;
 
/**
 * @author ZZQ
 * @date 2022/5/7 15:16
 */
@Data
public class RemoteStopUpdateReportInnerFrame extends BaseResponseInnerFrame<RemoteStopUpdateReportInnerFrame> {
    private boolean responseState;
 
    @Override
    public RemoteStopUpdateReportInnerFrame transformFrame(String hex) {
        if (hex.length() != 18) {
            throw new BusinessException("响应帧出错,请重新发送指令!");
        }
        // MQTT通信方式(1)
        setConnectType(hex.substring(0, 2));
        //  功能码(1)
        setFunctionCode(hex.substring(2, 4));
        //  负荷长度(2)
        setPayloadLength(hex.substring(4, 8));
        //校验状态
        if ("01".equals(hex.substring(8, 10))) {
            setResponseState(true);
        } else {
            setResponseState(false);
        }
 
        setCrc32(hex.substring(hex.length() - 8));
        //  校验CRC32
        String frame = hex.substring(2, hex.length() - 8);
        this.setValidate(CRC32Utils.validateFrame(frame, getCrc32()));
        return this;
    }
}