| | |
| | | /// <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; |
| | |
| | | // //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) { |
| | |
| | | |
| | | 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; |