Beispiel #1
0
        private void SocketDataReceived(object sender, DataReceivedEventArgs e)
        {
            if ((e.Data == null) || (e.Data.Length < 14) || (e.Data[5] != e.Data.Length))
            {
                return;
            }

            string ip      = e.Data[8] + "." + e.Data[9] + "." + e.Data[10] + "." + e.Data[11];
            string service = Convert.ToString((e.Data[12] << 8) + e.Data[13]);

            if (this.AlreadyDiscovered(ip))
            {
                return;
            }

            var conn = new KnxNetTunnelingConnection();

            conn.Connected += (object s, EventArgs args) =>
            {
                this.AddDevice(ip, conn);
            };
            conn.Disconnected += (object s, EventArgs args) =>
            {
                this.RemoveDevice(ip);
            };
            conn.Connect(ip);
        }
Beispiel #2
0
 internal KnxPresence(KnxAdapter adapter, KnxNetTunnelingConnection conn, string name, string serialNo, string description) :
     base(adapter, name, "KNX", "KNX Presence", "1.0", serialNo, description)
 {
     _conn            = conn;
     _conn.KnxEvent  += HandleKnxEvent;
     _conn.KnxStatus += HandleKnxEvent;
 }