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 | 50 ++++++++++++++++++++++++-------------------------- 1 files changed, 24 insertions(+), 26 deletions(-) diff --git a/Crabtree/SmartHome/UI/SimpleControl/EquipmentPublicClass.cs b/Crabtree/SmartHome/UI/SimpleControl/EquipmentPublicClass.cs index 337dd4e..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; @@ -63,9 +62,7 @@ }); 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) { @@ -93,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; -- Gitblit v1.8.0