From a93db4940a37fd73a37dd9b237c16e744e36f9ea Mon Sep 17 00:00:00 2001 From: wxr <464027401@qq.com> Date: 星期二, 30 八月 2022 10:24:45 +0800 Subject: [PATCH] 迁移升级网关之后修改网关子网号 --- Crabtree/SmartHome/UI/SimpleControl/Phone/Register/MigrationServer.cs | 63 +++++++++++++++++++++---------- 1 files changed, 42 insertions(+), 21 deletions(-) diff --git a/Crabtree/SmartHome/UI/SimpleControl/Phone/Register/MigrationServer.cs b/Crabtree/SmartHome/UI/SimpleControl/Phone/Register/MigrationServer.cs index aaf6234..fb2a5fb 100644 --- a/Crabtree/SmartHome/UI/SimpleControl/Phone/Register/MigrationServer.cs +++ b/Crabtree/SmartHome/UI/SimpleControl/Phone/Register/MigrationServer.cs @@ -163,14 +163,12 @@ #if DEBUG - //SetGateWayMqttUrlAddress (1, 0); - //WriteSecretKey (1, 0, new byte [] {1,1,2,3,2,3,4,5,2,3,5,6 }); - //CheckGateway (); - //var newHomeId = Home2New (); - //if (newHomeId == "") { } else { } - //Account2New (etPwd.Text.Trim()); - //return; + + var moveAccontResult = Account2New ("12345678"); + var newHomeId = Home2New (); + //杩佺Щ缃戝叧 + var moveGatewayResult = Gateway2New ("4D59383553502243", newHomeId, 0); #endif if (etPwd.Text.Trim() == "") { @@ -567,18 +565,18 @@ btnTipMsg.TextColor = SkinStyle.Current.TextColor; }); result = 100; - } else if (!visionString.Contains ("Ind_V02.35U_2019/06/25")) {//鐩墠鍙厑璁稿崌绾ц繖涓浐浠剁殑缃戝叧 - Application.RunOnMainThread (() => { - btnTipTitle.Text = "The gateway does not support automatic migration. Please contact technical support."; - btnTipTitle.Height = Application.GetRealHeight (150); - btnTipTitle.TextColor = SkinStyle.Current.DelColor; - btnTipMsg.Text = ""; - etPwd.Visible = false; - loading.Hide (); - btnSave.Visible = false; - btnClose.Width = Application.GetRealWidth (500); - }); - return; + //} else if (!visionString.Contains ("Ind_V02.35U_2019/06/25")) {//鐩墠鍙厑璁稿崌绾ц繖涓浐浠剁殑缃戝叧 + // Application.RunOnMainThread (() => { + // btnTipTitle.Text = "The gateway does not support automatic migration. Please contact technical support."; + // btnTipTitle.Height = Application.GetRealHeight (150); + // btnTipTitle.TextColor = SkinStyle.Current.DelColor; + // btnTipMsg.Text = ""; + // etPwd.Visible = false; + // loading.Hide (); + // btnSave.Visible = false; + // btnClose.Width = Application.GetRealWidth (500); + // }); + // return; } else { Application.RunOnMainThread (() => { btnTipMsg.Text = "Upgrading gateway."; @@ -638,8 +636,9 @@ } } } - - + //閲嶆柊璁剧疆涓�涓嬪瓙缃戝彿 + SetSubnetId (common); + System.Threading.Thread.Sleep (1000); if (result == 100) { @@ -933,6 +932,28 @@ } /// <summary> + /// 璁剧疆瀛愮綉鍙� + /// </summary> + /// <param name="gatewayDevice"></param> + private void SetSubnetId (GatewayBase gatewayDevice) + { + string [] macAddress = gatewayDevice.MAC.Split ('.'); + byte [] Musics = new byte [10]; + for (int i = 0; i < macAddress.Length; i++) { + Musics [i] = Convert.ToByte (macAddress [i], 16); + } + try { + Musics [8] = Convert.ToByte (Convert.ToInt32 (gatewayDevice.SubnetID)); + if (Musics [8] < 0 || Musics [8] > 255) { + throw new Exception (); + } + } catch { + return; + } + Control.ControlBytesSend (Command.SetDeviceSubnetID, gatewayDevice.SubnetID, gatewayDevice.DeviceID, Musics); + } + + /// <summary> /// 璁惧缃戝叧寮�鍚繙绋� /// </summary> private bool SetGatewayRemote(byte subnetId, byte deviceId) -- Gitblit v1.8.0