| | |
| | | */ |
| | | public class A5LightTimerReqInnerFrame implements IRequestInnerFrame { |
| | | |
| | | private final String payload; |
| | | private final String functionCode = A5LightDataEnum.LightTimer.getCode(); |
| | | private final String payloadLength; |
| | | private String payload; |
| | | |
| | | /** |
| | | * @param framePayload 多个路灯定时指令, |
| | | */ |
| | | public A5LightTimerReqInnerFrame(String framePayload) { |
| | | String destinationAddress = "FFFF"; |
| | | payload = destinationAddress + framePayload; |
| | | this.payloadLength = SupplementUtils.suppleZero(Integer.toHexString((payload.length() / 2)).toUpperCase(), 4); |
| | | public A5LightTimerReqInnerFrame(String framePayload, String lightAddress) { |
| | | String destinationAddress; |
| | | if (lightAddress == null || (!lightAddress.equals("0001") && !lightAddress.equals("0002"))) { |
| | | destinationAddress = "FFFF"; |
| | | } else { |
| | | destinationAddress = lightAddress; |
| | | } |
| | | payload = destinationAddress + framePayload ; |
| | | // payload = getEncodeFrame(); |
| | | |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public String getEncodeFrame() { |
| | | String functionCode = A5LightDataEnum.LightTimer.getCode(); |
| | | String payloadLength = SupplementUtils.suppleZero(Integer.toHexString((payload.length() / 2)).toUpperCase(), 4); |
| | | String frame = functionCode + payloadLength + payload; |
| | | |
| | | return MQTTConnectTypeEnum.SYNCHRONIZATION.getCode() + frame.toUpperCase() + CRC32Utils.getCRC32(frame.toUpperCase()); |
| | | } |
| | | |