From 18b93d511dc764b469d7c4a7e755f7274f89cdb4 Mon Sep 17 00:00:00 2001 From: 陈嘉乐 <cjl@hdlchina.com.cn> Date: 星期一, 27 四月 2020 17:55:14 +0800 Subject: [PATCH] 2020-4-27-1 --- ZigbeeApp/Shared/Phone/ZigBee/Device/ZbGateway.cs | 76 ++++++++++++-------------------------- 1 files changed, 24 insertions(+), 52 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/ZigBee/Device/ZbGateway.cs b/ZigbeeApp/Shared/Phone/ZigBee/Device/ZbGateway.cs index 990a261..a105443 100755 --- a/ZigbeeApp/Shared/Phone/ZigBee/Device/ZbGateway.cs +++ b/ZigbeeApp/Shared/Phone/ZigBee/Device/ZbGateway.cs @@ -143,12 +143,6 @@ public List<CommonDevice> DeviceList = new List<CommonDevice>(); /// <summary> - /// 鎵�鏈夌綉鍏充腑鐨勮澶囧垪琛� - /// </summary> - [Newtonsoft.Json.JsonIgnore] - public List<CommonDevice> AllGatewayDeviceList = new List<CommonDevice>(); - - /// <summary> /// 缃戝叧涓満鏅垪琛� /// 涓�涓満鏅腑鍖呭惈鎵�鏈変俊鎭紝鍖呮嫭鍦烘櫙璁惧淇℃伅 /// </summary> @@ -160,28 +154,6 @@ /// </summary> [Newtonsoft.Json.JsonIgnore] public List<Scene.GetSceneDeviceListInfo> SceneDeviceList = new List<Scene.GetSceneDeviceListInfo>(); - - /// <summary> - /// 缃戝叧涓環dl绉佹湁鎸夐敭缁戝畾鍒楄〃 - /// </summary> - [Newtonsoft.Json.JsonIgnore] - public List<HDLbutton> HdlButtonList = new List<HDLbutton>(); - - //缃戝叧涓柊鐨勮澶囧垪琛� - [Newtonsoft.Json.JsonIgnore] - public List<CommonDevice> ListNewDeviceInfoData = new List<CommonDevice>(); - - /// <summary> - /// 绉佹湁鎸夐敭淇℃伅鍒楄〃 - /// </summary> - [Newtonsoft.Json.JsonIgnore] - public System.Collections.Generic.Dictionary<string, HDLbutton> hdlButtonInfoList = new Dictionary<string, HDLbutton>(); - - /// <summary> - /// 浼犳劅鍣ㄤ俊鎭垪琛� - /// </summary> - [Newtonsoft.Json.JsonIgnore] - public System.Collections.Generic.Dictionary<string, Scene.TaskListInfo> sceneTaskInfoList = new Dictionary<string, Scene.TaskListInfo>(); #region action variable /// <summary> @@ -3158,14 +3130,14 @@ { if (localMqttClient.Options == null) { - var options = new MQTTnet.Client.Options.MqttClientOptionsBuilder().WithClientId(currentGuid.ToString()) - .WithTcpServer(brokerName, 1883) - .WithKeepAlivePeriod(TimeSpan.FromSeconds(20)) - .WithCleanSession() - //.WithCommunicationTimeout(TimeSpan.FromSeconds(10)) - .WithCredentials("", "") - .Build(); - await localMqttClient.ConnectAsync(options, CancellationToken.None); + var options = new MQTTnet.Client.Options.MqttClientOptionsBuilder()//MQTT杩炴帴鍙傛暟濉厖 + .WithClientId(currentGuid.ToString())//瀹㈡埛绔疘D + .WithTcpServer(brokerName, 1883)//TCP鏈嶅姟绔� 1883 锛屽嵆MQTT鏈嶅姟绔� + .WithCredentials("", "")//"", "")//鍑瘉 甯愬彿 瀵嗙爜 + .WithCommunicationTimeout(new TimeSpan(0, 0, 60)) //閲嶈繛瓒呮椂鏃堕棿锛岄粯璁�5s + .WithKeepAlivePeriod(new TimeSpan(0, 0, 15)) //淇濇寔杩炴帴鏃堕棿锛岄粯璁�5s锛屽績璺冲寘 + .Build();// + await localMqttClient.ConnectAsync(options); } else { @@ -3337,23 +3309,19 @@ if (RemoteMqttClient.ApplicationMessageReceivedHandler == null) { RemoteMqttClient.UseApplicationMessageReceivedHandler((e) => - { - if (!RemoteMqttClient.IsConnected || !IsRemote) - { - if (e.ApplicationMessage.Topic != "/ZigbeeGateWayToClient/" + Config.Instance.ConnEmqClientId + "/Push/NotifySqueeze") - { - return; - } - } - //濡傛灉褰撳墠浣跨敤鐨勬槸鍐呯綉妯″紡 - if (IsRemote == false) + { + //杩欓噷鏄壒娈婄殑涓婚 + if (e.ApplicationMessage.Topic == "/ZigbeeGateWayToClient/" + Config.Instance.ConnEmqClientId + "/Push/NotifySqueeze"//韪汉涓嬬嚎 + || e.ApplicationMessage.Topic == "/ZigbeeGateWayToClient/" + Config.Instance.Guid + "/Push/Deleted"//鍒嗕韩鍒犻櫎 + || e.ApplicationMessage.Topic == "/ZigbeeGateWayToClient/" + Config.Instance.Guid + "/Push/DeletedShareData"//鍒嗕韩鍒犻櫎 + || e.ApplicationMessage.Topic == "/ZigbeeGateWayToClient/" + Config.Instance.Guid + "/Push/Update"//鎴愬憳鏉冮檺鍙樻洿 + || e.ApplicationMessage.Topic == "/ZigbeeGateWayToClient/" + Config.Instance.Home.Id + "_" + Config.Instance.Guid + "/PrimaryUserDelYou")//瀛愯处鍙疯鍒犻櫎 { - if (e.ApplicationMessage.Topic == "/ZigbeeGateWayToClient/" + Config.Instance.ConnEmqClientId + "/Push/NotifySqueeze"//韪汉涓嬬嚎 - || e.ApplicationMessage.Topic == "/ZigbeeGateWayToClient/" + Config.Instance.Guid + "/Push/Deleted"//鍒嗕韩鍒犻櫎 - || e.ApplicationMessage.Topic == "/ZigbeeGateWayToClient/" + Config.Instance.Guid + "/Push/DeletedShareData") - { - mqttRemoteClient_MqttMsgPublishReceived(e); - } + mqttRemoteClient_MqttMsgPublishReceived(e); + return; + } + if (!RemoteMqttClient.IsConnected || !IsRemote) + { return; } mqttRemoteClient_MqttMsgPublishReceived(e); @@ -3382,6 +3350,10 @@ await RemoteMqttClient.SubscribeAsync("/ZigbeeGateWayToClient/" + myGuid + "/Push/Deleted"); //璁㈤槄涓�涓垎浜暟鎹凡缁忓彉鏇寸殑涓婚 await RemoteMqttClient.SubscribeAsync("/ZigbeeGateWayToClient/" + myGuid + "/Push/DeletedShareData"); + //璁㈤槄涓�涓瓙璐﹀彿琚垹闄ょ殑涓婚 + await RemoteMqttClient.SubscribeAsync("/ZigbeeGateWayToClient/" + Config.Instance.Home.Id + "_" + myGuid + "/PrimaryUserDelYou"); + //璁㈤槄涓�涓垚鍛樻潈闄愬凡缁忓彉鏇寸殑涓婚 + await RemoteMqttClient.SubscribeAsync("/ZigbeeGateWayToClient/" + myGuid + "/Push/Update"); } //璁㈤槄涓�涓尋涓嬬嚎鐨勪富棰� await RemoteMqttClient.SubscribeAsync("/ZigbeeGateWayToClient/" + Config.Instance.ConnEmqClientId + "/Push/NotifySqueeze"); -- Gitblit v1.8.0