From b3e96fce4cc01113128ddf8e0a18fc19594a9e56 Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期四, 05 十二月 2019 18:38:30 +0800
Subject: [PATCH] 一个新的版本

---
 ZigbeeApp/Shared/Phone/ZigBee/Common/Application.cs |   18 ++++++++++++------
 1 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/ZigBee/Common/Application.cs b/ZigbeeApp/Shared/Phone/ZigBee/Common/Application.cs
index f4c69b6..3fd043a 100755
--- a/ZigbeeApp/Shared/Phone/ZigBee/Common/Application.cs
+++ b/ZigbeeApp/Shared/Phone/ZigBee/Common/Application.cs
@@ -50,7 +50,9 @@
                     try
                     {
                         if (string.IsNullOrEmpty(Shared.Common.Config.Instance.HomeId))
-                        {
+                        {
+                            //浣忓畢ID涓虹┖鍙湁涓�绉嶅彲鑳藉氨鏄��鍑轰簡鐧诲綍锛岃繖閲岀殑涓婁竴娆′綇瀹匢D瑕佹竻绌�
+                            oldHomeID = "?";
                             System.Threading.Thread.Sleep(1000);
                             continue;
                         }
@@ -65,7 +67,7 @@
                             //鏈�鍚庡啀鏂紑mqtt杩炴帴
                             for (int i = 0; i < list.Count; i++)
                             {
-                                list[i].DisConnect("1");
+                                list[i].DisConnectLocalMqttClient("1");
                             }
                             list.Clear();
                             oldHomeID = Shared.Common.Config.Instance.HomeId;
@@ -111,6 +113,10 @@
                         else
                         {
                             ZbGateway.IsRemote = true;
+                            for (int i = 0; i < ZbGateway.GateWayList.Count; i++)
+                            {
+                                 ZbGateway.GateWayList[i].DisConnectLocalMqttClient("1");
+                            }
                         }
 
                         searchCount--;
@@ -208,8 +214,8 @@
                                     var gateWay = ZbGateway.GateWayList.Find(obj => obj.getGatewayBaseInfo != null && obj.getGatewayBaseInfo.gwID == zbGateWay.getGatewayBaseInfo.gwID);
                                     if (gateWay == null)
                                     {
-                                        await zbGateWay.StartLocalMqtt(ipAddress);
                                         ZbGateway.GateWayList.Add(zbGateWay);
+                                        await zbGateWay.StartLocalMqtt(ipAddress);
                                         NewGateWayAction?.Invoke(zbGateWay);
                                     }
                                     else
@@ -219,11 +225,11 @@
                                         gateWay.GatewayOnlineFlage = true;
                                         if (gateWay.getGatewayBaseInfo.IpAddress != ipAddress)
                                         {
-                                            gateWay.DisConnect("2");
+                                            await gateWay.DisConnectLocalMqttClient("2");
                                             ZbGateway.GateWayList.Remove(gateWay);
                                             gateWay = zbGateWay;
-                                            await zbGateWay.StartLocalMqtt(ipAddress);
                                             ZbGateway.GateWayList.Add(gateWay);
+                                            await zbGateWay.StartLocalMqtt(ipAddress);
                                         }
                                         else
                                         {
@@ -270,7 +276,7 @@
                     try
                     {
                         //瀹氭椂妫�娴嬭繙绋嬭繛鎺ユ儏鍐�
-                        await ZbGateway.StartCloudMqtt(); 
+                        await ZbGateway.StartRemoteMqtt(); 
                         if (!ZbGateway.IsRemote)
                         {
                             System.Threading.Thread.Sleep(500);

--
Gitblit v1.8.0