2021与蓝度共同重构项目,服务端
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package com.sandu.ximon.admin.localMQTT.controller;
 
import com.sandu.ximon.admin.localMQTT.util.MqttClientUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
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;
 
/**
 * @author van
 * @version 1.0
 * msg:
 * @date 2022/11/11 14:18
 */
@RestController
@RequestMapping("/localMQTT")
@Slf4j
public class localMQTTTestController {
 
 
    @RequestMapping("/test")
    public String localMQTT() throws InterruptedException {
 
        for (int i = 0; i < 100; i++) {
 
            /*
            * 开灯100
            * FEA501000BFE010003FFFF0045971477B6D8C2CA
            * 10
            * FEA501000BFE010003FFFF0AA542FD69D4E6194E
            * 关灯
            * FEA501000BFE0100030001007130ECA9150640E6
            * 查询心跳时间
            * FEA501000AFE110002FFFF26008FBE3DAC7C0D
            * 设置心跳30秒
            * FEA501000CFE210004FFFF001E9BB444E9C75BDB49
            * 5分钟
            * FEA501000CFE210004FFFF012C4A7824285825CB53
            * */
//            开10
            String result1 = MqttClientUtil.sendMqttMsg("363832544e5008ff3a32ffff",
                            "FEA501000BFE010003FFFF0AA542FD69D4E6194E");
            log.info("开灯返回结果:"+result1);
            sleep(3000);
//            关
            String result2 = MqttClientUtil.sendMqttMsg("363832544e5008ff3a32ffff",
                    "FEA501000BFE0100030001007130ECA9150640E6");
            log.info("关灯返回结果:"+result2);
            sleep(3000);
////            心跳查询
//            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(10000);
 
        }
 
 
        return "OK";
    }
}