From acf6f2bfdd9c4fa2500cc746e1064f375dc633d1 Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期一, 13 六月 2022 11:22:43 +0800
Subject: [PATCH] 备份
---
Crabtree/SmartHome/UI/SimpleControl/Phone/Guide/GuideSettingGateway.cs | 67 ++++++++++++++++++++-------------
1 files changed, 40 insertions(+), 27 deletions(-)
diff --git a/Crabtree/SmartHome/UI/SimpleControl/Phone/Guide/GuideSettingGateway.cs b/Crabtree/SmartHome/UI/SimpleControl/Phone/Guide/GuideSettingGateway.cs
index 27797e3..2d454f9 100644
--- a/Crabtree/SmartHome/UI/SimpleControl/Phone/Guide/GuideSettingGateway.cs
+++ b/Crabtree/SmartHome/UI/SimpleControl/Phone/Guide/GuideSettingGateway.cs
@@ -32,6 +32,10 @@
myLoading.Hide ();
btnCloseLoading.RemoveFromParent ();
WirelessConfig (new byte [] { 1 });//close
+ if (CommonPage.newDevice > 0) {
+ CommonPage.newDevice = 0;
+ SearchDeviceList ();
+ }
});
};
@@ -143,18 +147,25 @@
MainPage.Loading.Start ("Configuring device...");
System.Threading.Tasks.Task.Run (() => {
try {
- var currentRegionIdBytes = new byte [] {
- (byte)(UserConfig.Instance.CurrentRegion.RegionID / 256 / 256 / 256),
- (byte)(UserConfig.Instance.CurrentRegion.RegionID / 256 / 256),
- (byte)(UserConfig.Instance.CurrentRegion.RegionID / 256),
- (byte)(UserConfig.Instance.CurrentRegion.RegionID%256),
- };
+ //2022-01-12 淇璁$畻婧㈠嚭闂
+ byte regionID1 = (byte)((UserConfig.Instance.CurrentRegion.RegionID >> (6 * 4)) & 0xFF);
+ byte regionID2 = (byte)((UserConfig.Instance.CurrentRegion.RegionID >> (4 * 4)) & 0xFF);
+ byte regionID3 = (byte)((UserConfig.Instance.CurrentRegion.RegionID >> (2 * 4)) & 0xFF);
+ byte regionID4 = (byte)((UserConfig.Instance.CurrentRegion.RegionID) & 0xFF);
+ var currentRegionIdBytes = new byte [] {regionID1, regionID2, regionID3, regionID4};
+
+ //var currentRegionIdBytes = new byte [] {
+ // (byte)(UserConfig.Instance.CurrentRegion.RegionID / 256 / 256 / 256),
+ // (byte)(UserConfig.Instance.CurrentRegion.RegionID / 256 / 256),
+ // (byte)(UserConfig.Instance.CurrentRegion.RegionID / 256),
+ // (byte)(UserConfig.Instance.CurrentRegion.RegionID%256),
+ //};
gatewayBytes = Control.ControlBytesSendHasReturn (Command.ReadGateWayModelInfo, gatewayDeicve.SubnetID, gatewayDeicve.DeviceID, new byte [] { });
serverIPBytes = Control.ControlBytesSendHasReturn (Command.ReadGatewayServerIP, gatewayDeicve.SubnetID, gatewayDeicve.DeviceID, new byte [] { });
gatewayDeicve.Remote_GroupName = MainPage.LoginUser.AccountString;//UserConfig.Instance.CurrentRegion.RegionName;
- gatewayDeicve.Remote_ProjectName = gatewayDeicve.MAC.Replace(".","");//UserConfig.Instance.CurrentRegion.RegionName;
+ gatewayDeicve.Remote_ProjectName = gatewayDeicve.MAC.Replace (".", "");//UserConfig.Instance.CurrentRegion.RegionName;
gatewayDeicve.Remote_UserName = "Admin";
gatewayDeicve.Remote_Password = "c" + MainPage.LoginUser.MasterID;
byte [] ggn = new byte [20];
@@ -176,7 +187,7 @@
byte [] macAddress = Control.ControlBytesSendHasReturn (Command.ReadDeviceMac, gatewayDeicve.SubnetID, gatewayDeicve.DeviceID, new byte [] { });
-
+
gatewayBytes [0] = 2;//杩滅▼鏍囩ず
Array.Copy (ggn, 0, gatewayBytes, 1, 20 < ggn.Length ? 20 : ggn.Length);
Array.Copy (gpn, 0, gatewayBytes, 21, 20 < gpn.Length ? 20 : gpn.Length);
@@ -265,7 +276,7 @@
Application.RunOnMainThread (() => {
new Alert ("", "Communication abnormality,gateway failed to bind residence.Please try again.", Language.StringByID (R.MyInternationalizationString.Close)).Show ();
if (MainPage.LoginUser.AccountString == "464027401@qq.com") {
- new Alert ("22:"+respone.StateCode, respone.ErrorInfo, Language.StringByID (R.MyInternationalizationString.Close)).Show ();
+ new Alert ("22:" + respone.StateCode, respone.ErrorInfo, Language.StringByID (R.MyInternationalizationString.Close)).Show ();
}
});
}
@@ -368,7 +379,8 @@
th = null;
Application.RunOnMainThread (() => {
MainPage.Loading.Hide ();
- if (gatewayDeicve.Type == DeviceType.OnePortWirelessFR) {
+ if (gatewayDeicve.Type == DeviceType.OnePortWirelessFR && CommonPage.newDevice==0) {
+ CommonPage.newDevice = 0;
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 ();
@@ -612,23 +624,24 @@
//}
if (config) {
- System.Threading.Tasks.Task.Factory.StartNew (() => {
- try {
- byte bigClass = common.BigClass;
- byte minClass = common.MinClass;
- int count = common.LoopCount;
- for (int k = 1, j = 0; k <= count; k++) {
- if (Control.ControlBytesSendHasReturn (Command.ReadDeviceLoopInfo, common.SubnetID, common.DeviceID, new byte [] { bigClass, minClass, (byte)k }) == null) {
- j++;
- //杩炵画涓ゆ璇诲彇涓嶅埌鏁版嵁鍒欒烦鍑鸿寰幆
- if (j == 2 && k == 2)
- break;
- }
- }
- } catch (Exception ex) {
- Console.WriteLine ("Cinfig Read Device Loop Info " + ex.Message);
- }
- });
+ CommonPage.newDevice++;
+ //System.Threading.Tasks.Task.Factory.StartNew (() => {
+ // try {
+ // byte bigClass = common.BigClass;
+ // byte minClass = common.MinClass;
+ // int count = common.LoopCount;
+ // for (int k = 1, j = 0; k <= count; k++) {
+ // if (Control.ControlBytesSendHasReturn (Command.ReadDeviceLoopInfo, common.SubnetID, common.DeviceID, new byte [] { bigClass, minClass, (byte)k }) == null) {
+ // j++;
+ // //杩炵画涓ゆ璇诲彇涓嶅埌鏁版嵁鍒欒烦鍑鸿寰幆
+ // if (j == 2 && k == 2)
+ // break;
+ // }
+ // }
+ // } catch (Exception ex) {
+ // Console.WriteLine ("Cinfig Read Device Loop Info " + ex.Message);
+ // }
+ //});
}
#endregion
--
Gitblit v1.8.0