| | |
| | | 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"); |
| | | Alert confirmAlert1 = new Alert ("", "If not all the gateways are in the list,you can search again.", "Close", "Search again"); |
| | | Alert wrongPasswordAlert = new Alert ("", ErrorCode.GatewayPasswordError, "Close", "Search again"); |
| | | |
| | | void SearchGatewayList () |
| | | { |
| | | if (UserConfig.Instance.internetStatus == 0 || UserConfig.Instance.internetStatus == 1) { |
| | |
| | | #region 搜索设备 |
| | | ////2020-01-14 默认明文开始搜索 |
| | | UserConfig.Instance.IsLocalEncrypt = false; |
| | | UserConfig.Instance.EncryptedPasswordCorrect = true; |
| | | |
| | | CommonPage.LocalPhoneFindDevice = true; |
| | | CommonPage.RandomHigh = (byte)new Random ().Next (255); |
| | |
| | | if (CommonPage.GateWayList.Count == 0) { |
| | | MainPage.Loading.Hide (); |
| | | if (this != null && this.Parent != null) { |
| | | confirmAlert.Show (); |
| | | confirmAlert.ResultEventHandler += (ddf, ddd) => { |
| | | MainPage.Loading.Hide (); |
| | | if (ddd) { |
| | | SearchGatewayList (); |
| | | } |
| | | }; |
| | | ShowConfirmAlert (); |
| | | |
| | | |
| | | } |
| | | } else { |
| | | if (this != null && this.Parent != null) { |
| | |
| | | }) { IsBackground = true }.Start (); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 提示 |
| | | /// Please make sure gateway is powered up and comect to WiFi router. |
| | | /// 或者 |
| | | /// |
| | | /// </summary> |
| | | static void ShowConfirmAlert () { |
| | | if (UserConfig.Instance.IsLocalEncrypt) { |
| | | //密码检验正确 |
| | | if (UserConfig.Instance.EncryptedPasswordCorrect) { |
| | | |
| | | inView.confirmAlert.Show (); |
| | | inView.confirmAlert.ResultEventHandler += (ddf, ddd) => { |
| | | MainPage.Loading.Hide (); |
| | | if (ddd) { |
| | | inView.SearchGatewayList (); |
| | | } |
| | | }; |
| | | } else { |
| | | |
| | | |
| | | inView.wrongPasswordAlert.Show (); |
| | | inView.wrongPasswordAlert.ResultEventHandler += (ddf, ddd) => { |
| | | MainPage.Loading.Hide (); |
| | | if (ddd) { |
| | | inView.SearchGatewayList (); |
| | | } |
| | | }; |
| | | |
| | | } |
| | | } else { |
| | | inView.confirmAlert.Show (); |
| | | inView.confirmAlert.ResultEventHandler += (ddf, ddd) => { |
| | | MainPage.Loading.Hide (); |
| | | if (ddd) { |
| | | inView.SearchGatewayList (); |
| | | } |
| | | }; |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | //static byte [] AseKeyBytes; |
| | |
| | | }); |
| | | |
| | | bool goNext = false; |
| | | if (!UserConfig.Instance.IsLocalEncrypt) { |
| | | //如果没加密,走修改加密方法 |
| | | var result = SetGateWayLocalEncryption (common); |
| | | if (!result) { |
| | | MainPage.LoadingHide (); |
| | | return result;//修改失败 返回goNext false |
| | | } |
| | | //修改成功,设置本地为加密方式 |
| | | UserConfig.Instance.IsLocalEncrypt = true; |
| | | //string aseKeyStr = CommonPage.MyEncodingUTF8.GetString (AseKeyBytes); |
| | | //UserConfig.Instance.LocalEncryptKey = aseKeyStr; |
| | | System.Console.WriteLine ($"============>LocalEncryptKey 加密成功Key为:{UserConfig.Instance.LocalEncryptKey}"); |
| | | } |
| | | //if (!UserConfig.Instance.IsLocalEncrypt) { |
| | | // //如果没加密,走修改加密方法 |
| | | // var result = SetGateWayLocalEncryption (common); |
| | | // if (!result) { |
| | | // MainPage.LoadingHide (); |
| | | // return result;//修改失败 返回goNext false |
| | | // } |
| | | // //修改成功,设置本地为加密方式 |
| | | // UserConfig.Instance.IsLocalEncrypt = true; |
| | | // //string aseKeyStr = CommonPage.MyEncodingUTF8.GetString (AseKeyBytes); |
| | | // //UserConfig.Instance.LocalEncryptKey = aseKeyStr; |
| | | // System.Console.WriteLine ($"============>LocalEncryptKey 加密成功Key为:{UserConfig.Instance.LocalEncryptKey}"); |
| | | //} |
| | | |
| | | var backBytes = Control.ControlBytesSendHasReturn (Command.Read_APP_Data_STORE_1D5C_CMD, common.SubnetID, common.DeviceID, new byte [] { }); |
| | | |
| | |
| | | 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 (); |
| | | }); |
| | | } |
| | | |
| | | MainPage.LoadingHide (); |
| | | } |
| | | |
| | | if (backBytes.Length >= 37) { |
| | | //******************住宅ID string类型************* |
| | |
| | | //2020-01-12 |
| | | backIDStr = backIDStr.Replace ("\0", ""); |
| | | if (enable || backIDStr == UserConfig.Instance.CurrentRegion.Id || string.IsNullOrEmpty (backIDStr)) { |
| | | |
| | | |
| | | if (!UserConfig.Instance.IsLocalEncrypt) { |
| | | //如果没加密,走修改加密方法 |
| | | var result = SetGateWayLocalEncryption (common); |
| | | if (!result) { |
| | | MainPage.LoadingHide (); |
| | | return result;//修改失败 返回goNext false |
| | | } |
| | | //修改成功,设置本地为加密方式 |
| | | UserConfig.Instance.IsLocalEncrypt = true; |
| | | System.Console.WriteLine ($"============>LocalEncryptKey 加密成功Key为:{UserConfig.Instance.LocalEncryptKey}"); |
| | | } |
| | | goNext = true; |
| | | |
| | | } else { |
| | | Application.RunOnMainThread (() => { |
| | | new Alert ("", ErrorCode.UnableToBindGateway, Language.StringByID (R.MyInternationalizationString.Close)).Show (); |
| | | }); |
| | | UnableToBindGatewayAlertShow (); |
| | | } |
| | | } else { |
| | | Application.RunOnMainThread (() => { |
| | | new Alert ("", ErrorCode.GatewayVersionLow, Language.StringByID (R.MyInternationalizationString.Close)).Show (); |
| | | }); |
| | | } |
| | | MainPage.LoadingHide (); |
| | | return goNext; |
| | | |
| | | } |
| | | |
| | | |
| | | static void UnableToBindGatewayAlertShow () |
| | | { |
| | | if (inView == null) |
| | | return; |
| | | Application.RunOnMainThread (() => { |
| | | |
| | | //if (this != null && this.Parent != null) { |
| | | var alter = new Alert ("", ErrorCode.UnableToBindGateway, Language.StringByID (R.MyInternationalizationString.Close)); |
| | | alter.ResultEventHandler += (sender1, e1) => { |
| | | if (e1) { |
| | | if (inView == null) |
| | | return; |
| | | //重置为加密模式 |
| | | UserConfig.Instance.IsLocalEncrypt = true; |
| | | (inView.Parent as PageLayout).PageIndex -= 1; |
| | | } |
| | | }; |
| | | alter.Show (); |
| | | //} |
| | | |
| | | }); |
| | | |
| | | } |
| | | } |
| | | } |