private static void InitializeHostProtocolAddressInformation(KnxHpai hostProtocolAddressInfo, IPEndPoint localEndPoint) { if (hostProtocolAddressInfo == null) { throw new ArgumentNullException(nameof(hostProtocolAddressInfo), "KnxHpai cannot be null"); } if (localEndPoint == null) { throw new ArgumentNullException(nameof(localEndPoint), "LocalEndpoint cannot be null"); } hostProtocolAddressInfo.HostProtocolCode = HostProtocolCode.IPV4_UDP; hostProtocolAddressInfo.IpAddress = localEndPoint.Address; hostProtocolAddressInfo.Port = localEndPoint.Port; }
/// <summary> /// Parses the specified bytes. /// </summary> /// <param name="bytes">The bytes.</param> public static KnxHpai Parse(byte[] bytes) { var result = new KnxHpai { HostProtocolCode = (HostProtocolCode)bytes[1], IpAddress = new IPAddress(bytes.ExtractBytes(2, 4)), Port = (bytes[6] << 8) + bytes[7] }; try { if (bytes.Length > 8) { result.Description = DeviceDescriptionInformationBlock.Parse(bytes.ExtractBytes(8)); } } catch { // suppress any exceptions. } return(result); }