From 60fea1a35f8bfd2eb1399cae05d853b93b3674f9 Mon Sep 17 00:00:00 2001 From: 陈嘉乐 <cjl@hdlchina.com.cn> Date: 星期五, 03 一月 2020 13:47:35 +0800 Subject: [PATCH] 2020-01-03 1.增加信mqtt网关设备类型支持。 2.住宅ID改为string类型。 --- Crabtree/SmartHome/UI/SimpleControl/Phone/Guide/GuideAddGateway.cs | 72 +++++++++++++++++++++++++++--------- 1 files changed, 54 insertions(+), 18 deletions(-) diff --git a/Crabtree/SmartHome/UI/SimpleControl/Phone/Guide/GuideAddGateway.cs b/Crabtree/SmartHome/UI/SimpleControl/Phone/Guide/GuideAddGateway.cs index 5345188..2f42b0b 100644 --- a/Crabtree/SmartHome/UI/SimpleControl/Phone/Guide/GuideAddGateway.cs +++ b/Crabtree/SmartHome/UI/SimpleControl/Phone/Guide/GuideAddGateway.cs @@ -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,61 @@ 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 >= 33) { + //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 (); + // }); + //} + + bool enable = backBytes [32] == 0 ? false : true; + //杩斿洖浣忓畢ID 杞负string绫诲瀷 + string backIDStr = CommonPage.MyEncodingGB2312.GetString (backBytes, 0, 32).Trim ('\0'); + if (enable || backIDStr == UserConfig.Instance.CurrentRegion.RegionID || 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 (); + }); + } + + } else { - goNext = true; + Application.RunOnMainThread (() => { + new Alert ("", "缃戝叧鍥轰欢鐗堟湰杩囦綆锛岃鍏堝崌绾э紒", 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 +383,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