From 0fafbe4b132d03dc8f1f99de585bfcb5e63ab60a Mon Sep 17 00:00:00 2001 From: wxr <464027401@qq.com> Date: 星期一, 09 一月 2023 14:02:01 +0800 Subject: [PATCH] 多网关支持 --- Crabtree/SmartHome/HDL/Operation/UserConfig.cs | 10 +++++++++- Crabtree/SmartHome/UI/SimpleControl/Phone/Guide/GuideAddGateway.cs | 44 +++++++++++++++++++++++++++----------------- Crabtree/SmartHome/HDL/Operation/BusSocket.cs | 3 ++- Crabtree/SmartHome/UI/SimpleControl/MainPage.cs | 2 +- 4 files changed, 39 insertions(+), 20 deletions(-) diff --git a/Crabtree/SmartHome/HDL/Operation/BusSocket.cs b/Crabtree/SmartHome/HDL/Operation/BusSocket.cs index 7cc35a7..28b33c0 100644 --- a/Crabtree/SmartHome/HDL/Operation/BusSocket.cs +++ b/Crabtree/SmartHome/HDL/Operation/BusSocket.cs @@ -6,6 +6,7 @@ using System.Threading; using System.Net.Sockets; using System.Net; +using Shared.SimpleControl; namespace Shared { @@ -162,7 +163,7 @@ tempPacket.HaveSendCount++; byte [] messageSend; //2020-01-14 澧炲姞鏈湴閫氳鍔犲瘑 - if (UserConfig.Instance.IsLocalEncrypt) { + if (UserConfig.Instance.IsLocalEncrypt && CommonPage.needEncryptionDetection) { messageSend = Shared.Securitys.EncryptionService.AesEncryptPayload (tempPacket.Bytes, UserConfig.Instance.LocalEncryptKey); } else { messageSend = tempPacket.Bytes; diff --git a/Crabtree/SmartHome/HDL/Operation/UserConfig.cs b/Crabtree/SmartHome/HDL/Operation/UserConfig.cs index c8bed11..0539f1f 100644 --- a/Crabtree/SmartHome/HDL/Operation/UserConfig.cs +++ b/Crabtree/SmartHome/HDL/Operation/UserConfig.cs @@ -326,7 +326,15 @@ /// <summary> /// 鏄惁鍔犲瘑 /// </summary> - public bool IsLocalEncrypt = false; + bool isLocalEncrypt = false; + public bool IsLocalEncrypt { + get { + return isLocalEncrypt; + } + set { + isLocalEncrypt = value; + } + } //public bool IsLocalEncrypt { // set { } // get { return false; } diff --git a/Crabtree/SmartHome/UI/SimpleControl/MainPage.cs b/Crabtree/SmartHome/UI/SimpleControl/MainPage.cs index 6eccec7..94756a8 100644 --- a/Crabtree/SmartHome/UI/SimpleControl/MainPage.cs +++ b/Crabtree/SmartHome/UI/SimpleControl/MainPage.cs @@ -38,7 +38,7 @@ //public static Button LogoButton = new Button (); - public static string RequestVersion = "2.712291"; + public static string RequestVersion = "2.801091"; public static UserInfo LoginUser; /// <summary> /// 鏄惁鏄鐞嗗憳鏉冮檺(鍙樻洿浜�,鎴愬憳鐨勬椂鍊�,杩欎釜涔熶负ture銆備负浠�涔堜細澹版槑杩欐牱鍙橀噺,鍥犱负鏈変簺鎺ュ彛蹇呴』浣跨敤鍘熸潵鐨凾oken) diff --git a/Crabtree/SmartHome/UI/SimpleControl/Phone/Guide/GuideAddGateway.cs b/Crabtree/SmartHome/UI/SimpleControl/Phone/Guide/GuideAddGateway.cs index ada09d8..23d5bfa 100644 --- a/Crabtree/SmartHome/UI/SimpleControl/Phone/Guide/GuideAddGateway.cs +++ b/Crabtree/SmartHome/UI/SimpleControl/Phone/Guide/GuideAddGateway.cs @@ -654,11 +654,13 @@ /// <returns></returns> static bool CheckIsSuccessfulWithBytes (byte [] backBytes, string errorStr = "Modify gateway configuration failed,please try again!") { - if (backBytes == null) { - Application.RunOnMainThread (() => { - new Alert ("", ErrorCode.GatewayNoResponse, - Language.StringByID (R.MyInternationalizationString.Close)).Show (); - }); + if (backBytes == null ) { + if (CommonPage.needEncryptionDetection) { + Application.RunOnMainThread (() => { + new Alert ("", ErrorCode.GatewayNoResponse, + Language.StringByID (R.MyInternationalizationString.Close)).Show (); + }); + } return false; } else if (backBytes [0] == 0xF8) {//F8 = 鎴愬姛锛� F5=澶辫触 return true; @@ -711,14 +713,18 @@ // //UserConfig.Instance.LocalEncryptKey = aseKeyStr; // Utlis.WriteLine ($"============>LocalEncryptKey 鍔犲瘑鎴愬姛Key涓猴細{UserConfig.Instance.LocalEncryptKey}"); //} - UserConfig.Instance.IsLocalEncrypt = false; + CommonPage.needEncryptionDetection = false; var backBytes = Control.ControlBytesSendHasReturn (Command.Read_APP_Data_STORE_1D5C_CMD, common.SubnetID, common.DeviceID, new byte [] { }); - + CommonPage.needEncryptionDetection = true; + 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 (); - }); - return false; + 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 (); + }); + return false; + } } if (backBytes.Length >= 37) { @@ -734,15 +740,19 @@ if (!UserConfig.Instance.IsLocalEncrypt || true) {//涓嶇鍔犳病鍔犲瘑锛岄兘閲嶆柊鍔犲瘑涓�娆★紝闃叉澶氱綉鍏崇殑鏃跺�欐湁浠庣綉鍏虫病鍔犲瘑 2022-12-26 13:42:09 //濡傛灉娌″姞瀵嗭紝璧颁慨鏀瑰姞瀵嗘柟娉� + CommonPage.needEncryptionDetection = false; var result = SetGateWayLocalEncryption (common); + CommonPage.needEncryptionDetection = true; if (!result) { - Application.RunOnMainThread (() => { - MainPage.Loading.Hide (); - new Alert ("", "Encryption gateway failed, please try again.", Language.StringByID (R.MyInternationalizationString.Close)).Show (); + result = SetGateWayLocalEncryption (common); + if (!result) { + Application.RunOnMainThread (() => { + MainPage.Loading.Hide (); + new Alert ("", "Encryption gateway failed, please try again.", Language.StringByID (R.MyInternationalizationString.Close)).Show (); - }); - - return result;//淇敼澶辫触 杩斿洖goNext false + }); + return result;//淇敼澶辫触 杩斿洖goNext false + } } //淇敼鎴愬姛,璁剧疆鏈湴涓哄姞瀵嗘柟寮� UserConfig.Instance.IsLocalEncrypt = true; -- Gitblit v1.8.0