JLChen
2020-11-25 52e05a5fb6e07afbb14960fc3cbb8a8971e19eb2
HDL_ON/DAL/Net/Mqtt_A_Protocol.cs
@@ -15,6 +15,7 @@
//        public static IMqttClient mqttClient_A;
//        public static string mqttClientIP;
//        public static string mqttGatewayMAC;
//        public static string mqttGatewayName;
//        static bool remoteIsConnected;
//        static bool onConnection = false;
@@ -107,6 +108,7 @@
//                onConnection = true;
//                new System.Threading.Thread(async () =>
//                {
//                    MainPage.Log($"mqtt 线程启动 : {DateTime.Now}");
//                    if (remoteIsConnected)
//                        return;
//                    try
@@ -133,7 +135,7 @@
//                            int readCount = 0;
//                            BusSocket.Stop();
//                            System.Threading.Thread.Sleep(1000);
//                            BusSocket.Start(6688);
//                            BusSocket.Start();
//                            System.Threading.Thread.Sleep(1000);
//                            Control.ReadGatewayIPAddress();
//                            while (true)
@@ -154,13 +156,13 @@
//                                }
//                            }
//                            BusSocket.Stop();
//                            System.Threading.Thread.Sleep(1000);
//                            BusSocket.Start(6000);
//                            System.Threading.Thread.Sleep(1000);
//                            //System.Threading.Thread.Sleep(1000);
//                            //BusSocket.Start(6000);
//                            //System.Threading.Thread.Sleep(1000);
//                            var options = new MqttClientOptionsBuilder()//MQTT连接参数填充
//                                .WithClientId(Guid.NewGuid().ToString().Substring(0, 5))//客户端ID
//                                .WithTcpServer(mqttClientIP, 1883)//MQTTServerIP.Text, Int32.Parse(MQTTServerPort.Text.ToString()))//TCP服务端  1883  ,即MQTT服务端
//                                .WithTcpServer(mqttClientIP, 8586)//MQTTServerIP.Text, Int32.Parse(MQTTServerPort.Text.ToString()))//TCP服务端  1883  ,即MQTT服务端
//                                .WithCredentials("", "")//"", "")//凭证  帐号 密码
//                                .WithCommunicationTimeout(new TimeSpan(0, 0, 60)) //重连超时时间,默认5s
//                                .WithKeepAlivePeriod(new TimeSpan(0, 0, 15)) //保持连接时间,默认5s,心跳包