| | |
| | | return control.UsefulBytes; |
| | | } |
| | | |
| | | static DAL.Net.TcpListener tcpListener; |
| | | static bool searchLocalGateway = false; |
| | | /// <summary> |
| | | /// 读取局域网网关列表 |
| | | /// </summary> |
| | | public static void SearchLocalGateway() |
| | | { |
| | | searchLocalGateway = true; |
| | | var control = new Control(); |
| | | control.Send(new Target() |
| | | { |
| | | IPEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse(new Shared.Net.NetWiFi().BroadcastIpAddress.ToString()), 6000), |
| | | Command = Command.ReadGateway, |
| | | SubnetID = 255, |
| | | DeviceID = 255, |
| | | AddData = new byte[] { (byte)new Random().Next(255), (byte)new Random().Next(255) }, |
| | | }, 3, true); |
| | | } |
| | | /// <summary> |
| | | /// 验证网关回复信息 |
| | | /// </summary> |
| | | public static void VerGateway(byte[] result) |
| | | { |
| | | if(searchLocalGateway) |
| | | { |
| | | if (result != null) |
| | | { |
| | | var mac0 = CommonPage.byteToHex16(result[5]) + "." + CommonPage.byteToHex16(result[6]) + "." + CommonPage.byteToHex16(result[7]) + "." + CommonPage.byteToHex16(result[8]) + "." + CommonPage.byteToHex16(result[9]) + "." + CommonPage.byteToHex16(result[10]) + "." + CommonPage.byteToHex16(result[11]) + "." + CommonPage.byteToHex16(result[12]); |
| | | // |
| | | if (DB_ResidenceData.residenceData.residenceGatewayMAC.Replace(".", "").Replace(":", "").ToUpper() == mac0.Replace(".", "").Replace(":", "").ToUpper()) |
| | | { |
| | | searchLocalGateway = false; |
| | | } |
| | | else |
| | | { |
| | | Mqtt_Cloud.StartCloudMqtt(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | static TcpListener tcpListener; |
| | | |
| | | /// <summary> |
| | | /// 000E 搜索回复 |
| | |
| | | |
| | | if (tcpListener == null) |
| | | { |
| | | tcpListener = new DAL.Net.TcpListener(); |
| | | tcpListener = new TcpListener(); |
| | | tcpListener.OpenServer(8586); |
| | | } |
| | | |
| | |
| | | // receiveFlag += string.Format("{0}", usefulBytes[0]); |
| | | // break; |
| | | //case Command.ReadDeviceModulACK: |
| | | //case Command.ReadGatewayACK: |
| | | //case Command.ReadSecurityStatusACK: |
| | | // receiveFlag = string.Format("{0},{1}", usefulBytes[0], usefulBytes[1]); |
| | | // break; |
| | | case Command.ReadGatewayACK: |
| | | receiveFlag = string.Format("{0},{1}", usefulBytes[0], usefulBytes[1]); |
| | | break; |
| | | //case Command.UpdataLightDimmingTheLargestLevelACK: |
| | | //case Command.UpdataLightDimmingMaximumOrMinimumACK: |
| | | //case Command.WriteManageWirelessNetACK: |
| | |
| | | // this.SendFlag += string.Format("{0}", target.AddData[0]); |
| | | // break; |
| | | //case Command.ReadDeviceModul: |
| | | //case Command.ReadGateway: |
| | | //case Command.ReadSecurityStatus: |
| | | //case Command.ReadHornTargetState: |
| | | // this.SendFlag = string.Format("{0},{1}", target.AddData[0], target.AddData[1]); |
| | | // break; |
| | | case Command.ReadGateway: |
| | | this.SendFlag = string.Format("{0},{1}", target.AddData[0], target.AddData[1]); |
| | | break; |
| | | //case Command.SetScene: |
| | | //case Command.SetSeries: |
| | | //case Command.SetHotelCurtain: |