From 9c8baf7e7e1169ebdf7d5f7ed33ab29dd5fcbf18 Mon Sep 17 00:00:00 2001 From: JLChen <551775569@qq.com> Date: 星期一, 14 十二月 2020 17:45:17 +0800 Subject: [PATCH] 2020-12-14 1.解锁设置问题修复,增加面容ID验证。2.错误码对接增加。 --- HDL_ON/DAL/Mqtt/MqttClient.cs | 36 ++++++++++++++++++++---------------- 1 files changed, 20 insertions(+), 16 deletions(-) diff --git a/HDL_ON/DAL/Mqtt/MqttClient.cs b/HDL_ON/DAL/Mqtt/MqttClient.cs index 591e8a2..bbd535a 100644 --- a/HDL_ON/DAL/Mqtt/MqttClient.cs +++ b/HDL_ON/DAL/Mqtt/MqttClient.cs @@ -10,6 +10,7 @@ using System.Security.Cryptography; using HDL_ON.DriverLayer; using HDL_ON.Entity; +using HDL_ON.UI; namespace HDL_ON.DAL.Mqtt { @@ -20,7 +21,7 @@ /// </summary> static string mqttEncryptKey = ""; //static string checkGatewayTopicBase64 = ""; - + static bool hadGateway = true; /// <summary> /// 鎸や笅绾夸富棰� /// </summary> @@ -131,7 +132,7 @@ static void InitMqtt() { new System.Threading.Thread(async () => { - while (true) + while (hadGateway) { try { @@ -180,7 +181,7 @@ var topicAlinkStatus = new MqttTopicFilter() { - Topic = $"/user/{MqttInfoConfig.Current.HomeGatewayInfo.gatewayId}/app/thing/property/#", + Topic = $"/user/{MqttInfoConfig.Current.HomeGatewayInfo.gatewayId}/app/thing/property/send", QualityOfServiceLevel = MQTTnet.Protocol.MqttQualityOfServiceLevel.AtMostOnce }; @@ -209,8 +210,7 @@ /// </summary> public static async Task StartCloudMqtt() { - - if (OnAppConfig.Instance.internetStatus == 0) + if (MainPage.InternetStatus == 0) { return; } @@ -232,7 +232,7 @@ try { #region 鍒濆鍖栬繙绋婱qtt - + remoteMqttIsConnecting = true; RemoteMqttClient = new MqttFactory().CreateMqttClient(); @@ -268,7 +268,10 @@ else { SetGatewayOnlineResetCheck(); - if (Entity.DB_ResidenceData.residenceData.GatewayType == 0) + var bytes = Securitys.EncryptionService.AesDecryptPayload(e.ApplicationMessage.Payload, DB_ResidenceData.Instance.HomeGateway.aesKey); + + //bus鏁版嵁瑙f瀽 + if (DB_ResidenceData.Instance.GatewayType == 0) { var packet = new Packet(); @@ -285,6 +288,8 @@ else { //A鍗忚鏁版嵁澶勭悊 + var revString = Encoding.UTF8.GetString(bytes); + Control.Ins.UpdataFunctionStatus(revString); } } } @@ -305,14 +310,11 @@ if (RemoteMqttClient.ConnectedHandler == null) { RemoteMqttClient.UseConnectedHandler(async (e) => { + Control.Ins.GatewayOnline = true; IfNeedReadAllDeviceStatus = true; Utlis.WriteLine($"============>Mqtt杩滅▼杩炴帴鎴愬姛"); SendPushSignOut(); - - //if (Control.Ins.IsRemote) { - // //Utlis.ShowAppLinkStatus (AppLinkStatus.CloudLink); - // MainPage.AddTip (Language.StringByID (SimpleControl.R.MyInternationalizationString.LinkSuccess)); - //} + //FunctionList.List.ReadAllFunctionStatus(); }); } #endregion @@ -369,7 +371,7 @@ { try { - if (MqttInfoConfig.Current.HomeGatewayInfo != null && MqttInfoConfig.Current.HomeGatewayInfo.mac == Entity.DB_ResidenceData.residenceData.residenceGatewayMAC) + if (MqttInfoConfig.Current.HomeGatewayInfo != null && MqttInfoConfig.Current.HomeGatewayInfo.mac == Entity.DB_ResidenceData.Instance.residenceGatewayMAC) { await MQTTConnectAsync(); } @@ -634,7 +636,8 @@ { if (Control.Ins.IsRemote) { - Control.Ins.GatewayOnline = true; + if (!Control.Ins.GatewayOnline) + Control.Ins.GatewayOnline = true; } } @@ -651,16 +654,17 @@ MqttInfoConfig.Current.mMqttInfo = mqttInfoRequestResult_Obj; await MQTTConnectAsync(); //1.鍒ゆ柇鏄惁缁戝畾浜嗙綉鍏筹紝鑾峰彇缃戝叧杩滅▼杩炴帴鐨勫姞瀵咾EY - if (DB_ResidenceData.residenceData.CheckWhetherGatewayIsBound()) + if (DB_ResidenceData.Instance.CheckWhetherGatewayIsBound()) { //2.鎵惧嚭鏄惁瀛樺湪鍖归厤褰撳墠浣忓畢鐨刴ac锛屽瓨鍦ㄥ啀杩涜杩滅▼銆� - MqttInfoConfig.Current.HomeGatewayInfo = DB_ResidenceData.residenceData.HomeGateway; + MqttInfoConfig.Current.HomeGatewayInfo = DB_ResidenceData.Instance.HomeGateway; //3.寮�濮嬭繛鎺� await MQTTConnectAsync(); } else { Utlis.WriteLine("============>杩樻病缁戝畾缃戝叧"); + hadGateway = false; } } } -- Gitblit v1.8.0