| | |
| | | { |
| | | public class GuideSettingGateway : FrameLayout |
| | | { |
| | | |
| | | static byte TYPEStandardMQTT = 5; |
| | | static byte TYPEHdlMQTT = 4; |
| | | static GuideSettingGateway curView; |
| | |
| | | this.AddChidren (myLoading); |
| | | //myLoading.Start ("点击屏幕关闭配频模式"); |
| | | myLoading.Start ("Searching, Please touch the here to exit the searching mode."); |
| | | //myLoading.Start ("Waiting for new device, Please touch the here to exit the waiting mode."); |
| | | |
| | | this.AddChidren (btnCloseLoading); |
| | | } |
| | | }); |
| | |
| | | }) { IsBackground = true }.Start (); |
| | | } |
| | | |
| | | ///// <summary> |
| | | ///// 2020-02-11 |
| | | ///// 搜索重复次数 由4次增加为6次 |
| | | ///// </summary> |
| | | //static readonly int READ_COUNT = 6; |
| | | /// <summary> |
| | | /// 读取设备 |
| | | /// </summary> |
| | |
| | | CommonPage.DeviceList.Clear (); |
| | | CommonPage.searchTotal = 0; |
| | | //如果两次都没有数据反馈,就不读取 |
| | | int readCount = 4; |
| | | //2020 - 02 - 11搜索重复次数 由4次增加为6次 |
| | | int readCount = 6; |
| | | while (0 < readCount) { |
| | | readCount--; |
| | | var ms = new System.IO.MemoryStream (); |
| | |
| | | System.Threading.Thread.Sleep (1000); |
| | | //如果数量不相等,就重置次数 |
| | | if (tempCount != CommonPage.DeviceList.Count) { |
| | | readCount = 4; |
| | | readCount = 6; |
| | | } |
| | | } |
| | | CommonPage.DeviceList = CommonPage.DeviceList.FindAll ((obj) => { return obj != null && obj.SubnetID == gatewayDeicve.SubnetID; }); |
| | |
| | | var mobytes = Control.ControlBytesSendHasReturn (Command.SetGateWayModelInternetInfo, gatewayDeicve.SubnetID, gatewayDeicve.DeviceID, serverIPBytes); |
| | | if (mobytes == null) { |
| | | Application.RunOnMainThread (() => { |
| | | new Alert ("", Language.StringByID (R.MyInternationalizationString.TipEquipmentNotOnline), |
| | | new Alert ("", ErrorCode.GatewayNoResponse, |
| | | Language.StringByID (R.MyInternationalizationString.Close)).Show (); |
| | | }); |
| | | } else if (mobytes [0] == 0xF5) { |
| | |
| | | var bindReginIdStatus = Control.ControlBytesSendHasReturn (Command.Write_APP_Data_STORE_1D5E_CMD, gatewayDeicve.SubnetID, gatewayDeicve.DeviceID, currentRegionIdBytes); |
| | | if (bindReginIdStatus == null) { |
| | | Application.RunOnMainThread (() => { |
| | | new Alert ("", Language.StringByID (R.MyInternationalizationString.TipEquipmentNotOnline), Language.StringByID (R.MyInternationalizationString.Close)).Show (); |
| | | new Alert ("", ErrorCode.GatewayNoResponse, Language.StringByID (R.MyInternationalizationString.Close)).Show (); |
| | | }); |
| | | return; |
| | | } else if (bindReginIdStatus [0] != 0xF8) { |
| | |
| | | byte [] gatewayBytes = null; |
| | | string [] strServerIP = (MainPage.SeviceIP).Split ('.'); |
| | | string [] strServerIP1 = (MainPage.SeviceIP).Split ('.'); |
| | | MainPage.Loading.Start ("Configuring device..."); |
| | | MainPage.Loading.Start ("Configuring gateway..."); |
| | | System.Threading.Tasks.Task.Run (() => { |
| | | try { |
| | | |
| | |
| | | } catch (Exception ex) { |
| | | Console.WriteLine (ex.Message); |
| | | Application.RunOnMainThread (() => { |
| | | new Alert ("", Language.StringByID (R.MyInternationalizationString.OperationFailed), Language.StringByID (R.MyInternationalizationString.Close)).Show (); |
| | | //修改网关连接模式失败 |
| | | new Alert ("", "Failed to modify gateway connection mode!", Language.StringByID (R.MyInternationalizationString.Close)).Show (); |
| | | }); |
| | | bool canRemove = false; |
| | | } finally { |
| | |
| | | |
| | | byte [] backBytes = Control.ControlBytesSendHasReturn (Command.SetGateWayAdminInfo, gatewayDeicve.SubnetID, gatewayDeicve.DeviceID, adminBytes); |
| | | |
| | | return CheckIsSuccessfulWithBytes (backBytes); |
| | | return CheckIsSuccessfulWithBytes (backBytes, "Failed to modify gateway administrator information!"); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// </summary> |
| | | /// <param name="backBytes"></param> |
| | | /// <returns></returns> |
| | | private bool CheckIsSuccessfulWithBytes (byte [] backBytes) |
| | | private bool CheckIsSuccessfulWithBytes (byte [] backBytes, string errorStr = "Modify gateway configuration failed!") |
| | | { |
| | | if (backBytes == null) { |
| | | Application.RunOnMainThread (() => { |
| | | new Alert ("", Language.StringByID (R.MyInternationalizationString.TipEquipmentNotOnline), |
| | | new Alert ("", ErrorCode.GatewayNoResponse, |
| | | Language.StringByID (R.MyInternationalizationString.Close)).Show (); |
| | | }); |
| | | return false; |
| | |
| | | return true; |
| | | } else { |
| | | Application.RunOnMainThread (() => { |
| | | new Alert ("", Language.StringByID (R.MyInternationalizationString.OperationFailed), |
| | | new Alert ("", errorStr, |
| | | Language.StringByID (R.MyInternationalizationString.Close)).Show (); |
| | | }); |
| | | return false; |
| | |
| | | var bindReginIdStatus = Control.ControlBytesSendHasReturn (Command.Write_APP_Data_STORE_1D5E_CMD, gatewayDeicve.SubnetID, gatewayDeicve.DeviceID, sendBytes); |
| | | if (bindReginIdStatus == null) { |
| | | Application.RunOnMainThread (() => { |
| | | new Alert ("", Language.StringByID (R.MyInternationalizationString.TipEquipmentNotOnline), Language.StringByID (R.MyInternationalizationString.Close)).Show (); |
| | | new Alert ("", ErrorCode.GatewayNoResponse, Language.StringByID (R.MyInternationalizationString.Close)).Show (); |
| | | }); |
| | | return; |
| | | } else if (bindReginIdStatus [0] != 0xF8) { |
| | |
| | | void BindGatewaysNew () |
| | | { |
| | | Application.RunOnMainThread (() => { |
| | | MainPage.Loading.Start ("Gateway setting succeeded,data up.Please wait..."); |
| | | MainPage.Loading.Start ("Gateway setting succeeded,data up. Please wait..."); |
| | | }); |
| | | IO.FileUtils.SaveEquipmentMessage (gatewayDeicve); |
| | | var gatewayMAC = gatewayDeicve.MAC.Replace (".", ""); |