| | |
| | | public MqttSubMsgSdV1(MqttTopic subTopic, String msg) { |
| | | this.deviceId = subTopic.devId ; |
| | | this.protocol = subTopic.protocol ; |
| | | this.topic = subTopic.topic ; |
| | | this.msg = msg ; |
| | | this.topic = subTopic ; |
| | | this.metaData = msg ; |
| | | } |
| | | public String toString(){ |
| | | StringBuilder sb = new StringBuilder(); |
| | |
| | | .append("\n") ; |
| | | } |
| | | sb.append("主题:") |
| | | .append(topic) |
| | | .append("\n") ; |
| | | sb.append("消息:") |
| | | .append(msg) |
| | | .append(topic.longName()) |
| | | .append("\n") ; |
| | | if(vo4Up != null){ |
| | | sb.append("数据:") |
| | | .append(vo4Up.toString()) |
| | | .append("\n") ; |
| | | }else{ |
| | | sb.append("元数据:") |
| | | .append(metaData) |
| | | .append("\n") ; |
| | | } |
| | | |
| | | return sb.toString() ; |
| | | } |
| | | |
| | | public boolean subMsgMatchPubMsg(MqttPubMsg pubMsg){ |
| | | if (pubMsg instanceof MqttPubMsgSdV1) { |
| | | MqttPubMsgSdV1 pubMsgSdV1 = (MqttPubMsgSdV1) pubMsg; |
| | | //MqttPubMsgSdV1 pubMsgSdV1 = (MqttPubMsgSdV1) pubMsg; |
| | | if(this.vo4Up != null && this.vo4Up instanceof StateVo){ |
| | | //只要上报的是状态数据,说明设备响应了命令 |
| | | return true ; |
| | | } |
| | | } |
| | |
| | | if (topic == null || topic.isEmpty()) { |
| | | return false; |
| | | } |
| | | if (msg == null || msg.isEmpty()) { |
| | | if (metaData == null || metaData.isEmpty()) { |
| | | return false; |
| | | } |
| | | return true; |