| | |
| | | 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; |
| | | import com.sandu.ximon.admin.utils.LogUtils; |
| | | import lombok.Data; |
| | | import lombok.ToString; |
| | | |
| | |
| | | |
| | | @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)); |
| | |
| | | |
| | | String errorCodeHex = hex.substring(12, 16); |
| | | errorCode = HexUtil.hexToInt(errorCodeHex); |
| | | System.out.println("故障码:"+ errorCodeHex +" - " + errorCode); |
| | | System.out.println("故障码:" + errorCodeHex + " - " + errorCode); |
| | | |
| | | setCrc32(hex.substring(hex.length() - 8)); |
| | | // 校验CRC32 |
| | | String frame = getFunctionCode() + getPayloadLength() + getDestinationAddress() + getErrorCode(); |
| | | this.setValidate(CRC32Utils.validateFrame(hex.substring(2, hex.length() - 8), getCrc32())); |
| | | String frame = getFunctionCode() + getPayloadLength() + getDestinationAddress() + errorCodeHex; |
| | | this.setValidate(CRC32Utils.validateFrame(frame, getCrc32())); |
| | | return this; |
| | | } |
| | | } |