private void StateRequest(object sender, ElapsedEventArgs ev)
        {
            // HEADER
            var datagram = new byte[16];

            datagram[00] = 0x06;
            datagram[01] = 0x10;
            datagram[02] = 0x02;
            datagram[03] = 0x07;
            datagram[04] = 0x00;
            datagram[05] = 0x10;

            datagram[06] = ChannelId;
            datagram[07] = 0x00;
            datagram[08] = 0x08;
            datagram[09] = 0x01;
            datagram[10] = _localEndpoint.Address.GetAddressBytes()[0];
            datagram[11] = _localEndpoint.Address.GetAddressBytes()[1];
            datagram[12] = _localEndpoint.Address.GetAddressBytes()[2];
            datagram[13] = _localEndpoint.Address.GetAddressBytes()[3];
            datagram[14] = (byte)(_localEndpoint.Port >> 8);
            datagram[15] = (byte)_localEndpoint.Port;

            try
            {
                KnxSender.SendData(datagram);
            }
            catch (Exception e)
            {
                Logger.Error(ClassName, e);
            }
        }
        /// <summary>
        ///     Send a byte array value as data to specified address
        /// </summary>
        /// <param name="address">KNX Address</param>
        /// <param name="data">Byte array value</param>
        public void Action(string address, byte[] data)
        {
            Logger.Debug(ClassName, "Sending 0x{0} to {1}.", BitConverter.ToString(data), address);

            _lockManager.PerformLockedOperation(() => KnxSender.Action(address, data));

            Logger.Debug(ClassName, "Sent 0x{0} to {1}.", BitConverter.ToString(data), address);
        }
Exemple #3
0
        /// <summary>
        ///     Send a byte array value as data to specified address
        /// </summary>
        /// <param name="address">KNX Address</param>
        /// <param name="data">Byte array value</param>
        public void Action(string address, byte[] data)
        {
            Logger.Debug(ClassName, "Sending {0} to {1}.", data, address);

            _lockManager.PerformLockedOperation(() => KnxSender.Action(address, data));

            Logger.Debug(ClassName, "Sent {0} to {1}.", data, address);
        }
Exemple #4
0
        /// <summary>
        ///     Send a byte array value as data to specified address
        /// </summary>
        /// <param name="address">KNX Address</param>
        /// <param name="data">Byte array value</param>
        /// <param name="addTruncateByte">adds extra byte to chop off for payload</param>
        public void Action(string address, byte[] data, bool addTruncateByte = true)
        {
            if (addTruncateByte)
            {
                // reverse bytes temporary to add byte in front
                Array.Reverse(data);
                Array.Resize(ref data, data.Length + 1);
                data[data.Length - 1] = 0x00;
                Array.Reverse(data);
            }
            Logger.Debug(ClassName, "Sending 0x{0} to {1}.", BitConverter.ToString(data), address);

            _lockManager.PerformLockedOperation(() => KnxSender.Action(address, data));

            Logger.Debug(ClassName, "Sent 0x{0} to {1}.", BitConverter.ToString(data), address);
        }