From be95e839f40eb3ddf64706b60cba6dfcf4fad5e5 Mon Sep 17 00:00:00 2001 From: JLChen <551775569@qq.com> Date: 星期五, 03 四月 2020 14:31:44 +0800 Subject: [PATCH] 2020-04-03 1.去掉登录前ping百度域名的网络监测。 --- Crabtree/SmartHome/UI/SimpleControl/Phone/Guide/GuideSettingGateway.cs | 117 +++++++++++++++++++++++++++++++--------------------------- 1 files changed, 63 insertions(+), 54 deletions(-) diff --git a/Crabtree/SmartHome/UI/SimpleControl/Phone/Guide/GuideSettingGateway.cs b/Crabtree/SmartHome/UI/SimpleControl/Phone/Guide/GuideSettingGateway.cs index 46bbfd3..b95835f 100644 --- a/Crabtree/SmartHome/UI/SimpleControl/Phone/Guide/GuideSettingGateway.cs +++ b/Crabtree/SmartHome/UI/SimpleControl/Phone/Guide/GuideSettingGateway.cs @@ -146,11 +146,11 @@ { if (gatewayDeicve.Type == DeviceType.OnePortMqttFR) { - Console.WriteLine ("Assign OnePortMqttFR锛孒DL MQTT"); + Utlis.WriteLine ("Assign OnePortMqttFR锛孒DL MQTT"); //RemoteSetting (); RemoteSettingWithHDLMQTT (); } else { - Console.WriteLine ("Assign OnePortWirelessFR"); + Utlis.WriteLine ("Assign OnePortWirelessFR"); RemoteSettingWithOldDevice (); //RemoteSettingWithMQTT (); } @@ -195,7 +195,7 @@ if (common.Type == DeviceType.MusicModel) continue; if (common.isMixBox) { - Console.WriteLine ("IsMixBox"); + Utlis.WriteLine ("IsMixBox"); continue; } countDevcie++; @@ -463,7 +463,7 @@ btnDelDevice.Parent.RemoveFromParent (); }); } catch (Exception ex) { - Console.WriteLine (ex.Message); + Utlis.WriteLine (ex.Message); } finally { Application.RunOnMainThread (() => { MainPage.Loading.Hide (); @@ -501,7 +501,7 @@ // } // } // } catch (Exception ex) { - // Console.WriteLine ("Cinfig Read Device Loop Info " + ex.Message); + // Utlis.WriteLine ("Cinfig Read Device Loop Info " + ex.Message); // } //}); } @@ -523,7 +523,7 @@ //杩欓噷鎼滅储璁惧锛岀洿鍒板畬鎴愬氨閫�鍑� readDevice (); } catch (Exception ex) { - Console.WriteLine (ex.Message); + Utlis.WriteLine (ex.Message); } Application.RunOnMainThread (action); }) { IsBackground = true }.Start (); @@ -568,7 +568,7 @@ ms.WriteByte (common.SubnetID); ms.WriteByte (common.DeviceID); } - Console.WriteLine ("鎼滅储闈炵綉鍏宠澶囷紝缃戠粶鍦板潃鏄�:" + CommonPage.EndPoint.ToString ()); + Utlis.WriteLine ("鎼滅储闈炵綉鍏宠澶囷紝缃戠粶鍦板潃鏄�:" + CommonPage.EndPoint.ToString ()); var control = new Control (); control.Send (new Target () { IPEndPoint = CommonPage.EndPoint, @@ -707,7 +707,7 @@ BindGatewaysNew (); } } catch (Exception ex) { - Console.WriteLine (ex.Message); + Utlis.WriteLine (ex.Message); Application.RunOnMainThread (() => { new Alert ("", Language.StringByID (R.MyInternationalizationString.OperationFailed), Language.StringByID (R.MyInternationalizationString.Close)).Show (); }); @@ -736,55 +736,25 @@ System.Threading.Tasks.Task.Run (() => { try { - //璇诲彇涓�绔彛浜ゆ崲鏈恒�佹棤绾跨綉鍏崇殑閰嶇疆淇℃伅 - gatewayBytes = Control.ControlBytesSendHasReturn (Command.ReadGateWayModelInfo, gatewayDeicve.SubnetID, gatewayDeicve.DeviceID, new byte [] { }); - - gatewayDeicve.Remote_GroupName = MainPage.LoginUser.AccountString;//UserConfig.Instance.CurrentRegion.RegionName; - gatewayDeicve.Remote_ProjectName = gatewayDeicve.MAC.Replace (".", "");//UserConfig.Instance.CurrentRegion.RegionName; - gatewayDeicve.Remote_UserName = "Admin"; - gatewayDeicve.Remote_Password = "c" + MainPage.LoginUser.ID; - //gatewayDeicve.Remote_Password = "85521566"; - byte [] ggn = new byte [20]; - byte [] b1 = CommonPage.MyEncodingGB2312.GetBytes (gatewayDeicve.Remote_GroupName); - gatewayDeicve.Remote_GroupName = CommonPage.MyEncodingGB2312.GetString (b1); - Array.Copy (b1, 0, ggn, 0, 20 < b1.Length ? 20 : b1.Length); - - byte [] gpn = new byte [20]; - byte [] b2 = CommonPage.MyEncodingGB2312.GetBytes (gatewayDeicve.Remote_ProjectName); - Array.Copy (b2, 0, gpn, 0, 20 < b2.Length ? 20 : b2.Length); - - byte [] gun = new byte [8]; - byte [] b3 = CommonPage.MyEncodingGB2312.GetBytes (gatewayDeicve.Remote_UserName); - Array.Copy (b3, 0, gun, 0, 8 < b3.Length ? 8 : b3.Length); - - byte [] gpw = new byte [8]; - byte [] b4 = CommonPage.MyEncodingGB2312.GetBytes (gatewayDeicve.Remote_Password); - Array.Copy (b4, 0, gpw, 0, 8 < b4.Length ? 8 : b4.Length); - - - gatewayBytes [0] = TYPEHdlMQTT;//HDL MQTT - Array.Copy (ggn, 0, gatewayBytes, 1, 20); - Array.Copy (gpn, 0, gatewayBytes, 21, 20); - Array.Copy (gun, 0, gatewayBytes, 41, 8); - Array.Copy (gpw, 0, gatewayBytes, 49, 8); - //1.淇敼鐢ㄦ埛鍚嶄俊鎭� - Control.ControlBytesSend (Command.SetGateWayModelInfo, gatewayDeicve.SubnetID, gatewayDeicve.DeviceID, gatewayBytes); - ////2.璇诲彇涓�娆$鐞嗕俊鎭� - //byte [] adminBytes = Control.ControlBytesSendHasReturn (Command.ReadGateWayAdminInfo, gatewayDeicve.SubnetID, gatewayDeicve.DeviceID, new byte [] { }); - ////3.淇敼绠$悊淇℃伅 - //if (SetGateWayAdminInfo (adminBytes)) { - // //4.鍐欓厤缃垚鍔熷悗涓嬩竴姝ユ搷浣� - // GatewaySettingSucceeded (); + ////璇诲彇涓�绔彛浜ゆ崲鏈恒�佹棤绾跨綉鍏崇殑閰嶇疆淇℃伅 + //gatewayBytes = Control.ControlBytesSendHasReturn (Command.ReadGateWayModelInfo, gatewayDeicve.SubnetID, gatewayDeicve.DeviceID, new byte [] { }); + //if (gatewayBytes == null) { + // //璇诲彇涓�绔彛浜ゆ崲鏈恒�佹棤绾跨綉鍏崇殑閰嶇疆淇℃伅澶辫触 + // new Alert ("", "Read gateway configuration failed!", "Close").Show (); + // return; //} - - //2.淇敼绠$悊淇℃伅 - if (SetGateWayAdminInfo ()) { - //3.鍐欓厤缃垚鍔熷悗涓嬩竴姝ユ搷浣� - GatewaySettingSucceeded (); + + //1.淇敼鐢ㄦ埛鍚嶄俊鎭� 鍜屼慨鏀硅繛鎺ユā寮� + if (SetGateWayModelInfo()) { + //2.淇敼绠$悊淇℃伅 + if (SetGateWayAdminInfo ()) { + //3.鍐欓厤缃垚鍔熷悗涓嬩竴姝ユ搷浣� + GatewaySettingSucceeded (); + } } } catch (Exception ex) { - Console.WriteLine (ex.Message); + Utlis.WriteLine (ex.Message); Application.RunOnMainThread (() => { //淇敼缃戝叧杩炴帴妯″紡澶辫触 new Alert ("", "Failed to modify gateway connection mode!", Language.StringByID (R.MyInternationalizationString.Close)).Show (); @@ -798,6 +768,40 @@ } }); //Room.InitAllRoom (); + } + + bool SetGateWayModelInfo () { + byte [] gatewayBytes = new byte [60]; + gatewayDeicve.Remote_GroupName = MainPage.LoginUser.AccountString;//UserConfig.Instance.CurrentRegion.RegionName; + gatewayDeicve.Remote_ProjectName = gatewayDeicve.MAC.Replace (".", "");//UserConfig.Instance.CurrentRegion.RegionName; + gatewayDeicve.Remote_UserName = "Admin"; + gatewayDeicve.Remote_Password = "c" + MainPage.LoginUser.ID; + //gatewayDeicve.Remote_Password = "85521566"; + byte [] ggn = new byte [20]; + byte [] b1 = CommonPage.MyEncodingGB2312.GetBytes (gatewayDeicve.Remote_GroupName); + gatewayDeicve.Remote_GroupName = CommonPage.MyEncodingGB2312.GetString (b1); + Array.Copy (b1, 0, ggn, 0, 20 < b1.Length ? 20 : b1.Length); + + byte [] gpn = new byte [20]; + byte [] b2 = CommonPage.MyEncodingGB2312.GetBytes (gatewayDeicve.Remote_ProjectName); + Array.Copy (b2, 0, gpn, 0, 20 < b2.Length ? 20 : b2.Length); + + byte [] gun = new byte [8]; + byte [] b3 = CommonPage.MyEncodingGB2312.GetBytes (gatewayDeicve.Remote_UserName); + Array.Copy (b3, 0, gun, 0, 8 < b3.Length ? 8 : b3.Length); + + byte [] gpw = new byte [8]; + byte [] b4 = CommonPage.MyEncodingGB2312.GetBytes (gatewayDeicve.Remote_Password); + Array.Copy (b4, 0, gpw, 0, 8 < b4.Length ? 8 : b4.Length); + + + gatewayBytes [0] = TYPEHdlMQTT;//HDL MQTT + Array.Copy (ggn, 0, gatewayBytes, 1, 20); + Array.Copy (gpn, 0, gatewayBytes, 21, 20); + Array.Copy (gun, 0, gatewayBytes, 41, 8); + Array.Copy (gpw, 0, gatewayBytes, 49, 8); + byte [] backBytes = Control.ControlBytesSendHasReturn (Command.SetGateWayModelInfo, gatewayDeicve.SubnetID, gatewayDeicve.DeviceID, gatewayBytes); + return CheckIsSuccessfulWithBytes (backBytes, "Failed to modify gateway connection mode."); } /// <summary> @@ -964,8 +968,13 @@ MainPage.LoginUser.LastTime = DateTime.Now; Application.RunOnMainThread (() => { bodyView.RemoveAll (); + //MainPage.WiFiStatus = "CrabtreeAdd/WiFi.png"; UserMiddle.Init (true); + MainPage.WiFiStatus = "CrabtreeAdd/WiFi.png"; + UserMiddle.btnLinkStatus.UnSelectedImagePath = MainPage.WiFiStatus; }); + + //Utlis.ShowAppLinkStatus (AppLinkStatus.WiFi); } @@ -1211,7 +1220,7 @@ // } // } catch (Exception ex) { - // Console.WriteLine (ex.Message); + // Utlis.WriteLine (ex.Message); // Application.RunOnMainThread (() => { // new Alert ("", Language.StringByID (R.MyInternationalizationString.OperationFailed), Language.StringByID (R.MyInternationalizationString.Close)).Show (); // }); -- Gitblit v1.8.0