Crabtree/.vs/SmartHome/xs/UserPrefs.xml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
Crabtree/ON/Properties/AndroidManifest.xml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
Crabtree/SmartHome/HDL/Operation/Packet.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
Crabtree/SmartHome/UI/SimpleControl/CommonPage.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
Crabtree/SmartHome/UI/SimpleControl/Phone/Guide/GuideAddGateway.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
Crabtree/SmartHome/UI/SimpleControl/Phone/Guide/GuideSettingGateway.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
Crabtree/.vs/SmartHome/xs/UserPrefs.xml
@@ -1,39 +1,20 @@ <Properties StartupConfiguration="{9D9EF20B-6E65-4A65-92BF-567EBF1E1443}|Default"> <MonoDevelop.Ide.ItemProperties.ON.Droid AndroidDesignerPreferredTheme="SplashTheme" AndroidDesignerPreferredDevice="Nexus 4" PreferredExecutionTarget="Android.364c4b3158493098" /> <MonoDevelop.Ide.Workbench ActiveDocument="ON/SplashActivity.cs"> <MonoDevelop.Ide.ItemProperties.ON.Droid AndroidDesignerPreferredTheme="SplashTheme" AndroidDesignerPreferredDevice="Nexus 4" PreferredExecutionTarget="Android.3TG0221602005112" /> <MonoDevelop.Ide.Workbench ActiveDocument="SmartHome/UI/SimpleControl/Phone/Guide/GuideAddGateway.cs"> <Files> <File FileName="SmartHome/HDL/Common/HttpUtil/NewAPI.cs" Line="543" Column="1" /> <File FileName="SmartHome/UI/SimpleControl/Phone/Guide/GuideAddGateway.cs" Line="375" Column="23" /> <File FileName="SmartHome/UI/SimpleControl/Phone/Guide/GuideAddGateway.cs" Line="379" Column="50" /> <File FileName="SmartHome/HDL/Common/HttpUtil/HttpServerRequest.cs" /> <File FileName="SmartHome/UI/SimpleControl/Phone/Guide/GuideSettingGateway.cs" Line="1" Column="1" /> <File FileName="SmartHome/HDL/Operation/MyEnum.cs" /> <File FileName="SmartHome/HDL/Common/HDLLinkUtlis.cs" /> <File FileName="SmartHome/UI/SimpleControl/Phone/AC/UserACPage.cs" /> <File FileName="SmartHome/HDL/Operation/Control.cs" /> <File FileName="SmartHome/UI/SimpleControl/MainPage.cs" /> <File FileName="SmartHome/UI/SimpleControl/Phone/Room/UserRooms.cs" /> <File FileName="../../../../../Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets" /> <File FileName="ON/Application.cs" /> <File FileName="ON/Resources/drawable/layer_splash.xml" /> <File FileName="ON/Resources/layout/activity_splash.xml" /> <File FileName="ON/Resources/values/Strings.xml" /> <File FileName="ON/Properties/AssemblyInfo.cs" /> <File FileName="SmartHome/UI/SimpleControl/Phone/Guide/GuideAddResidence.cs" Line="116" Column="65" /> <File FileName="ON/SplashActivity.cs" Line="1" Column="1" /> <File FileName="SmartHome/UI/SimpleControl/Phone/Guide/GuideSettingGateway.cs" Line="764" Column="44" /> <File FileName="SmartHome/HDL/Operation/MyEnum.cs" Line="1482" Column="23" /> <File FileName="SmartHome/UI/SimpleControl/CommonPage.cs" Line="32" Column="84" /> <File FileName="SmartHome/HDL/Operation/Packet.cs" Line="136" Column="1" /> <File FileName="SmartHome/HDL/Operation/Control.cs" Line="304" Column="30" /> <File FileName="SmartHome/HDL/Operation/BusSocket.cs" Line="166" Column="1" /> </Files> <Pads> <Pad Id="ProjectPad"> <State name="__root__"> <Node name="SmartHome" expanded="True"> <Node name="ON.Droid" expanded="True"> <Node name="Properties" expanded="True" /> <Node name="Resources" expanded="True"> <Node name="drawable" expanded="True" /> <Node name="layout" expanded="True" /> <Node name="values" expanded="True" /> </Node> <Node name="SplashActivity.cs" selected="True" /> </Node> <Node name="Shared" expanded="True"> <Node name="HDL" expanded="True"> <Node name="Common" expanded="True"> @@ -41,15 +22,30 @@ </Node> <Node name="Operation" expanded="True" /> </Node> <Node name="IO" expanded="True" /> <Node name="Net" expanded="True" /> <Node name="UI" expanded="True"> <Node name="SimpleControl" expanded="True"> <Node name="Phone" expanded="True"> <Node name="Guide" expanded="True" /> <Node name="Curtain" expanded="True" /> <Node name="Guide" expanded="True"> <Node name="GuideAddGateway.cs" selected="True" /> </Node> <Node name="Room" expanded="True" /> </Node> </Node> </Node> </Node> </Node> </State> </Pad> <Pad Id="MonoDevelop.Debugger.WatchPad"> <State> <Value>ex.Message</Value> <Value>4%6</Value> <Value>command</Value> <Value>this.Bytes [17]</Value> <Value>this.Bytes [18]</Value> </State> </Pad> </Pads> @@ -62,7 +58,7 @@ <String>IosService/IosService.csproj</String> <String>DroidService/DroidService.csproj</String> </DisabledProjects> <MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" /> <MonoDevelop.Ide.Workspace ActiveConfiguration="Release" /> <MonoDevelop.Ide.ItemProperties.ON.Ios automaticSigning="False" PreferredExecutionTarget="MonoDevelop.IPhone.IPhoneSimulatorTarget." /> <MonoDevelop.Ide.DebuggingService.Breakpoints> <BreakpointStore> @@ -75,10 +71,8 @@ <Breakpoint file="/Users/kaede/Desktop/CrabtreeOn/Crabtree/SmartHome/UI/SimpleControl/Phone/Room/GenericDialog.cs" relfile="SmartHome/UI/SimpleControl/Phone/Room/GenericDialog.cs" line="32" column="1" /> <Breakpoint file="/Users/kaede/Desktop/CrabtreeOn/Crabtree/SmartHome/UI/SimpleControl/Phone/Guide/GuideSettingGateway.cs" relfile="SmartHome/UI/SimpleControl/Phone/Guide/GuideSettingGateway.cs" line="320" column="1" /> <Breakpoint file="/Users/kaede/Desktop/CrabtreeOn/Crabtree/SmartHome/UI/SimpleControl/Phone/Room/UserDeviceListPage.cs" relfile="SmartHome/UI/SimpleControl/Phone/Room/UserDeviceListPage.cs" line="368" column="1" /> <Breakpoint file="/Users/kaede/Desktop/CrabtreeOn/Crabtree/SmartHome/UI/SimpleControl/Phone/Guide/GuideSettingGateway.cs" relfile="SmartHome/UI/SimpleControl/Phone/Guide/GuideSettingGateway.cs" line="984" column="1" /> <Breakpoint file="/Users/kaede/Desktop/CrabtreeOn/Crabtree/SmartHome/UI/SimpleControl/Phone/Guide/GuideSettingGateway.cs" relfile="SmartHome/UI/SimpleControl/Phone/Guide/GuideSettingGateway.cs" line="979" column="1" /> <Breakpoint file="/Users/kaede/Desktop/CrabtreeOn/Crabtree/SmartHome/UI/SimpleControl/Phone/Guide/GuideAddGateway.cs" relfile="SmartHome/UI/SimpleControl/Phone/Guide/GuideAddGateway.cs" line="658" column="1" /> <Breakpoint file="/Users/kaede/Desktop/CrabtreeOn/Crabtree/SmartHome/UI/SimpleControl/Phone/Guide/GuideAddGateway.cs" relfile="SmartHome/UI/SimpleControl/Phone/Guide/GuideAddGateway.cs" line="578" column="1" /> <Breakpoint file="/Users/kaede/Desktop/CrabtreeOn/Crabtree/SmartHome/UI/SimpleControl/Phone/Guide/GuideAddGateway.cs" relfile="SmartHome/UI/SimpleControl/Phone/Guide/GuideAddGateway.cs" line="31" column="1" /> <Breakpoint file="/Users/kaede/Desktop/CrabtreeOn/Crabtree/SmartHome/UI/SimpleControl/Phone/Guide/GuideAddGateway.cs" relfile="SmartHome/UI/SimpleControl/Phone/Guide/GuideAddGateway.cs" line="731" column="1" /> </BreakpointStore> </MonoDevelop.Ide.DebuggingService.Breakpoints> <MultiItemStartupConfigurations /> Crabtree/ON/Properties/AndroidManifest.xml
@@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.hdl.crabtreenew" android:versionName="2.712301" android:versionCode="202212301"> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.hdl.crabtreenew" android:versionName="2.801062" android:versionCode="202301062"> <uses-sdk android:minSdkVersion="23" android:targetSdkVersion="30" /> <!-- 在安卓P版本之后,必须要授予FOREGROUND_SERVICE权限,才能够使用前台服务 --> <uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> Crabtree/SmartHome/HDL/Operation/Packet.cs
@@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using Shared.SimpleControl; namespace Shared { @@ -57,8 +58,10 @@ /// </summary> public virtual void Manager () { //加密检测 EncryptionDetection (); if (CommonPage.needEncryptionDetection) { //加密检测 EncryptionDetection (); } //var mes2 = System.Text.Encoding.ASCII.GetString (Bytes, 0, Bytes.Length); //Utlis.WriteLine ($"============>GetBytes :{mes2}"); Crabtree/SmartHome/UI/SimpleControl/CommonPage.cs
@@ -28,6 +28,11 @@ public static bool LocalPhoneFindDevice = false; public static int searchTotal = 0; private static string ip="0.0.0.0"; /// <summary> /// 是否需要加密检测、、为了适配多网关,搜索添加网关的时候需要关掉加密检测,然后同时发送密文,明文搜索网关 2023-01-06 16:49:30 /// </summary> public static bool needEncryptionDetection = true; public static System.Net.IPEndPoint EndPoint { get { try { Crabtree/SmartHome/UI/SimpleControl/Phone/Guide/GuideAddGateway.cs
@@ -17,6 +17,21 @@ { BackgroundColor = SkinStyle.Current.MainColor; inThisView = true; //var secretKeyPack = HttpServerRequest.Current.ApplyDeviceSecret ("3782DACE9D900428"); //if (secretKeyPack != null) { // if (secretKeyPack.Code == StateCode.SUCCESS) { // var pack = Newtonsoft.Json.JsonConvert.DeserializeObject<DeviceSecret> (secretKeyPack.Data.ToString ()); // if (pack != null) { // byte [] usefullBytes = new byte [17]; // usefullBytes [0] = 1; // byte [] ddd = System.Text.Encoding.ASCII.GetBytes (pack.deviceSecret); // Array.Copy (ddd, 0, usefullBytes, 1, 16 < ddd.Length ? 16 : ddd.Length); // } // } //} } public override void RemoveFromParent () @@ -427,6 +442,8 @@ MainPage.Loading.Start ("Searching for gateway..."); }); #region 搜索设备 //是否需要加密检测、、为了适配多网关,搜索添加网关的时候需要关掉加密检测,然后同时发送密文,明文搜索网关 2023-01-06 16:49:30 CommonPage.needEncryptionDetection = false; ////2020-01-14 默认明文开始搜索 UserConfig.Instance.IsLocalEncrypt = false; UserConfig.Instance.EncryptedPasswordCorrect = true; @@ -482,8 +499,57 @@ readCount = 3; } } CommonPage.FindGateway = false; //2023-01-06 16:33:09 增加同时发送密文搜索 CommonPage.needEncryptionDetection = true; UserConfig.Instance.IsLocalEncrypt = true; readCount = 3; while (0 < readCount) { readCount--; System.IO.MemoryStream ms = new System.IO.MemoryStream (); ms.WriteByte (CommonPage.RandomHigh); ms.WriteByte (CommonPage.RandomLow); List<Common> list = CommonPage.GateWayList; int tempCount = list.Count; string s = ";"; for (int i = 0; i < list.Count; i++) { Common common = list [i]; if (s.Contains (";" + common.SubnetID.ToString () + ":" + common.DeviceID.ToString ())) continue; s += common.SubnetID.ToString () + ":" + common.DeviceID.ToString () + ";"; ms.WriteByte (common.SubnetID); ms.WriteByte (common.DeviceID); } Control control = new Control (); Utlis.WriteLine ("组播搜索网关,搜索地址是:" + CommonPage.EndPoint.ToString () + " " + CommonPage.GateWayList.Count); control.Send (new Target () { IPEndPoint = CommonPage.EndPoint, Command = Command.ReadGateway, SubnetID = 0xFF, DeviceID = 0xFF, AddData = ms.ToArray () }, SendCount.Zero, false); Utlis.WriteLine ("广播搜索网关,搜索地址是:" + new Net.NetWiFi ().BroadcastIpAddress.ToString () + " " + CommonPage.GateWayList.Count); control.Send (new Target () { IPEndPoint = new System.Net.IPEndPoint (new Net.NetWiFi ().BroadcastIpAddress, 6000), Command = Command.ReadGateway, SubnetID = 0xFF, DeviceID = 0xFF, AddData = ms.ToArray () }, SendCount.Zero, false); System.Threading.Thread.Sleep (800); //如果数量不相等,就重置次数 if (tempCount != CommonPage.GateWayList.Count) { readCount = 3; } } CommonPage.FindGateway = false; CommonPage.LocalPhoneFindDevice = false; #endregion } catch (Exception ex) { @@ -645,14 +711,14 @@ // //UserConfig.Instance.LocalEncryptKey = aseKeyStr; // Utlis.WriteLine ($"============>LocalEncryptKey 加密成功Key为:{UserConfig.Instance.LocalEncryptKey}"); //} UserConfig.Instance.IsLocalEncrypt = false; var 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) { Crabtree/SmartHome/UI/SimpleControl/Phone/Guide/GuideSettingGateway.cs
@@ -980,20 +980,28 @@ var result = Control.ControlBytesSendHasReturn (Command.ApplyServerKey, gatewayDeicve.SubnetID, gatewayDeicve.DeviceID, new byte [] { 0}); if (result != null && result.Length > 1) { if (result [1] == 0xF5) { var secretKeyPack = HttpServerRequest.Current.ApplyDeviceSecret (gatewayDeicve.MAC); var secretKeyPack = HttpServerRequest.Current.ApplyDeviceSecret (gatewayDeicve.MAC.Replace(".","")); if (secretKeyPack != null) { if (secretKeyPack.Code == StateCode.SUCCESS) { var pack = Newtonsoft.Json.JsonConvert.DeserializeObject<DeviceSecret> (secretKeyPack.Data.ToString ()); if (pack != null) { byte [] usefullBytes = new byte [17]; usefullBytes [0] = 1; byte [] ddd = CommonPage.MyEncodingGB2312.GetBytes (pack.deviceSecret); byte [] ddd = System.Text.Encoding.ASCII.GetBytes (pack.deviceSecret); Array.Copy (ddd, 0, usefullBytes, 1, 16 < ddd.Length ? 16 : ddd.Length); var result2 = Control.ControlBytesSendHasReturn (Command.ApplyServerKey, gatewayDeicve.SubnetID, gatewayDeicve.DeviceID, usefullBytes); var result3 = Control.ControlBytesSendHasReturn (Command.RestartTheGateway, gatewayDeicve.SubnetID, gatewayDeicve.DeviceID, new byte [] { }); Application.RunOnMainThread (() => { new Alert ("", "The Internet access key was successfully written, and the gateway is being restarted!", Language.StringByID (R.MyInternationalizationString.Close)).Show (); }); //byte [] restartArray = new byte [12]; //string [] macArray = gatewayDeicve.MAC.Split ("."); //for(int i = 0; i < macArray.Length; i++) { // restartArray [i + 2] = Convert.ToByte (macArray [i], 16); //} //restartArray [10] = gatewayDeicve.SubnetID; //restartArray [11] = gatewayDeicve.DeviceID; //var result3 = Control.ControlBytesSendHasReturn (Command.RestartTheGateway, gatewayDeicve.SubnetID, gatewayDeicve.DeviceID, restartArray); //Application.RunOnMainThread (() => { // new Alert ("", "The Internet access key was successfully written, and the gateway is being restarted!", Language.StringByID (R.MyInternationalizationString.Close)).Show (); //}); } } } else {