From cc8749fe1d158ee21670bde77fad237be2f0c416 Mon Sep 17 00:00:00 2001 From: JLChen <551775569@qq.com> Date: 星期五, 08 一月 2021 11:47:06 +0800 Subject: [PATCH] 2021-01-08 1.去掉无关文件 --- Crabtree/SmartHome/UI/SimpleControl/Phone/Guide/GuideSettingGateway.cs | 113 +++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 102 insertions(+), 11 deletions(-) diff --git a/Crabtree/SmartHome/UI/SimpleControl/Phone/Guide/GuideSettingGateway.cs b/Crabtree/SmartHome/UI/SimpleControl/Phone/Guide/GuideSettingGateway.cs index b95835f..bb7b93a 100644 --- a/Crabtree/SmartHome/UI/SimpleControl/Phone/Guide/GuideSettingGateway.cs +++ b/Crabtree/SmartHome/UI/SimpleControl/Phone/Guide/GuideSettingGateway.cs @@ -25,8 +25,11 @@ curView = this; myLoading = new Loading (); + myLoading.TextColor = 0xFFA9A9A9; + myLoading.LodingBackgroundColor = SkinStyle.Current.MainColor; + //#if __IOS__ - myLoading.LodingBackgroundColor = 0x00999999; + //myLoading.LodingBackgroundColor = 0x20999999; //#else // myLoading.LodingBackgroundColor = SkinStyle.Current.ViewColor; //#endif @@ -36,6 +39,8 @@ myLoading.Hide (); btnCloseLoading.RemoveFromParent (); WirelessConfig (new byte [] { 1 });//close + //2020-07-02 鍏抽棴鑷姩鎼滅储绾跨▼ + StopSearchDeviceThead (); if (needRefresh) { needRefresh = false; SearchDeviceList (); @@ -50,6 +55,7 @@ curView = null; addedCommon.Clear (); BackgroundColor = SkinStyle.Current.MainColor; + //StopSearchDeviceThead (); base.RemoveFromParent (); } @@ -94,8 +100,8 @@ }; var btnSearch = new Button () { - Width = Application.GetRealWidth (75), - Height = Application.GetRealHeight (75), + Width = Application.GetMinRealAverage (75), + Height = Application.GetMinRealAverage (75), X = Application.GetRealWidth (520), Y = Application.GetRealHeight (10), UnSelectedImagePath = "Item/Refresh.png", @@ -243,14 +249,17 @@ if (gatewayDeicve.Type == DeviceType.OnePortWirelessFR || gatewayDeicve.Type == DeviceType.OnePortMqttFR) { Control.ControlBytesSend (Command.GotoConfigMode, gatewayDeicve.SubnetID, gatewayDeicve.DeviceID, new byte [] { }); //new Alert ("", "缃戝叧宸茬粡杩涘叆閰嶉妯″紡锛岃鎵嬪姩鏂拌澶囪繘鍏ラ厤棰戞ā寮忋��", "Close").Show (); - new Alert ("", "Searching for new devices, Please make sure all new devices are in configuration mode.", "OK").Show (); + new Alert ("", ErrorCode.SearchingForNewDevices, "OK").Show (); this.AddChidren (myLoading); //myLoading.Start ("鐐瑰嚮灞忓箷鍏抽棴閰嶉妯″紡"); - myLoading.Start ("Searching, Please touch the here to exit the searching mode."); + myLoading.Start (ErrorCode.SearchingExitTheSearchingMode); //myLoading.Start ("Waiting for new device, Please touch the here to exit the waiting mode."); this.AddChidren (btnCloseLoading); + + //2020-07-02 缃戝叧閰嶉妯″紡鏃讹紝寮�鍚嚜鍔ㄦ悳绱㈢嚎绋� + StartSearchDeviceThead (); } }); }); @@ -942,7 +951,7 @@ //var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject (new EditMACByHomeId { RegionID = UserConfig.Instance.CurrentRegion.Id, MAC = gatewayMAC, IsReBind = true }); var respone = MainPage.RequestHttps (API.BindMac, requestJson, urlHead); - if (respone.StateCode.ToUpper () != "SUCCESS") { + if (respone.StateCode.ToUpper () != StateCode.SUCCESS) { GetNowHomeGatewayAfterBindMacFailed ();//2020-01-11 Application.RunOnMainThread (() => { new Alert ("", $"Failed to bind Mac address! {ErrorCode.Reason }{respone.StateCode}", Language.StringByID (R.MyInternationalizationString.Close)).Show (); @@ -1018,7 +1027,7 @@ // //var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject (new EditMACByHomeId { RegionID = UserConfig.Instance.CurrentRegion.Id, MAC = gatewayMAC, IsReBind = true }); // var respone = MainPage.RequestHttps (API.UpdateMac, requestJson, urlHead); - // if (respone.StateCode.ToUpper () != "SUCCESS") { + // if (respone.StateCode.ToUpper () != StateCode.SUCCESS) { // GetNowHomeGatewayAfterBindMacFailed ();//2020-01-11 // Application.RunOnMainThread (() => { // new Alert ("", "Failed to update Mac address, gateway binding failed!", Language.StringByID (R.MyInternationalizationString.Close)).Show (); @@ -1049,7 +1058,7 @@ // //var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject (new EditMACByHomeId { RegionID = UserConfig.Instance.CurrentRegion.Id, MAC = gatewayMAC, IsReBind = true }); // var respone = MainPage.RequestHttps (API.BindGatewayToHome, requestJson, urlHead); - // if (respone.StateCode.ToUpper () != "SUCCESS" && respone.StateCode != "BindGatewaysExists") { + // if (respone.StateCode.ToUpper () != StateCode.SUCCESS && respone.StateCode != "BindGatewaysExists") { // GetNowHomeGatewayAfterBindMacFailed ();//2020-01-11 // Application.RunOnMainThread (() => { // new Alert ("", "Failed to bind Mac address, gateway binding failed!", Language.StringByID (R.MyInternationalizationString.Close)).Show (); @@ -1086,7 +1095,7 @@ var requestJson3 = Newtonsoft.Json.JsonConvert.SerializeObject (requestObj3); var revertObj3 = MainPage.RequestHttps (API.GetSingleHomeGatewayPagger, requestJson3, urlHead); - if (revertObj3.StateCode.ToUpper () == "SUCCESS") { + if (revertObj3.StateCode.ToUpper () == StateCode.SUCCESS) { var infoResult = Newtonsoft.Json.JsonConvert.DeserializeObject<GetGatewayResult> (revertObj3.ResponseData.ToString ()); //2020-01-11 UserConfig.Instance.SetNowHomeGateways (infoResult.PageData); @@ -1095,6 +1104,88 @@ } + + #region 2020-07-02 + /// <summary> + /// 瀹氭椂鎼滅储璁惧绾跨▼ + /// </summary> + Thread searchDeviceThead; + bool bStartSearch; + + /// <summary> + /// 2020-07-02 + /// 缃戝叧閰嶉妯″紡鏃讹紝寮�鍚嚜鍔ㄦ悳绱㈢嚎绋� + /// </summary> + void StartSearchDeviceThead () + { + StopSearchDeviceThead (); + CommonPage.LocalPhoneFindDevice = true; + CommonPage.FindGatewayChilren = true; + CommonPage.RandomHigh = (byte)new Random ().Next (255); + CommonPage.RandomLow = (byte)new Random ().Next (255); + + bStartSearch = true; + searchDeviceThead = new Thread ((obj) => { + while (bStartSearch) { + try { + //瀹氭椂4S + Thread.Sleep (4000); + + var ms = new System.IO.MemoryStream (); + ms.WriteByte (CommonPage.RandomHigh); + ms.WriteByte (CommonPage.RandomLow); + + var list = CommonPage.DeviceList; + int tempCount = list.Count; + string s = ";"; + for (int i = 0; i < list.Count; i++) { + Common common = list [i]; + if (common.SubnetID != gatewayDeicve.SubnetID) + continue; + if (s.Contains (";" + common.SubnetID.ToString () + ":" + common.DeviceID.ToString ())) + continue; + s += common.SubnetID.ToString () + ":" + common.DeviceID.ToString () + ";"; + ms.WriteByte (common.SubnetID); + ms.WriteByte (common.DeviceID); + } + Utlis.WriteLine ("SearchDeviceThead鎼滅储闈炵綉鍏宠澶囷紝缃戠粶鍦板潃鏄�:" + CommonPage.EndPoint.ToString ()); + var control = new Control (); + control.Send (new Target () { + IPEndPoint = CommonPage.EndPoint, + Command = Command.ReadDeviceModul, + SubnetID = gatewayDeicve.SubnetID, + DeviceID = 0xFF, + AddData = ms.ToArray () + }, SendCount.Zero, false); + + ms.Close (); + + } catch { + + } + } + }); + searchDeviceThead.Start (); + + + Utlis.WriteLine ("----StartSearchDeviceThead----"); + } + + /// <summary> + /// 鏆傚仠鎼滅储璁惧绾跨▼ + /// </summary> + void StopSearchDeviceThead () + { + CommonPage.LocalPhoneFindDevice = false; + CommonPage.FindGatewayChilren = false; + bStartSearch = false; + if (searchDeviceThead != null) + searchDeviceThead.Abort (); + + Utlis.WriteLine ("----StopSearchDeviceThead----"); + + } + #endregion ///// <summary> ///// 鏌ヨ褰撳墠浣忓畢 缃戝叧鍒楄〃 @@ -1117,7 +1208,7 @@ // //var requestObj3 = new GatewayByRegionListObj () { RegionID = UserConfig.Instance.CurrentRegion.Id }; // var requestJson3 = Newtonsoft.Json.JsonConvert.SerializeObject (requestObj3); // var revertObj3 = MainPage.RequestHttps (API.GetSingleHomeGatewayPagger, requestJson3, urlHead); - // if (revertObj3.StateCode.ToUpper () == "SUCCESS") { + // if (revertObj3.StateCode.ToUpper () == StateCode.SUCCESS) { // var infoResult = Newtonsoft.Json.JsonConvert.DeserializeObject<GetGatewayResult> (revertObj3.ResponseData.ToString ()); // var responseGatewayDataObj = infoResult.PageData; // if (responseGatewayDataObj != null && responseGatewayDataObj.Count > 0) { @@ -1235,7 +1326,7 @@ // //Room.InitAllRoom (); //} - + ///// <summary> ///// 淇敼URL -- Gitblit v1.8.0