package com.aliyun.iotx;

import org.eclipse.paho.client.mqttv3.MqttException;

import java.util.ArrayList;
import java.util.List;

/**
 * 订阅云飞的数据
 */
public class MainApplication {

    private final static String deviceName1 = "16082926";
    private final static String deviceName2 = "16082928";
    private final static String deviceName3 = "16082934";
    private final static String deviceName4 = "16082924";
    private final static String deviceName5 = "16082938";
    private final static String deviceName6 = "16082925";
    private final static String deviceName7 = "16082937";
    private final static String deviceName8 = "16082935";
    private final static String deviceName9 = "16082936";
    private final static String deviceName10 = "16082942";
    private final static String deviceName11 = "16082932";
    private final static String deviceName12 = "16082933";
    private final static String deviceName13 = "16082927";
    private final static String deviceName14 = "16082929";
    private final static String deviceName15 = "16082931";
    private final static String deviceName16 = "16082930";
    private final static String deviceName17 = "16082940";
    private final static String deviceName18 = "16082941";
    private final static String deviceName19 = "16082939";
    private final static String deviceName20 = "16082923";

    private static final List<String> Device_Name_List = new ArrayList<>();
    static {
        Device_Name_List.add(deviceName1);
        Device_Name_List.add(deviceName2);
        Device_Name_List.add(deviceName3);
        Device_Name_List.add(deviceName4);
        Device_Name_List.add(deviceName5);
        Device_Name_List.add(deviceName6);
        Device_Name_List.add(deviceName7);
        Device_Name_List.add(deviceName8);
        Device_Name_List.add(deviceName9);
        Device_Name_List.add(deviceName10);
        Device_Name_List.add(deviceName11);
        Device_Name_List.add(deviceName12);
        Device_Name_List.add(deviceName13);
        Device_Name_List.add(deviceName14);
        Device_Name_List.add(deviceName15);
        Device_Name_List.add(deviceName16);
        Device_Name_List.add(deviceName17);
        Device_Name_List.add(deviceName18);
        Device_Name_List.add(deviceName19);
        Device_Name_List.add(deviceName20);
    }

    // 订阅云飞的数据
    public static void main(String[] args) throws MqttException {
//        BridgeTsl bridgeTsl = new BridgeTsl();
        BridgeTsl.start();

        for (String deviceName : Device_Name_List) {
            // 新的，有重连
            String HOST = "tcp://120.27.222.26:1883";
            MqttClientThread mqttClientThread = new MqttClientThread(HOST,
                    "/yfkj/qxz/pub/" + deviceName,
                    "client" + deviceName);
            mqttClientThread.start();
        }

    }
}
