| | |
| | | |
| | | var title = new Button () { |
| | | TextAlignment = TextAlignment.Center, |
| | | Text = home.RegionName, |
| | | Text = home.Name, |
| | | TextColor = SkinStyle.Current.TextColor1, |
| | | TextSize = 19, |
| | | }; |
| | |
| | | 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]); |
| | |
| | | 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 (); |
| | |
| | | }; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | 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"); |