wxr
2020-11-04 e6a26ee148587327478d9a82624a820c907b6e16
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;
@@ -73,7 +74,8 @@
//        static void InitMqtt()
//        {
//            new System.Threading.Thread(async () => {
//            new System.Threading.Thread(async () =>
//            {
//                while (true)
//                {
//                    try
@@ -106,6 +108,7 @@
//                onConnection = true;
//                new System.Threading.Thread(async () =>
//                {
//                    MainPage.Log($"mqtt 线程启动 : {DateTime.Now}");
//                    if (remoteIsConnected)
//                        return;
//                    try
@@ -121,7 +124,8 @@
//                                MainPage.Log($"Des Topic={aesDecryptTopic}");
//                            });
//                            mqttClient_A.UseConnectedHandler(async (e) => {
//                            mqttClient_A.UseConnectedHandler(async (e) =>
//                            {
//                                MainPage.Log("mqtt connected !!");
//                                onConnection = false;
//                            });
@@ -131,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)
@@ -152,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,心跳包