From 365eadb33ee86b05ac74d408025d102a758c2efd Mon Sep 17 00:00:00 2001
From: 陈嘉乐 <cjl@hdlchina.com.cn>
Date: 星期五, 10 一月 2020 15:27:17 +0800
Subject: [PATCH] 2020-01-10 2020-01-10 1.修改切换本地和远程问题。 2.修改判断住宅网关方案。 3.其它优化修改。
---
Crabtree/SmartHome/UI/SimpleControl/Phone/Guide/GuideAddGateway.cs | 80 ++++++++++++++++++++++++++++++---------
1 files changed, 61 insertions(+), 19 deletions(-)
diff --git a/Crabtree/SmartHome/UI/SimpleControl/Phone/Guide/GuideAddGateway.cs b/Crabtree/SmartHome/UI/SimpleControl/Phone/Guide/GuideAddGateway.cs
index 5345188..85688bb 100644
--- a/Crabtree/SmartHome/UI/SimpleControl/Phone/Guide/GuideAddGateway.cs
+++ b/Crabtree/SmartHome/UI/SimpleControl/Phone/Guide/GuideAddGateway.cs
@@ -148,7 +148,7 @@
var title = new Button () {
TextAlignment = TextAlignment.Center,
- Text = home.RegionName,
+ Text = home.Name,
TextColor = SkinStyle.Current.TextColor1,
TextSize = 19,
};
@@ -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,67 @@
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 ("每", "");
+ //|| backIDStr == "每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每"
+ 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 ();
@@ -351,6 +389,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