From 8fcc3bd198606e0400eca5383572fb97ecdada85 Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期二, 10 一月 2023 15:51:37 +0800
Subject: [PATCH] 备份
---
SmartHome/UI/SimpleControl/CommonPage.cs | 106 ++++++++++++++++++++++++++++++++---------------------
1 files changed, 64 insertions(+), 42 deletions(-)
diff --git a/SmartHome/UI/SimpleControl/CommonPage.cs b/SmartHome/UI/SimpleControl/CommonPage.cs
index 4910531..f422a89 100644
--- a/SmartHome/UI/SimpleControl/CommonPage.cs
+++ b/SmartHome/UI/SimpleControl/CommonPage.cs
@@ -10,13 +10,8 @@
{
public static class CommonPage
{
- //public static AirQuality AirQuality;
- //public static Action RefreshAir;
public static bool IsRemote = false;
- public static bool FindGateway = false;
- public static bool FindGatewayChilren = false;
public static string FindGatewayChilrenIPAddress = new Net.NetWiFi ().BroadcastIpAddress.ToString ();
- public static bool LocalPhoneFindDevice = false;
public static int searchTotal = 0;
public static int newDevice = 0;
private static string ip= "115.29.251.24";
@@ -32,17 +27,18 @@
}
return new System.Net.IPEndPoint (System.Net.IPAddress.Parse (ip), 9999);
} else {
- if (FindGateway) {
- return new System.Net.IPEndPoint (System.Net.IPAddress.Parse ("224.0.168.188"), 6000);
- } else if (FindGatewayChilren) {
- try {
- return new System.Net.IPEndPoint (System.Net.IPAddress.Parse (FindGatewayChilrenIPAddress), 6000);
- } catch {
- return new System.Net.IPEndPoint (System.Net.IPAddress.Parse ("224.0.168.188"), 6000);
- }
- } else {
+ //if (FindGateway) {
+ // return new System.Net.IPEndPoint (System.Net.IPAddress.Parse ("224.0.168.188"), 6000);
+ //} else if (FindGatewayChilren) {
+ // try {
+ // return new System.Net.IPEndPoint (System.Net.IPAddress.Parse (FindGatewayChilrenIPAddress), 6000);
+ // } catch {
+ // return new System.Net.IPEndPoint (System.Net.IPAddress.Parse ("224.0.168.188"), 6000);
+ // }
+ //} else {
+ // return new System.Net.IPEndPoint (System.Net.IPAddress.Parse (new Net.NetWiFi ().BroadcastIpAddress.ToString ()), 6000);
+ //}
return new System.Net.IPEndPoint (System.Net.IPAddress.Parse (new Net.NetWiFi ().BroadcastIpAddress.ToString ()), 6000);
- }
}
} catch {
//闃叉寮傚父瀵艰嚧绋嬪簭閫�鍑�
@@ -73,41 +69,62 @@
static object lockobj = new object ();
- static void Packet_ReceiveEvent (byte subnetID, byte deviceID, Command command, byte [] usefullBytes,int deviceTypeNumber)
+ static List<int> supportList = new List<int> () {
+ 228, 229,230,4618, 231, 232, 233, 234, 235, 236, 237, 238
+ ,740,741,742,743,744,745,746,750,752,754, 755,756,757,761,758,759,760,762,894,
+ 4602,4604 ,4613, 4622,4605,4606,4607,4609, 4611,4620,4621,4615,4617,4619,4612,
+ 36865,9600,19600,
+ 1099,1163,3501,3502,3503,3504,3505,3506,
+ 3508,3509,3516,3517,3521,3527,3528,3530,3532,3533,3534,3536,3538,
+ 3539,3541,3543,3550,3559,3600,3601,3605,4601,4602,
+ 30001,63479,65282,65532,65534,
+ };
+
+ static void Packet_ReceiveEvent (byte subnetID, byte deviceID, Command command, byte [] usefullBytes,int deviceTypeNumber, System.Net.IPEndPoint remoteIp)
{
try {
List<byte> ButtonBkeyModelList = new List<byte> ();
switch (command) {
- //璇诲彇缃戝叧璁惧鍥炲
- case Command.ReadGatewayACK:
- if (usefullBytes [0] != RandomHigh | usefullBytes [1] != RandomLow) {
- return;
- }
- lock (GateWayList) {
- if (GateWayList.Find ((l) => { return l.SubnetID == subnetID && l.DeviceID == deviceID; }) != null) {
- return;
- }
- DeviceType deviceType = (DeviceType)(usefullBytes [2] * 256 + usefullBytes [3]);
- if (usefullBytes [2] == 254 && usefullBytes [3] < 7) {
- GatewayBase gatewayBase = new GatewayBase ();
- gatewayBase.DeviceTypeNumber = deviceTypeNumber;
- gatewayBase.SubnetID = subnetID;
- gatewayBase.DeviceID = deviceID; gatewayBase.Type = deviceType;
- gatewayBase.LoopID = usefullBytes [4];
- gatewayBase.MAC = byteToHex16 (usefullBytes [5]) + "." + byteToHex16 (usefullBytes [6]) + "." + byteToHex16 (usefullBytes [7]) + "." + byteToHex16 (usefullBytes [8]) + "." + byteToHex16 (usefullBytes [9]) + "." + byteToHex16 (usefullBytes [10]) + "." + byteToHex16 (usefullBytes [11]) + "." + byteToHex16 (usefullBytes [12]);
- gatewayBase.Name = MyEncodingGB2312.GetString (usefullBytes, 13, 20).Trim ('\0');//=============
- gatewayBase.IPAddress = usefullBytes [33] + "." + usefullBytes [34] + "." + usefullBytes [35] + "." + usefullBytes [36];
- gatewayBase.RouteIPAddress = usefullBytes [37] + "." + usefullBytes [38] + "." + usefullBytes [39] + "." + usefullBytes [40];
- gatewayBase.IPMAC = usefullBytes [41] + "." + usefullBytes [42] + "." + usefullBytes [43] + "." + usefullBytes [44] + "." + usefullBytes [45] + "." + usefullBytes [46];
- gatewayBase.SubnetMask = usefullBytes [47] + "." + usefullBytes [48] + "." + usefullBytes [49] + "." + usefullBytes [50];
- gatewayBase.DHCP = usefullBytes [51] == 0 ? false : true;
- GateWayList.Add (gatewayBase);
- if (gatewayBase.Name == "") {
- gatewayBase.Name = gatewayBase.CommonLoopID.ToString ();
+ case Command.ReadRemarkACK:
+ if(supportList.Contains(deviceTypeNumber)) {
+ //if (IsRemote) {
+ // if (remoteIp.ToString().Contains("118.31.3.103") || remoteIp.ToString ().Contains ("157.175.231.123"))
+ // lock (GateWayList_NewServer) {
+ // if (GateWayList_NewServer.Find ((l) => { return l.SubnetID == subnetID && l.DeviceID == deviceID; }) != null) {
+ // return;
+ // }
+ // DeviceType deviceType = (DeviceType)(usefullBytes [2] * 256 + usefullBytes [3]);
+ // GatewayBase gatewayBase = new GatewayBase ();
+ // gatewayBase.DeviceTypeNumber = deviceTypeNumber;
+ // gatewayBase.SubnetID = subnetID;
+ // gatewayBase.DeviceID = deviceID;
+ // gatewayBase.Type = deviceType;
+ // gatewayBase.Name = MyEncodingGB2312.GetString (usefullBytes, 0, 20).Trim ('\0');//=============
+ // GateWayList_NewServer.Add (gatewayBase);
+ // Console.WriteLine ($"name:{gatewayBase.Name}++{deviceTypeNumber}");
+ // }
+ //} else
+ {
+ lock (GateWayList) {
+ if (GateWayList.Find ((l) => { return l.SubnetID == subnetID && l.DeviceID == deviceID; }) != null) {
+ return;
+ }
+ DeviceType deviceType = (DeviceType)(usefullBytes [2] * 256 + usefullBytes [3]);
+ GatewayBase gatewayBase = new GatewayBase ();
+ gatewayBase.DeviceTypeNumber = deviceTypeNumber;
+ gatewayBase.SubnetID = subnetID;
+ gatewayBase.DeviceID = deviceID;
+ gatewayBase.Type = deviceType;
+ gatewayBase.Name = MyEncodingGB2312.GetString (usefullBytes, 0, 20).Trim ('\0');//=============
+ var name = Encoding.Default.GetString (usefullBytes, 0, 20).Trim ('\0');
+ GateWayList.Add (gatewayBase);
+
+ Console.WriteLine ($"name:{gatewayBase.Name}++{deviceTypeNumber}");
}
}
}
break;
+
case Command.WriteWirelessPanelButtonKey:
//01 01 59(+30) 02 0D 03 64 00 01
break;
@@ -157,5 +174,10 @@
/// </summary>
public static List<GatewayBase> GateWayList = new List<GatewayBase> ();
+
+ public static List<GatewayBase> GateWayList_NewServer = new List<GatewayBase> ();
+
+
+
}
}
\ No newline at end of file
--
Gitblit v1.8.0