From ac2ee45fadc64fe840bbba6264df3ca4622adb15 Mon Sep 17 00:00:00 2001 From: JLChen <551775569@qq.com> Date: 星期日, 12 一月 2020 16:06:13 +0800 Subject: [PATCH] 2020-01-12 1.优化修改。 --- Crabtree/SmartHome/UI/SimpleControl/Phone/Guide/GuideAddGateway.cs | 81 +++++++++++++++++++++++++++++++--------- 1 files changed, 62 insertions(+), 19 deletions(-) diff --git a/Crabtree/SmartHome/UI/SimpleControl/Phone/Guide/GuideAddGateway.cs b/Crabtree/SmartHome/UI/SimpleControl/Phone/Guide/GuideAddGateway.cs index 5345188..f8a1686 100644 --- a/Crabtree/SmartHome/UI/SimpleControl/Phone/Guide/GuideAddGateway.cs +++ b/Crabtree/SmartHome/UI/SimpleControl/Phone/Guide/GuideAddGateway.cs @@ -148,7 +148,7 @@ var title = new Button () { TextAlignment = TextAlignment.Center, - Text = home.RegionName, + Text = home.Name, TextColor = SkinStyle.Current.TextColor1, TextSize = 19, }; @@ -262,8 +262,11 @@ return (w.Split ('_') [0] == "Equipment") && (w.Split ('_') [2] == common.SubnetID.ToString ()); }); for (int k = 0; k < delFile.Count; k++) { - if (delFile [k].Contains (DeviceType.OnePortWirelessFR.ToString ()) || delFile [k].Contains (DeviceType.OnePortBus.ToString ()) || - delFile [k].Contains (DeviceType.RCU.ToString ()) || delFile [k].Contains (DeviceType.SuperWireless.ToString ())) { + if (delFile [k].Contains (DeviceType.OnePortWirelessFR.ToString ()) + || delFile [k].Contains (DeviceType.OnePortMqttFR.ToString ()) + || delFile [k].Contains (DeviceType.OnePortBus.ToString ()) + || delFile [k].Contains (DeviceType.RCU.ToString ()) + || delFile [k].Contains (DeviceType.SuperWireless.ToString ())) { continue; } IO.FileUtils.DeleteFile (delFile [k]); @@ -291,32 +294,68 @@ bool goNext = false; System.Threading.Tasks.Task.Run (() => { try { - if (common.Type == DeviceType.OnePortWirelessFR) { - var bingResidenceIdBytes = Control.ControlBytesSendHasReturn (Command.Read_APP_Data_STORE_1D5C_CMD, common.SubnetID, common.DeviceID, new byte [] { }); - if (bingResidenceIdBytes == null) { + if (common.Type == DeviceType.OnePortWirelessFR || common.Type == DeviceType.OnePortMqttFR) { + var backBytes = Control.ControlBytesSendHasReturn (Command.Read_APP_Data_STORE_1D5C_CMD, common.SubnetID, common.DeviceID, new byte [] { }); + if (backBytes == null) { Application.RunOnMainThread (() => { new Alert ("", "No response from gateway. Please make sure the gateway is online and its firmware is up to date.", Language.StringByID (R.MyInternationalizationString.Close)).Show (); }); } - int bingResideceId = 0; - for (int i = 0; i < bingResidenceIdBytes.Length; i++) { - bingResideceId += (int)(bingResidenceIdBytes [i] * Math.Pow (256, 3 - i)); - } - if (bingResideceId != UserConfig.Instance.CurrentRegion.RegionID && bingResideceId != 0) { -//#if DEBUG -// Control.ControlBytesSendHasReturn (Command.Write_APP_Data_STORE_1D5E_CMD, common.SubnetID, common.DeviceID, new byte [] { 0, 0, 0, 0 }); -//#endif - Application.RunOnMainThread (() => { - new Alert ("", "This gateway has been bound to a residence, please reset it before binding to another residence.", Language.StringByID (R.MyInternationalizationString.Close)).Show (); - }); + + + if (backBytes.Length >= 37) { + + //******************浣忓畢ID string绫诲瀷************* + bool enable = backBytes [0] == 0 ? false : true; + //杩斿洖浣忓畢ID 杞负string绫诲瀷 + string backIDStr = CommonPage.MyEncodingGB2312.GetString (backBytes, 1, 36).Trim ('\0'); + backIDStr = backIDStr.Replace ("每", ""); + //2020-01-12 + backIDStr = backIDStr.Replace ("\0", ""); + if (enable || backIDStr == UserConfig.Instance.CurrentRegion.Id || string.IsNullOrEmpty (backIDStr) ) { + goNext = true; + } else { + //#if DEBUG + // Control.ControlBytesSendHasReturn (Command.Write_APP_Data_STORE_1D5E_CMD, common.SubnetID, common.DeviceID, new byte [] { 0, 0, 0, 0 }); + //#endif + Application.RunOnMainThread (() => { + //new Alert ("", "This gateway has been bound to a residence, please reset it before binding to another residence.", Language.StringByID (R.MyInternationalizationString.Close)).Show (); + new Alert ("", ErrorCode.UnableToBindGateway, Language.StringByID (R.MyInternationalizationString.Close)).Show (); + + }); + } + + //******************浣忓畢ID int绫诲瀷************* + //bool enable = backBytes [32] == 0 ? false : true; + //int bingResideceId = 0; + ////杩斿洖浣忓畢ID 杞负string绫诲瀷 + //string backIDStr = CommonPage.MyEncodingGB2312.GetString (backBytes, 0, 32).Trim ('\0'); + + //bingResideceId = Utlis.StringToInt (backIDStr); + + //if (true || bingResideceId == UserConfig.Instance.CurrentRegion.RegionID || bingResideceId == 0) { + // goNext = true; + //} else { + // //#if DEBUG + // // Control.ControlBytesSendHasReturn (Command.Write_APP_Data_STORE_1D5E_CMD, common.SubnetID, common.DeviceID, new byte [] { 0, 0, 0, 0 }); + // //#endif + // Application.RunOnMainThread (() => { + // new Alert ("", "This gateway has been bound to a residence, please reset it before binding to another residence.", Language.StringByID (R.MyInternationalizationString.Close)).Show (); + // }); + //} + } else { - goNext = true; + Application.RunOnMainThread (() => { + new Alert ("", ErrorCode.GatewayVersionLow, Language.StringByID (R.MyInternationalizationString.Close)).Show (); + }); + //goNext = true; } + } else { goNext = true; } } catch (Exception ex) { - Console.WriteLine (ex.Message); + Console.WriteLine (ex.Message); } finally { Application.RunOnMainThread (() => { MainPage.Loading.Hide (); @@ -351,6 +390,10 @@ }; } } + + + + static bool inThisView = false; Alert checkInternetAlert = new Alert ("", "Your phone in not connected to WIFI network, please connet", "Close", "Search again"); Alert confirmAlert = new Alert ("", "Please make sure gateway is powered up and comect to WiFi router.", "Close", "Search again"); -- Gitblit v1.8.0