CrabtreeOn,印度客户定制APP,迁移2.0平台版本
wxr
2023-01-09 0fafbe4b132d03dc8f1f99de585bfcb5e63ab60a
多网关支持
4个文件已修改
59 ■■■■■ 已修改文件
Crabtree/SmartHome/HDL/Operation/BusSocket.cs 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Crabtree/SmartHome/HDL/Operation/UserConfig.cs 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Crabtree/SmartHome/UI/SimpleControl/MainPage.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Crabtree/SmartHome/UI/SimpleControl/Phone/Guide/GuideAddGateway.cs 44 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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;
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; }
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。为什么会声明这样变量,因为有些接口必须使用原来的Token)
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;