From 7a11998bb4d64d8fce3aef1ed7918553832baf02 Mon Sep 17 00:00:00 2001
From: 陈嘉乐 <cjl@hdlchina.com.cn>
Date: 星期二, 16 三月 2021 13:25:35 +0800
Subject: [PATCH] 2021-3-16-2

---
 HDL_ON/DAL/Mqtt/MqttClient.cs |   35 ++++++++++++++++++++++++++---------
 1 files changed, 26 insertions(+), 9 deletions(-)

diff --git a/HDL_ON/DAL/Mqtt/MqttClient.cs b/HDL_ON/DAL/Mqtt/MqttClient.cs
index a7dea34..a3fe1fe 100644
--- a/HDL_ON/DAL/Mqtt/MqttClient.cs
+++ b/HDL_ON/DAL/Mqtt/MqttClient.cs
@@ -194,13 +194,20 @@
                     //App璁㈤槄绾㈠瀹� / 缃戝叧閬ユ帶鍣ㄦ坊鍔犳垚鍔熼�氱煡
                     var pirStatus = new MqttTopicFilter()
                     {
-                        Topic = $"/user/${DB_ResidenceData.Instance.CurrentRegion.RegionID}/app/thing/topo/found",
+                        Topic = $"/user/{DB_ResidenceData.Instance.CurrentRegion.RegionID}/app/thing/topo/found",
+                        QualityOfServiceLevel = MQTTnet.Protocol.MqttQualityOfServiceLevel.AtMostOnce
+                    };
+                    //App璁㈤槄閬ユ帶鍣ㄨ嚜瀛︽寜閿涔犳垚鍔熼�氱煡
+                    var study = new MqttTopicFilter()
+                    {
+                        Topic = $"/user/{DB_ResidenceData.Instance.CurrentRegion.RegionID}/app/thing/event/irCodeStudyDone/up",
                         QualityOfServiceLevel = MQTTnet.Protocol.MqttQualityOfServiceLevel.AtMostOnce
                     };
 
                     Utlis.WriteLine("寮�濮嬭闃咃紒");
                     var result = await RemoteMqttClient.SubscribeAsync(new MqttTopicFilter[] {
                         pirStatus,
+                         study,
                         topicFilterPush2, topicAlinkStatus });
                     if (result.Items[0].ResultCode == MQTTnet.Client.Subscribing.MqttClientSubscribeResultCode.GrantedQoS0)
                     {
@@ -238,7 +245,7 @@
 
             Utlis.WriteLine($"StartCloudMqtt: 寮�濮�");
 
-            await Task.Factory.StartNew(async () => {
+            await Task.Factory.StartNew((Func<Task>)(async () => {
                 try
                 {
                     #region 鍒濆鍖栬繙绋婱qtt
@@ -250,7 +257,7 @@
                     if (RemoteMqttClient.ApplicationMessageReceivedHandler == null)
                     {
                         //澶勭悊鎺ユ敹鍒扮殑鏁版嵁
-                        RemoteMqttClient.UseApplicationMessageReceivedHandler((e) => {
+                        RemoteMqttClient.UseApplicationMessageReceivedHandler((Action<MqttApplicationMessageReceivedEventArgs>)((e) => {
                             try
                             {
                                 var topic = e.ApplicationMessage.Topic;
@@ -287,10 +294,20 @@
                                     ReceiveNotifySqueezeAsync(mMes);
                                 }
                                 //App璁㈤槄绾㈠瀹�/缃戝叧閬ユ帶鍣ㄦ坊鍔犳垚鍔熼�氱煡
-                                else if (topic == $"/user/${DB_ResidenceData.Instance.CurrentRegion.RegionID}/app/thing/topo/found")
+                                else if (topic == $"/user/{DB_ResidenceData.Instance.CurrentRegion.RegionID}/app/thing/topo/found")
                                 {
-                                    var ss = Encoding.UTF8.GetString(e.ApplicationMessage.Payload);
-                                    HDL_ON.UI.UI2.PersonalCenter.PirDevice.Method.addcontronsid = ss;
+                                    var bytes = Securitys.EncryptionService.AesDecryptPayload(e.ApplicationMessage.Payload, tuyaEncryptKey);
+                                    var revString = Encoding.UTF8.GetString(bytes);
+                                    HDL_ON.UI.UI2.PersonalCenter.PirDevice.Method.controldata = revString;
+                                    //ReceiveCheckGateway(ss);
+                                    //return;
+                                }
+                                //App璁㈤槄閬ユ帶鍣ㄨ嚜瀛︽寜閿涔犳垚鍔熼�氱煡
+                                else if (topic == $"/user/{DB_ResidenceData.Instance.CurrentRegion.RegionID}/app/thing/event/irCodeStudyDone/up")
+                                {
+                                    var bytes = Securitys.EncryptionService.AesDecryptPayload(e.ApplicationMessage.Payload, tuyaEncryptKey);
+                                    var revString = Encoding.UTF8.GetString(bytes);
+                                    HDL_ON.UI.UI2.PersonalCenter.PirDevice.Method.buttondata = revString;
                                     //ReceiveCheckGateway(ss);
                                     //return;
                                 }
@@ -299,7 +316,7 @@
                                 {
                                     var bytes = Securitys.EncryptionService.AesDecryptPayload(e.ApplicationMessage.Payload, tuyaEncryptKey);
                                     var revString = Encoding.UTF8.GetString(bytes);
-                                    Control.Ins.UpdataFunctionStatus(revString, null);
+                                    Control.Ins.UpdataFunctionStatus(revString, null,true);
                                 }
                                 //涓�绔彛鏁版嵁瑙f瀽
                                 else
@@ -321,7 +338,7 @@
                                 }
                             }
                             catch { }
-                        });
+                        }));
                     }
 
                     //(2)DisconnectedHandler
@@ -372,7 +389,7 @@
                     Utlis.WriteLine($"StartCloudMqtt: 缁撴潫");
                 }
 
-            });
+            }));
         }
 
 

--
Gitblit v1.8.0