From 365eadb33ee86b05ac74d408025d102a758c2efd Mon Sep 17 00:00:00 2001 From: 陈嘉乐 <cjl@hdlchina.com.cn> Date: 星期五, 10 一月 2020 15:27:17 +0800 Subject: [PATCH] 2020-01-10 2020-01-10 1.修改切换本地和远程问题。 2.修改判断住宅网关方案。 3.其它优化修改。 --- Crabtree/SmartHome/UI/SimpleControl/EquipmentPublicClass.cs | 61 +++++++++++++++--------------- 1 files changed, 31 insertions(+), 30 deletions(-) diff --git a/Crabtree/SmartHome/UI/SimpleControl/EquipmentPublicClass.cs b/Crabtree/SmartHome/UI/SimpleControl/EquipmentPublicClass.cs index 34e3fad..f308fc1 100644 --- a/Crabtree/SmartHome/UI/SimpleControl/EquipmentPublicClass.cs +++ b/Crabtree/SmartHome/UI/SimpleControl/EquipmentPublicClass.cs @@ -31,10 +31,11 @@ #if wallon return; #endif - if (MainPage.LoginUser == null || !MainPage.LoginUser.IsLogin) { + if (MainPage.LoginUser == null || !MainPage.LoginUser.IsLogin || isConnectiong) { return; } + isConnectiong = true; new System.Threading.Thread (async () => { try { if (status == 0) { @@ -44,9 +45,7 @@ UserMiddle.btnLinkStatus.UnSelectedImagePath = MainPage.WiFiStatus; }); } else { - if (MainPage.LoginUser == null || !MainPage.LoginUser.IsLogin) { - return; - } + //Application.RunOnMainThread (() => { // if (UserMiddle.LinkStatusTip.BackgroundColor == SkinStyle.Current.DelColor) { // UserMiddle.LinkStatusTip.BackgroundColor = SkinStyle.Current.MainColor; @@ -58,13 +57,12 @@ obj.Split ('_') [1].ToString () == DeviceType.OnePortBus.ToString () || obj.Split ('_') [1].ToString () == DeviceType.RCU.ToString () || obj.Split ('_') [1].ToString () == DeviceType.SuperWireless.ToString () || - obj.Split ('_') [1].ToString () == DeviceType.OnePortWirelessFR.ToString ()); + obj.Split ('_') [1].ToString () == DeviceType.OnePortWirelessFR.ToString () || + obj.Split ('_') [1].ToString () == DeviceType.OnePortMqttFR.ToString()); }); bool canRemote = false; if (CommonPage.IsRemote) { - //await SmartHome.MqttCommon.DisConnectRemoteMqttClient (); - //await SmartHome.MqttCommon.StartCloudMqtt (); - + await SmartHome.MqttCommon.StartCloudMqtt (); SmartHome.MqttCommon.MqttRemoteSend (new byte [] { }, 3); } foreach (var gatewayFileName in gateWayList) { @@ -92,26 +90,27 @@ canRemote = false; var mac0 = CommonPage.byteToHex16 (result [5]) + "." + CommonPage.byteToHex16 (result [6]) + "." + CommonPage.byteToHex16 (result [7]) + "." + CommonPage.byteToHex16 (result [8]) + "." + CommonPage.byteToHex16 (result [9]) + "." + CommonPage.byteToHex16 (result [10]) + "." + CommonPage.byteToHex16 (result [11]) + "." + CommonPage.byteToHex16 (result [12]); if (common.MAC == mac0) { + CommonPage.IsRemote = false; //var gatewayBytes = Control.ControlBytesSendHasReturn (Command.ReadGateWayModelInfo, common.SubnetID, common.DeviceID, new byte [] { }); - #region - control.Send (new Target () { - IPEndPoint = new System.Net.IPEndPoint (System.Net.IPAddress.Parse (new Net.NetWiFi ().BroadcastIpAddress.ToString ()), 6000), - Command = Command.ReadGateWayModelInfo, - SubnetID = common.SubnetID, - DeviceID = common.DeviceID, - AddData = new byte [] { }, - }, SendCount.Three, true,true); - var gatewayBytes = control.UsefulBytes; - #endregion - if (gatewayBytes != null) { - common.Remote_GroupName = CommonPage.MyEncodingGB2312.GetString (gatewayBytes, 1, 20).Trim ('\0'); - common.Remote_ProjectName = CommonPage.MyEncodingGB2312.GetString (gatewayBytes, 21, 20).Trim ('\0'); - common.Remote_UserName = CommonPage.MyEncodingGB2312.GetString (gatewayBytes, 41, 8).Trim ('\0'); - common.Remote_Password = CommonPage.MyEncodingGB2312.GetString (gatewayBytes, 49, 8).Trim ('\0'); - var requestJson2 = @"{'Token':'" + MainPage.LoginUser.LoginTokenString + "','MAC':'" + common.MAC + "','Password':'" + common.Remote_Password + "'}"; - var revertObj2 = MainPage.RequestHttps ("UpdateRemoteSwitchPassword", requestJson2, true, false); - return; - } + //#region + //control.Send (new Target () { + // IPEndPoint = new System.Net.IPEndPoint (System.Net.IPAddress.Parse (new Net.NetWiFi ().BroadcastIpAddress.ToString ()), 6000), + // Command = Command.ReadGateWayModelInfo, + // SubnetID = common.SubnetID, + // DeviceID = common.DeviceID, + // AddData = new byte [] { }, + //}, SendCount.Three, true,true); + //var gatewayBytes = control.UsefulBytes; + //#endregion + //if (gatewayBytes != null) { + //common.Remote_GroupName = CommonPage.MyEncodingGB2312.GetString (gatewayBytes, 1, 20).Trim ('\0'); + //common.Remote_ProjectName = CommonPage.MyEncodingGB2312.GetString (gatewayBytes, 21, 20).Trim ('\0'); + //common.Remote_UserName = CommonPage.MyEncodingGB2312.GetString (gatewayBytes, 41, 8).Trim ('\0'); + //common.Remote_Password = CommonPage.MyEncodingGB2312.GetString (gatewayBytes, 49, 8).Trim ('\0'); + //var requestJson2 = @"{'Token':'" + MainPage.LoginUser.LoginTokenString + "','MAC':'" + common.MAC + "','Password':'" + common.Remote_Password + "'}"; + //var revertObj2 = MainPage.RequestHttps ("UpdateRemoteSwitchPassword", requestJson2, true, false); + //return; + //} Application.RunOnMainThread (() => { MainPage.WiFiStatus = "CrabtreeAdd/WiFi.png"; UserMiddle.btnLinkStatus.UnSelectedImagePath = MainPage.WiFiStatus; @@ -129,9 +128,11 @@ } } if (canRemote && !CommonPage.IsRemote) { - if (!string.IsNullOrEmpty (UserConfig.Instance.CurrentRegion.MAC)) { - Shared.SimpleControl.CommonPage.IsRemote = true; - await SmartHome.MqttCommon.StartCloudMqtt (); + if (UserConfig.Instance.CheckHomeGateways ()) { + if (!string.IsNullOrEmpty (UserConfig.Instance.CurrentRegion.HomeGateways[0].GatewayUniqueId)) { + Shared.SimpleControl.CommonPage.IsRemote = true; + await SmartHome.MqttCommon.StartCloudMqtt (); + } } } } -- Gitblit v1.8.0