From d53e6af2c5f17838fa79659614b15a2a1f383399 Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期五, 31 三月 2023 10:04:58 +0800
Subject: [PATCH] 1

---
 Crabtree/SmartHome/UI/SimpleControl/Phone/Guide/GuideAddGateway.cs |   44 +++++++++++++++++++++++++++-----------------
 1 files changed, 27 insertions(+), 17 deletions(-)

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