Пример #1
0
        /// <summary>
        /// Deserializes the specified bytes.
        /// </summary>
        /// <param name="bytes">The bytes.</param>
        public override void Deserialize(byte[] bytes)
        {
            var hpaiLength = (int)bytes[2];                 // get the length for the "HostProtocolAddressInformation //
            var hpaiBytes  = new byte[hpaiLength];          // extract the hpai bytes

            Array.Copy(bytes, 2, hpaiBytes, 0, hpaiLength); // parse the host protocol address information

            this.CommunicationChannel    = bytes[0];
            this.HostProtocolAddressInfo = KnxHpai.Parse(hpaiBytes);
        }
Пример #2
0
        public void CreateKnxHpai()
        {
            var hpai = new KnxHpai
            {
                HostProtocolCode = HostProtocolCode.IPV4_UDP,
                IpAddress        = IPAddress.Parse("192.168.2.1"),
                Port             = 3060
            };

            Assert.IsNotNull(hpai);
        }
Пример #3
0
        public void SerializeDeserializeKnxHpai()
        {
            var hpai = new KnxHpai
            {
                HostProtocolCode = HostProtocolCode.IPV4_UDP,
                IpAddress        = IPAddress.Parse("192.168.2.1"),
                Port             = 3060
            };

            var array            = hpai.ToByteArray();
            var deserializedHpai = KnxHpai.Parse(array);

            Assert.AreEqual(hpai.HostProtocolCode, deserializedHpai.HostProtocolCode);
            Assert.AreEqual(hpai.IpAddress, deserializedHpai.IpAddress);
            Assert.AreEqual(hpai.Port, deserializedHpai.Port);
        }
Пример #4
0
        public override void Deserialize(byte[] bytes)
        {
            this.CommunicationChannel = bytes[0];
            //this.State = (ErrorCode)Enum.Parse(typeof(ErrorCode), (((int)bytes[1]).ToString()));
            this.State = (ErrorCode)bytes[1];

            if (this.State != ErrorCode.NoError)
            {
                return;
            }

            var hpaiLength = (int)bytes[2];                 // get the length for the "HostProtocolAddressInformation //
            var hpaiBytes  = new byte[hpaiLength];          // extract the hpai bytes

            Array.Copy(bytes, 2, hpaiBytes, 0, hpaiLength); // parse the host protocol address information

            this.HostProtocolAddressInfo = KnxHpai.Parse(hpaiBytes);

            // the connection type is written behind the hpai
            //this.ConnectionType =
            //    (ConnectionType)Enum.Parse(typeof(ConnectionType), (((int)bytes[hpaiLength + 2]).ToString()));

            this.ConnectionType = (ConnectionType)bytes[hpaiLength + 2];
        }
Пример #5
0
 public override void Deserialize(byte[] bytes)
 {
     Endpoint = KnxHpai.Parse(bytes);
 }
Пример #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DisconnectRequest"/> class.
 /// </summary>
 /// <param name="communicationChannel">The communication channel.</param>
 /// <param name="hostProtocolAddressInfo">The host protocol address info.</param>
 public DisconnectRequest(byte communicationChannel, KnxHpai hostProtocolAddressInfo)
 {
     this.CommunicationChannel    = communicationChannel;
     this.HostProtocolAddressInfo = hostProtocolAddressInfo;
 }
Пример #7
0
 public SearchRequest()
 {
     Endpoint = new KnxHpai();
 }