From 2e7e5f9af5b32cfe1fc3c6ba40bf7eb984bbd0a4 Mon Sep 17 00:00:00 2001 From: 黄学彪 <hxb@hdlchina.com.cn> Date: 星期一, 11 五月 2020 17:52:06 +0800 Subject: [PATCH] ??????? --- ZigbeeApp/Shared/Phone/ZigBee/Common/Application.cs | 64 +++++++++----------------------- 1 files changed, 18 insertions(+), 46 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/ZigBee/Common/Application.cs b/ZigbeeApp/Shared/Phone/ZigBee/Common/Application.cs index 30ae20b..04c6a57 100755 --- a/ZigbeeApp/Shared/Phone/ZigBee/Common/Application.cs +++ b/ZigbeeApp/Shared/Phone/ZigBee/Common/Application.cs @@ -104,18 +104,25 @@ { searchCount = 6; ZbGateway.IsRemote = false; + //褰撶綉鍏崇殑杩炴帴鏂瑰紡鏀瑰彉鏃�,璁板綍褰撳墠鐨勮繛鎺ユ柟寮� + Shared.Phone.UserCenter.HdlGatewayLogic.Current.CheckGatewayByConnectChanged(Shared.Phone.UserCenter.GatewayConnectMode.WIFI); } else { if (searchCount < 0) { ZbGateway.IsRemote = true; + //褰撶綉鍏崇殑杩炴帴鏂瑰紡鏀瑰彉鏃�,璁板綍褰撳墠鐨勮繛鎺ユ柟寮� + Shared.Phone.UserCenter.HdlGatewayLogic.Current.CheckGatewayByConnectChanged(Shared.Phone.UserCenter.GatewayConnectMode.Remote); } } } else { ZbGateway.IsRemote = true; + //褰撶綉鍏崇殑杩炴帴鏂瑰紡鏀瑰彉鏃�,璁板綍褰撳墠鐨勮繛鎺ユ柟寮� + Shared.Phone.UserCenter.HdlGatewayLogic.Current.CheckGatewayByConnectChanged(Shared.Phone.UserCenter.GatewayConnectMode.Remote); + for (int i = 0; i < ZbGateway.GateWayList.Count; i++) { ZbGateway.GateWayList[i].DisConnectLocalMqttClient("1"); @@ -145,7 +152,11 @@ FindGateWaySocket.BeginSend(new System.Net.IPEndPoint(broadcastIpAddress, 7624), broadBytes); } } - catch { } + catch + { + //鍏抽棴Socket,涓嬫鍙戦�佷細鑷姩杩炴帴 + FindGateWaySocket.Stop(); + } System.Threading.Thread.Sleep(500); } }) @@ -185,7 +196,6 @@ getGatewayBaseInfo = new ZbGateway.GatewayBaseInfo { IpAddress = ipAddress, - Time = time, GwName = gwName, HomeId = homeID, IsMainGateWay = isMainGateWay, @@ -237,7 +247,6 @@ else { gateWay.PubKey = pubKey; - gateWay.getGatewayBaseInfo.Time = time; gateWay.getGatewayBaseInfo.GwName = gwName; gateWay.getGatewayBaseInfo.HomeId = homeID; await gateWay.StartLocalMqtt(ipAddress); @@ -277,7 +286,11 @@ } } } - catch { } + catch + { + //鍏抽棴Socket,涓嬫鍙戦�佷細鑷姩杩炴帴 + FindGateWaySocket.Stop(); + } } #endregion } @@ -295,48 +308,7 @@ try { //瀹氭椂妫�娴嬭繙绋嬭繛鎺ユ儏鍐� - await ZbGateway.StartRemoteMqtt(); - if (!ZbGateway.IsRemote) - { - System.Threading.Thread.Sleep(500); - continue; - } - var gateWayList = ZbGateway.GateWayList.FindAll(obj => obj.getGatewayBaseInfo.HomeId == Shared.Common.Config.Instance.HomeId); - - if (gateWayList.Count == 1) - { - gateWayList[0].getGatewayBaseInfo.IsMainGateWay = true; - } - else - { - if (gateWayList.Find((obj) => obj.getGatewayBaseInfo.IsMainGateWay) == null) - { - for (int i = 0; i < gateWayList.Count; i++) - { - var gateWay = gateWayList[i]; - var info = await gateWay.GetZbGwInfoAsync(); - if (info == null || info.getGwData == null) - { - continue; - } - if (info.getGwData.IsDominant == 1) - { - for (int j = 0; j < gateWayList.Count; j++) - { - if (gateWayList[i].getGatewayBaseInfo.gwID == info.getGwData.GwId) - { - gateWayList[i].getGatewayBaseInfo.IsMainGateWay = true; - } - else - { - gateWayList[i].getGatewayBaseInfo.IsMainGateWay = false; - } - } - break; - } - } - } - } + await ZbGateway.StartRemoteMqtt(); } catch { } System.Threading.Thread.Sleep(2000); -- Gitblit v1.8.0