From 9ef48d7b2da7c408b53f73be0f6eef3cbac1c84a Mon Sep 17 00:00:00 2001 From: 黄学彪 <hxb@hdlchina.com.cn> Date: 星期四, 19 十一月 2020 10:23:45 +0800 Subject: [PATCH] Evoyo.Home1.1.0120111601_Release --- ZigbeeApp/Shared/Phone/ZigBee/Device/ZbGateway.cs | 103 ++++++++++++++++++++++++++++++++++++--------------- 1 files changed, 73 insertions(+), 30 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/ZigBee/Device/ZbGateway.cs b/ZigbeeApp/Shared/Phone/ZigBee/Device/ZbGateway.cs index 92b8ced..376af66 100755 --- a/ZigbeeApp/Shared/Phone/ZigBee/Device/ZbGateway.cs +++ b/ZigbeeApp/Shared/Phone/ZigBee/Device/ZbGateway.cs @@ -2664,44 +2664,50 @@ //璁㈤槄涓�涓尋涓嬬嚎鐨勪富棰� await RemoteMqttClient.SubscribeAsync("/ZigbeeGateWayToClient/" + Config.Instance.ConnEmqClientId + "/Push/NotifySqueeze"); - await initGateWayBaseInfomation(); - - //娌℃湁涓荤綉鍏虫椂涓诲姩璇诲彇锛岃幏鍙栦富缃戝叧淇℃伅 - var gateWayList = GateWayList.FindAll(obj => obj.HomeId == Shared.Common.Config.Instance.HomeId); - if (gateWayList.Find(obj => obj.IsMainGateWay == true) == null) + //濡傛灉杩欎釜鍑芥暟鍗′箙浜嗙殑璇濓紝浼氭帴鏀跺埌浜戠鎺ㄩ�佺殑鎸や笅绾夸富棰橈紝涓嶇煡閬撲负浠�涔� + new Thread(async () => { - if (gateWayList.Count == 1) + await initGateWayBaseInfomation(); + + //娌℃湁涓荤綉鍏虫椂涓诲姩璇诲彇锛岃幏鍙栦富缃戝叧淇℃伅 + var gateWayList = GateWayList.FindAll(obj => obj.HomeId == Shared.Common.Config.Instance.HomeId); + if (gateWayList.Find(obj => obj.IsMainGateWay == true) == null) { - gateWayList[0].IsMainGateWay = true; - } - else - { - for (int i = 0; i < gateWayList.Count; i++) + if (gateWayList.Count == 1) { - var gateWay = gateWayList[i]; - var info = await gateWay.GetZbGwInfoAsync(); - if (info == null || info.getGwData == null) + gateWayList[0].IsMainGateWay = true; + } + else + { + for (int i = 0; i < gateWayList.Count; i++) { - continue; - } - if (info.getGwData.IsDominant == 1) - { - for (int j = 0; j < gateWayList.Count; j++) + var gateWay = gateWayList[i]; + var info = await gateWay.GetZbGwInfoAsync(); + if (info == null || info.getGwData == null) { - if (gateWayList[i].GwId == info.getGwData.GwId) - { - gateWayList[i].IsMainGateWay = true; - } - else - { - gateWayList[i].IsMainGateWay = false; - } + continue; } - break; + if (info.getGwData.IsDominant == 1) + { + for (int j = 0; j < gateWayList.Count; j++) + { + if (gateWayList[i].GwId == info.getGwData.GwId) + { + gateWayList[i].IsMainGateWay = true; + } + else + { + gateWayList[i].IsMainGateWay = false; + } + } + break; + } } } } - } + }) + { IsBackground = true }.Start(); + }); } #endregion @@ -2816,6 +2822,24 @@ { DebugPrintLog($"Local鏂紑閫氳杩炴帴鍑哄紓甯�:{ex.Message}"); } + } + + /// <summary> + /// 寮哄埗鏂紑鏈湴鐨勭綉鍏宠繛鎺� + /// </summary> + public async Task CloseLocalConnectionOnForce() + { + try + { + await localMqttClient.DisconnectAsync(); + } + catch { } + finally + { + localIsConnected = false; + //杩欎釜涓滆タ涔熻寮� + localMqttIsConnecting = false; + } } /// <summary> @@ -2838,6 +2862,25 @@ catch (Exception e) { DebugPrintLog($"Remote鏂紑閫氳杩炴帴鍑哄紓甯�:{e.Message}"); + } + } + + /// <summary> + /// 寮哄埗鏂紑杩滅▼Mqtt鐨勯摼鎺� + /// </summary> + /// <returns></returns> + public static async Task CloseRemoteConnectionOnForce() + { + try + { + await RemoteMqttClient.DisconnectAsync(); + } + catch { } + finally + { + remoteIsConnected = false; + //杩欎釜涓滆タ涔熻寮� + remoteMqttIsConnecting = false; } } @@ -3558,7 +3601,7 @@ #if DEBUG if (flage == true) { - //if (msg.Contains("DeviceStatusReport") == false) + //if (msg.Contains("DeviceInfoRespon") == true) { System.Console.WriteLine(msg + " " + System.DateTime.Now.ToLongTimeString() + " " + System.DateTime.Now.Millisecond); } -- Gitblit v1.8.0