| | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import static com.sandu.ximon.admin.localMQTT.callback.StatusMqttCallBack.localMqttConnectStatusMap; |
| | | import static java.lang.Thread.sleep; |
| | | |
| | | /** |
| | |
| | | |
| | | |
| | | @RequestMapping("/test") |
| | | public static String localMQTT() throws InterruptedException { |
| | | public String localMQTT() throws InterruptedException { |
| | | |
| | | for (int i = 0; i < 10; i++) { |
| | | for (int i = 0; i < 100; i++) { |
| | | |
| | | String result1 = MqttClientUtil.sendMqttMsg("363832544E5008FF3A32FFFF", |
| | | "FEA501000BFE010003FFFF0045971477B6D8C2CA"); |
| | | log.info("返回结果:"+result1); |
| | | sleep(1000); |
| | | String result2 = MqttClientUtil.sendMqttMsg("363832544E5008FF3A32FFFF", |
| | | "FEA501000BFE010003FFFF640F48B1367ABDE0B9"); |
| | | log.info("返回结果:"+result2); |
| | | sleep(1000); |
| | | /* |
| | | * 开灯100 |
| | | * FEA501000BFE010003FFFF0045971477B6D8C2CA |
| | | * 10 |
| | | * FEA501000BFE010003FFFF0AA542FD69D4E6194E |
| | | * 关灯 |
| | | * FEA501000BFE0100030001007130ECA9150640E6 |
| | | * 查询心跳时间 |
| | | * FEA501000AFE110002FFFF26008FBE3DAC7C0D |
| | | * 设置心跳30秒 |
| | | * FEA501000CFE210004FFFF001E9BB444E9C75BDB49 |
| | | * 5分钟 |
| | | * FEA501000CFE210004FFFF012C4A7824285825CB53 |
| | | * */ |
| | | // 开10 |
| | | String result1 = MqttClientUtil.sendMqttMsg("363832544e5008ff3a32ffff", |
| | | "FEA501000BFE010003FFFF0AA542FD69D4E6194E"); |
| | | log.info("开灯返回结果:"+result1); |
| | | sleep(5000); |
| | | // 关 |
| | | String result2 = MqttClientUtil.sendMqttMsg("363832544e5008ff3a32ffff", |
| | | "FEA501000BFE0100030001007130ECA9150640E6"); |
| | | log.info("关灯返回结果:"+result2); |
| | | sleep(5000); |
| | | //// 心跳查询 |
| | | String result3 = MqttClientUtil.sendMqttMsg("363832544e5008ff3a32ffff", |
| | | "FEA501000AFE110002FFFF26008FBE3DAC7C0D"); |
| | | log.info("心跳查询返回结果:"+result3); |
| | | sleep(3000); |
| | | String result4 = MqttClientUtil.sendMqttMsg("363832544e5008ff3a32ffff", |
| | | "FEA501001AFE230012FE23000A00017F1019647F111E005428F600EC64EC194EA28A7C"); |
| | | log.info("定时任务返回结果:"+result4); |
| | | sleep(3000); |
| | | |
| | | System.out.println("链接状态:---"+i+"---:"); |
| | | System.out.println(localMqttConnectStatusMap.get("363832544e5008ff3a32ffff")); |
| | | sleep(3000); |
| | | |
| | | } |
| | | |