From f23ad1b3f9f6193f35f72104d690b21dc67d5c1f Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期一, 06 七月 2020 12:35:25 +0800
Subject: [PATCH] 去掉了访问外网的异步
---
ZigbeeApp/Shared/Phone/ZigBee/Device/ZbGateway.cs | 56 ++++++++++++++++++++++++++++++++++++++++----------------
1 files changed, 40 insertions(+), 16 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/ZigBee/Device/ZbGateway.cs b/ZigbeeApp/Shared/Phone/ZigBee/Device/ZbGateway.cs
index e7b139f..408e3d2 100755
--- a/ZigbeeApp/Shared/Phone/ZigBee/Device/ZbGateway.cs
+++ b/ZigbeeApp/Shared/Phone/ZigBee/Device/ZbGateway.cs
@@ -2400,6 +2400,11 @@
{
DebugPrintLog($" 鏈湴杩炴帴鎴愬姛_缃戝叧IP:{brokerName}_缃戝叧鏄惁鍔�:{IsEncry}_褰撳墠瀵嗙爜:{Password}");
IsRemote = false;
+ //Log鍐欏叆(璋冭瘯鐢�)
+ if (Shared.Phone.UserCenter.UserCenterResourse.HideOption.WriteSendAndReceveDataToFile == 1)
+ {
+ Shared.Phone.UserCenter.HdlLogLogic.Current.WriteLog(2, "鏈湴杩炴帴鎴愬姛");
+ }
});
}
@@ -2439,7 +2444,12 @@
}
}
catch (Exception ex)
- {
+ {
+ //Log鍐欏叆(璋冭瘯鐢�)
+ if (Shared.Phone.UserCenter.UserCenterResourse.HideOption.WriteSendAndReceveDataToFile == 1)
+ {
+ Shared.Phone.UserCenter.HdlLogLogic.Current.WriteLog(2, "鏈湴杩炴帴寮傚父:\r\n" + ex.Message);
+ }
DebugPrintLog($"灞�鍩熺綉閫氳杩炴帴鍑哄紓甯�:{ex.Message}");
}
finally
@@ -2449,17 +2459,10 @@
});
}
- class GateWayBaseInfomation
- {
- //public string GatewayUniqueId;//"Emq缃戝叧1", <!-- 缃戝叧Mac -->
- public bool MqttOnlineStatus;//: true, <!-- 缃戝叧鍦ㄤ簯绔疎mq鏄惁鍦ㄧ嚎 -->
- public string AesKey;// : "a5d8da8a-ddea-48", <!-- 涓庢缃戝叧鍦ㄤ簯绔疎mq閫氫俊鏃讹紝璐熻浇鍔犺В鐨�16浣岮es瀵嗛挜 -->
- public string MacMark;//: "61eaa0ea-4812-4a7a-86d6-3098c61e64ed" <!-- 缃戝叧瀵瑰簲鐨勫敮涓�鐮� -->
- }
/// <summary>
/// 褰撳墠鏈夊笎鍙蜂笅鎵�鏈夌殑缃戝叧鍒楄〃鍙婁俊鎭�
/// </summary>
- static Dictionary<string, GateWayBaseInfomation> GateWayBaseInfomations = new Dictionary<string, GateWayBaseInfomation> { };
+ public static Dictionary<string, Shared.Phone.UserCenter.GatewayResult> GateWayBaseInfomations = new Dictionary<string, Shared.Phone.UserCenter.GatewayResult> { };
/// <summary>
/// 鑾峰彇褰撳墠甯愬彿鎵�鏈夌殑缃戝叧淇℃伅
/// </summary>
@@ -2482,9 +2485,7 @@
MainAccountId = Config.Instance.Home.MainUserDistributedMark,
SharedHid = Config.Instance.Home.Id
};
-
- var listNotShow = new List<string>() { "NotSetAgain" };
- var resultData = await Shared.Phone.UserCenter.UserCenterLogic.GetByteResponseDataByRequestHttps("App/GetSharedHomeApiControl", false, pra, listNotShow);
+ var resultData = Shared.Phone.UserCenter.UserCenterLogic.GetByteResponseDataByRequestHttps("App/GetSharedHomeApiControl", false, pra);
if (resultData == null)
{
return;
@@ -2505,7 +2506,7 @@
pra2.ReqDto.LoginAccessToken = loginToken;
var bytes = System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(pra2));
- var result = await CommonPage.Instance.DoRequestZigbeeHttpsInterface("https://global.hdlcontrol.com/HangZhouHdlCloudApi/App/GetSingleHomeGatewayPagger", bytes, loginToken);
+ var result = CommonPage.Instance.DoRequestZigbeeHttpsInterface("https://global.hdlcontrol.com/HangZhouHdlCloudApi/App/GetSingleHomeGatewayPagger", bytes, loginToken);
if (result != null)
{
var jobject = Newtonsoft.Json.Linq.JObject.Parse(Encoding.UTF8.GetString(result));
@@ -2530,7 +2531,7 @@
var list = JArray.Parse(responseData["PageData"].ToString());
foreach (var v in list)
{
- GateWayBaseInfomations[v["GatewayUniqueId"].ToString()] = new GateWayBaseInfomation { AesKey = v["AesKey"].ToString(), MacMark = v["MacMark"].ToString(), MqttOnlineStatus = bool.Parse(v["MqttOnlineStatus"].ToString()) };
+ GateWayBaseInfomations[v["GatewayUniqueId"].ToString()] = new Shared.Phone.UserCenter.GatewayResult { AesKey = v["AesKey"].ToString(), MacMark = v["MacMark"].ToString(), MqttOnlineStatus = bool.Parse(v["MqttOnlineStatus"].ToString()) };
//if (RemoteMqttClient.IsConnected)
{
await RemoteMqttClient.SubscribeAsync($"/ZigbeeGateWayToClient/{v["MacMark"].ToString()}/#", MQTTnet.Protocol.MqttQualityOfServiceLevel.ExactlyOnce);
@@ -2695,7 +2696,7 @@
["PublishPayloadJsonStr"] = "1"
};
var bytes = System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(jsonData));
- result = await CommonPage.Instance.DoRequestZigbeeHttpsInterface("https://global.hdlcontrol.com/HangZhouHdlCloudApi/EmqMqtt/GetConnMqttInfo", bytes, Config.Instance.Token);
+ result = CommonPage.Instance.DoRequestZigbeeHttpsInterface("https://global.hdlcontrol.com/HangZhouHdlCloudApi/EmqMqtt/GetConnMqttInfo", bytes, Config.Instance.Token);
}
else
{
@@ -2712,7 +2713,7 @@
["PublishPayloadJsonStr"] = "1"
};
var bytes = System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(jsonData));
- result = await CommonPage.Instance.DoRequestZigbeeHttpsInterface("https://global.hdlcontrol.com/HangZhouHdlCloudApi/EmqMqtt/ShareMemberConnMqttInfo", bytes, Config.Instance.Token);
+ result = CommonPage.Instance.DoRequestZigbeeHttpsInterface("https://global.hdlcontrol.com/HangZhouHdlCloudApi/EmqMqtt/ShareMemberConnMqttInfo", bytes, Config.Instance.Token);
}
if (result != null)
{
@@ -2889,6 +2890,16 @@
if (Shared.Common.Config.Instance.HomeId == "")
{
return;
+ }
+
+ //Log鍐欏叆(璋冭瘯鐢�)
+ if (Shared.Phone.UserCenter.UserCenterResourse.HideOption.WriteSendAndReceveDataToFile == 1)
+ {
+ string text = "杩滅▼鍙戦��:";
+ if (IsRemote == false) { text = "鏈湴鍙戦��:"; }
+ text += topic + "\r\n";
+ text += Encoding.UTF8.GetString(message) + "\r\n";
+ Shared.Phone.UserCenter.HdlLogLogic.Current.WriteLog(2, text);
}
if (IsRemote)
@@ -2923,6 +2934,11 @@
{
DebugPrintLog($"灞�鍩熺綉鈥斺�斾簩娆″彂閫佸埌缃戝叧鐨勪富棰�:{topic}_鍙戦�佸埌缃戝叧鐨勬暟鎹�:{System.Text.Encoding.UTF8.GetString(message)}_鏄惁鍔犲瘑:{IsEncry}");
await localMqttClient.PublishAsync(new MqttApplicationMessage { Topic = topic, Payload = message, QualityOfServiceLevel = MQTTnet.Protocol.MqttQualityOfServiceLevel.ExactlyOnce, Retain = retain });
+ }
+ //Log鍐欏叆(璋冭瘯鐢�)
+ if (Shared.Phone.UserCenter.UserCenterResourse.HideOption.WriteSendAndReceveDataToFile == 1)
+ {
+ Shared.Phone.UserCenter.HdlLogLogic.Current.WriteLog(2, "鏈湴杩炴帴寮傚父鏂紑");
}
}
}
@@ -3139,6 +3155,14 @@
attrId = topic.Split('/')[5];
}
+ //Log鍐欏叆(璋冭瘯鐢�)
+ if (Shared.Phone.UserCenter.UserCenterResourse.HideOption.WriteSendAndReceveDataToFile == 1)
+ {
+ string text = "缃戝叧鍥炲:" + topic + "\r\n";
+ text += message + "\r\n";
+ Shared.Phone.UserCenter.HdlLogLogic.Current.WriteLog(2, text);
+ }
+
//鍏ㄥ眬鎺ユ敹缃戝叧鎺ㄩ�佺殑鐨勯�昏緫(涓轰簡鎵ц閫熷害,灏藉彲鑳界殑鍒姞鑰楁椂鐨勬搷浣�)
Shared.Phone.UserCenter.HdlGatewayReceiveLogic.Current.GatewayOverallMsgReceive(gatewayID, topic, reportStatus, message);
--
Gitblit v1.8.0