From 3e7c0a6deda128e639abfa3b8ed9377dbd017526 Mon Sep 17 00:00:00 2001
From: 陈嘉乐 <cjl@hdlchina.com.cn>
Date: 星期五, 11 十二月 2020 17:47:24 +0800
Subject: [PATCH] 2020-12-11-4
---
HDL_ON/DAL/Mqtt/MqttClient.cs | 26 ++++++++++++++------------
1 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/HDL_ON/DAL/Mqtt/MqttClient.cs b/HDL_ON/DAL/Mqtt/MqttClient.cs
index 591e8a2..321d8b1 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,7 +210,6 @@
/// </summary>
public static async Task StartCloudMqtt()
{
-
if (OnAppConfig.Instance.internetStatus == 0)
{
return;
@@ -232,7 +232,7 @@
try
{
#region 鍒濆鍖栬繙绋婱qtt
-
+ remoteMqttIsConnecting = true;
RemoteMqttClient = new MqttFactory().CreateMqttClient();
@@ -268,7 +268,9 @@
else
{
SetGatewayOnlineResetCheck();
- if (Entity.DB_ResidenceData.residenceData.GatewayType == 0)
+ Securitys.EncryptionService.AesDecryptPayload(e.ApplicationMessage.Payload, DB_ResidenceData.residenceData.HomeGateway.aesKey);
+ //bus鏁版嵁瑙f瀽
+ if (DB_ResidenceData.residenceData.GatewayType == 0)
{
var packet = new Packet();
@@ -285,6 +287,8 @@
else
{
//A鍗忚鏁版嵁澶勭悊
+ var revString = Encoding.UTF8.GetString(e.ApplicationMessage.Payload);
+ Control.Ins.UpdataFunctionStatus(revString);
}
}
}
@@ -308,11 +312,7 @@
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
@@ -634,7 +634,8 @@
{
if (Control.Ins.IsRemote)
{
- Control.Ins.GatewayOnline = true;
+ if (!Control.Ins.GatewayOnline)
+ Control.Ins.GatewayOnline = true;
}
}
@@ -661,6 +662,7 @@
else
{
Utlis.WriteLine("============>杩樻病缁戝畾缃戝叧");
+ hadGateway = false;
}
}
}
--
Gitblit v1.8.0