| | |
| | | // public static IMqttClient mqttClient_A; |
| | | // public static string mqttClientIP; |
| | | // public static string mqttGatewayMAC; |
| | | // public static string mqttGatewayName; |
| | | // static bool remoteIsConnected; |
| | | |
| | | // static bool onConnection = false; |
| | |
| | | // onConnection = true; |
| | | // new System.Threading.Thread(async () => |
| | | // { |
| | | // MainPage.Log($"mqtt 线程启动 : {DateTime.Now}"); |
| | | // if (remoteIsConnected) |
| | | // return; |
| | | // try |
| | |
| | | // int readCount = 0; |
| | | // BusSocket.Stop(); |
| | | // System.Threading.Thread.Sleep(1000); |
| | | // BusSocket.Start(6688); |
| | | // BusSocket.Start(); |
| | | // System.Threading.Thread.Sleep(1000); |
| | | // Control.ReadGatewayIPAddress(); |
| | | // while (true) |
| | |
| | | // } |
| | | // } |
| | | // 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,心跳包 |