From 5986f63b75bd81c6cef262c670e9251c038cbf5d Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期二, 17 十二月 2019 17:21:07 +0800
Subject: [PATCH] 合并一个版本
---
ZigbeeApp/Shared/Phone/ZigBee/Device/ZbGateway.cs | 42 ++++++++++++++++++++++++++++++++----------
1 files changed, 32 insertions(+), 10 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/ZigBee/Device/ZbGateway.cs b/ZigbeeApp/Shared/Phone/ZigBee/Device/ZbGateway.cs
index dffdf80..0b5fc0d 100755
--- a/ZigbeeApp/Shared/Phone/ZigBee/Device/ZbGateway.cs
+++ b/ZigbeeApp/Shared/Phone/ZigBee/Device/ZbGateway.cs
@@ -60,6 +60,12 @@
/// <value><c>true</c> if is remote; otherwise, <c>false</c>.</value>
public static bool IsRemote;
+ /// <summary>
+ /// 鏄惁鎷ユ湁杩滅▼杩炴帴鐨勬潈闄�
+ /// </summary>
+ [Newtonsoft.Json.JsonIgnore]
+ public static bool AllowRemoteCtrl = true;
+
/// <summary>
/// 缃戝叧淇濆瓨璺緞
/// </summary>
@@ -3229,6 +3235,11 @@
/// <returns></returns>
static async System.Threading.Tasks.Task initGateWayBaseInfomation()
{
+ if (AllowRemoteCtrl == false)
+ {
+ //娌℃湁杩滅▼杩炴帴鐨勬潈闄�
+ return;
+ }
string loginToken = Config.Instance.Token;
if (Config.Instance.Home.IsOthreShare == true)
{
@@ -3271,11 +3282,13 @@
var statuCode = jobject["StateCode"].ToString();
if (statuCode != "Success")
{
- //Log鍑哄姏
- Shared.Phone.UserCenter.HdlLogLogic.Current.WriteLog(-1, "鎺ュ彛璁块棶澶辫触鈽咃細App/GetSingleHomeGatewayPagger " + statuCode);
//搴忓垪鍖栧璞�
var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(pra2);
- Shared.Phone.UserCenter.HdlLogLogic.Current.WriteLog(-1, "鍙傛暟锛歕r\n" + requestJson);
+ //Log鍑哄姏
+ string errorMsg = "鎺ュ彛璁块棶澶辫触鈽咃細App/GetSingleHomeGatewayPagger " + statuCode + "\r\n";
+ errorMsg += "鍙傛暟锛歕r\n" + requestJson;
+ Shared.Phone.UserCenter.HdlLogLogic.Current.WriteLog(-1, errorMsg);
+ return;
}
var responseData = jobject["ResponseData"];
@@ -3323,10 +3336,12 @@
/// <param name="brokerName">Broker name.</param>
public static async System.Threading.Tasks.Task StartRemoteMqtt()
{
- if (remoteMqttIsConnecting
- || !Shared.Common.Config.Instance.IsLogin
- || Shared.Common.Config.Instance.HomeId == ""
- || remoteIsConnected)
+ //杩藉姞锛氭病鏈夎繙绋嬭繛鎺ョ殑鏉冮檺
+ if (AllowRemoteCtrl == false
+ || remoteMqttIsConnecting
+ || !Shared.Common.Config.Instance.IsLogin
+ || Shared.Common.Config.Instance.HomeId == ""
+ || remoteIsConnected)
{
return;
}
@@ -3444,6 +3459,12 @@
if (result != null)
{
var jobject = Newtonsoft.Json.Linq.JObject.Parse(Encoding.UTF8.GetString(result));
+ if (jobject["StateCode"].ToString() == "NotAllowRemoteCtrl")
+ {
+ //娌℃湁杩滅▼杩炴帴鐨勬潈闄�
+ AllowRemoteCtrl = false;
+ return;
+ }
var responseData = jobject["ResponseData"];
if (responseData != null)
{
@@ -3496,7 +3517,8 @@
{
localIsConnected = false;
DebugPrintLog($"Local涓诲姩鏂紑_{s}");
- await localMqttClient.DisconnectAsync(new MQTTnet.Client.Disconnecting.MqttClientDisconnectOptions { }, CancellationToken.None);
+ //await localMqttClient.DisconnectAsync(new MQTTnet.Client.Disconnecting.MqttClientDisconnectOptions { }, CancellationToken.None);
+ await localMqttClient.DisconnectAsync();
}
}
catch (Exception ex)
@@ -3516,7 +3538,8 @@
{
remoteIsConnected = false;
DebugPrintLog($"Remote涓诲姩鏂紑_{s}");
- await RemoteMqttClient.DisconnectAsync(new MQTTnet.Client.Disconnecting.MqttClientDisconnectOptions { }, CancellationToken.None);
+ //await RemoteMqttClient.DisconnectAsync(new MQTTnet.Client.Disconnecting.MqttClientDisconnectOptions { }, CancellationToken.None);
+ await RemoteMqttClient.DisconnectAsync();
}
}
catch(Exception e) {
@@ -4344,7 +4367,6 @@
}
}
#endregion
- DebugPrintLog("缃戝叧杩斿洖鏁版嵁閫氱煡");
}
catch (Exception ex)
{
--
Gitblit v1.8.0