2021与蓝度共同重构项目,服务端
liuhaonan
2022-08-12 798400ebc4769a6afec56ebbf8198e87e6c1a683
ximon-admin/src/main/java/com/sandu/ximon/admin/manager/iot/frame/inner/report/A5LightErrorCodeReportInnerFrame.java
@@ -1,5 +1,6 @@
package com.sandu.ximon.admin.manager.iot.frame.inner.report;
import cn.hutool.core.util.HexUtil;
import cn.hutool.core.util.StrUtil;
import com.sandu.ximon.admin.manager.iot.frame.inner.BaseResponseInnerFrame;
import com.sandu.ximon.admin.manager.iot.rrpc.util.CRC32Utils;
@@ -23,12 +24,14 @@
    /**
     * 故障码
     */
    private String errorCode;
    private int errorCode;
    @Override
    public A5LightErrorCodeReportInnerFrame transformFrame(String hex) {
        if (StrUtil.isBlank(hex)) {
        if (StrUtil.isBlank(hex) || hex.length() != 24) {
            System.out.println("hex is blank or length is not 24");
            return null;
        }
        // MQTT通信方式(1)
        setConnectType(hex.substring(0, 2));
@@ -39,10 +42,13 @@
        setDestinationAddress(hex.substring(8, 12));
        setErrorCode(hex.substring(12, 16));
        String errorCodeHex = hex.substring(12, 16);
        errorCode = HexUtil.hexToInt(errorCodeHex);
        System.out.println("故障码:" + errorCodeHex + " - " + errorCode);
        setCrc32(hex.substring(hex.length() - 8));
        //  校验CRC32
        String frame = getFunctionCode() + getPayloadLength() + getDestinationAddress() + getErrorCode();
        String frame = getFunctionCode() + getPayloadLength() + getDestinationAddress() + errorCodeHex;
        this.setValidate(CRC32Utils.validateFrame(frame, getCrc32()));
        return this;
    }