From 5a5a2b696866f947b6025d26c3302e8ffef46435 Mon Sep 17 00:00:00 2001 From: JLChen <551775569@qq.com> Date: 星期一, 11 一月 2021 16:11:20 +0800 Subject: [PATCH] 2021-01-11 1.更新MQTT连接和本地搜索网关方法。2.子账号相关接口完善 --- Crabtree/SmartHome/HDL/Operation/Packet.cs | 32 +++++++++++++++++++------------- 1 files changed, 19 insertions(+), 13 deletions(-) diff --git a/Crabtree/SmartHome/HDL/Operation/Packet.cs b/Crabtree/SmartHome/HDL/Operation/Packet.cs index ded4f36..0779834 100644 --- a/Crabtree/SmartHome/HDL/Operation/Packet.cs +++ b/Crabtree/SmartHome/HDL/Operation/Packet.cs @@ -60,7 +60,8 @@ //鍔犲瘑妫�娴� EncryptionDetection (); - + //var mes2 = System.Text.Encoding.ASCII.GetString (Bytes, 0, Bytes.Length); + //Utlis.WriteLine ($"============>GetBytes 锛歿mes2}"); //瀵逛簬鎿嶄綔鏁版嵁搴撶殑鏃堕棿姣旇緝闀跨殑锛屽彲浠ュ垱寤哄彟涓�涓嚎绋嬪鐞� if (!"HDLMIRACLE".Equals (System.Text.Encoding.ASCII.GetString (Bytes, 4, 10))) { @@ -69,7 +70,6 @@ byte subnetID = this.Bytes [17]; //婧愬瓙缃戝彿 byte deviceID = this.Bytes [18]; //婧愯澶囧彿 - //婧愯澶囩被鍨� int deviceType = this.Bytes [19] * 256 + this.Bytes [20]; @@ -81,7 +81,8 @@ //涓嶆槸瑕佹帴鏀剁殑鎸囦护灏辫繑鍥� if (!((targetSubnetID == Global.LocalSubnetID && targetDeviceID == Global.LocalDeviceID) || (targetSubnetID == 0xff && targetDeviceID == 0xff))) { - return; + //Utlis.WriteLine ($"============>targetSubnetID return"); + return; } byte [] usefulBytes = null; if (this.Bytes [16] == 0xFF) { @@ -97,7 +98,7 @@ try { ReceiveEvent (subnetID, deviceID, command, usefulBytes); } catch (Exception ex) { - Console.WriteLine (ex.Message); + Utlis.WriteLine (ex.Message); } } @@ -130,21 +131,26 @@ if (IsLocal) {//鏈湴閫氳 if (UserConfig.Instance.IsLocalEncrypt) { - if ("Passord error" == (System.Text.Encoding.ASCII.GetString (Bytes, 14, 13))) { - //缃戝叧杩斿洖锛屽姞瀵嗗瘑鐮乲ey涓嶅 - - return; + if (Bytes.Length == 28) { + var mes = System.Text.Encoding.ASCII.GetString (Bytes, 14, 14); + if ("Password error" == mes) { + //缃戝叧杩斿洖锛屽姞瀵嗗瘑鐮乲ey涓嶅 + UserConfig.Instance.EncryptedPasswordCorrect = false; + return; + } } - var messageGet = Shared.Securitys.EncryptionService.AesEncryptPayload (Bytes, UserConfig.Instance.LocalEncryptKey); + var messageGet = Shared.Securitys.EncryptionService.AesDecryptPayload (Bytes, UserConfig.Instance.LocalEncryptKey); Bytes = messageGet; } else { - if ("Locked" == (System.Text.Encoding.ASCII.GetString (Bytes, 14, 6))) { - //缃戝叧宸插姞瀵嗭紝鑷姩鍒囨崲涓哄姞瀵� - UserConfig.Instance.IsLocalEncrypt = true; + if (Bytes.Length == 20) { + var mes = System.Text.Encoding.ASCII.GetString (Bytes, 14, 6); + if ("Locked" == mes) { + //缃戝叧宸插姞瀵嗭紝鑷姩鍒囨崲涓哄姞瀵� + UserConfig.Instance.IsLocalEncrypt = true; + } } - } } -- Gitblit v1.8.0