internal KNXSender(KNXConnection connection) { this.KNXConnection = connection; }
internal KNXReceiver(KNXConnection connection) { this.KNXConnection = connection; }
/// <summary> /// Disconnects from the remote host. /// </summary> public KnxClientHelper Disconnect() { if (knxClient != null) { knxClient.KNXConnectedDelegate -= knxClient_Connected; knxClient.KNXDisconnectedDelegate -= knxClient_Disconnected; knxClient.KNXEventDelegate -= knxClient_EventReceived; knxClient.KNXStatusDelegate -= knxClient_StatusReceived; try { knxClient.Disconnect(); } catch { } knxClient = null; } return this; }
/// <summary> /// Connect to the remote host using the specified port. /// </summary> /// <param name="port">Port number.</param> public KnxClientHelper Connect() { if (knxClient != null) { knxClient.Disconnect(); } if (knxEndPoint == null) { knxClient = new KNXConnectionRouting(); } else { if (knxEndPoint.RemoteIp != null && knxEndPoint.LocalIp != null) { knxClient = new KNXConnectionTunneling(knxEndPoint.RemoteIp, knxEndPoint.RemotePort, knxEndPoint.LocalIp, knxEndPoint.LocalPort); } else if (knxEndPoint.LocalIp != null && knxEndPoint.LocalPort > 0) { knxClient = new KNXConnectionRouting(knxEndPoint.LocalIp, knxEndPoint.LocalPort); } else if (knxEndPoint.LocalIp != null && knxEndPoint.LocalPort == 0) { knxClient = new KNXConnectionRouting(knxEndPoint.LocalIp); } else if (knxEndPoint.LocalPort > 0) { knxClient = new KNXConnectionRouting(knxEndPoint.LocalPort); } } knxClient.Connect(); knxClient.KNXConnectedDelegate += knxClient_Connected; knxClient.KNXDisconnectedDelegate += knxClient_Disconnected; knxClient.KNXEventDelegate += knxClient_EventReceived; knxClient.KNXStatusDelegate += knxClient_StatusReceived; return this; }