QKnxNetIpEndpointConnection Class

The QKnxNetIpEndpointConnection class serves as base class for derived classes to enable the opening and handling of a client connection to a KNXnet/IP server. More...

Header: #include <QKnxNetIpEndpointConnection>
qmake: QT += knx
Inherits: QObject
Inherited By:

QKnxNetIpDeviceManagement and QKnxNetIpTunnel

Public Types

enum class EndpointType { Data, Control }
enum class Error { None, State, Network, NotIPv4, Acknowledge, …, Unknown }
enum SequenceType { Send, Receive }
enum State { Disconnected, Starting, Bound, Connecting, Connected, Disconnecting }

Public Functions

virtual ~QKnxNetIpEndpointConnection() = 0
void connectToHost(const QKnxNetIpHpai &controlEndpoint)
void connectToHost(const QHostAddress &address, quint16 port)
void connectToHost(const QHostAddress &address, quint16 port, QKnxNetIp::HostProtocol protocol)
void connectToHostEncrypted(const QKnxNetIpHpai &controlEndpoint)
void connectToHostEncrypted(const QHostAddress &address, quint16 port)
void disconnectFromHost()
QKnxNetIpEndpointConnection::Error error() const
QString errorString() const
quint32 heartbeatTimeout() const
QHostAddress localAddress() const
quint16 localPort() const
bool natAware() const
quint8 netIpHeaderVersion(QKnxNetIpEndpointConnection::EndpointType endpoint) const
QKnxNetIpSecureConfiguration secureConfiguration() const
int sequenceCount(QKnxNetIpEndpointConnection::SequenceType type) const
QKnxByteArray serialNumber() const
void setHeartbeatTimeout(quint32 msec)
void setLocalAddress(const QHostAddress &address)
void setLocalPort(quint16 port)
void setNatAware(bool isAware)
void setSecureConfiguration(const QKnxNetIpSecureConfiguration &config)
void setSerialNumber(const QKnxByteArray &serialNumber)
void setSupportedProtocolVersions(const QKnxByteArray &versions)
QKnxNetIpEndpointConnection::State state() const
QKnxByteArray supportedProtocolVersions() const

Signals

void connected()
void disconnected()
void errorOccurred(QKnxNetIpEndpointConnection::Error error, QString errorString)
void stateChanged(QKnxNetIpEndpointConnection::State state)

Detailed Description

The QKnxNetIpEndpointConnection establishes a communication channel between a client and a KNXnet/IP server endpoint. This is used by the client side to monitor the state of the communication channel. The IP address of the client must be set together with a local port. It is then possible to connect to a chosen KNXnet/IP server on a given port. To detect the failure of the channel, the class provides a heartbeat monitor timeout that can be modified according to the client needs. If the KNXnet/IP communication has to traverse across a network using network address translation (NAT), the client can also make the class aware of this.

See also Qt KNXnet/IP Connection Classes.

Member Type Documentation

enum class QKnxNetIpEndpointConnection::EndpointType

This enum holds the endpoint type.

ConstantValue
QKnxNetIpEndpointConnection::EndpointType::Data0
QKnxNetIpEndpointConnection::EndpointType::Control1

enum class QKnxNetIpEndpointConnection::Error

This enum holds the errors that can occur establishing a KNXnet/IP connection.

ConstantValueDescription
QKnxNetIpEndpointConnection::Error::None0No errors so far.
QKnxNetIpEndpointConnection::Error::State1 
QKnxNetIpEndpointConnection::Error::Network2Detected errors in the internal UDP socket connection.
QKnxNetIpEndpointConnection::Error::NotIPv43Host or remote IPs not version 4.
QKnxNetIpEndpointConnection::Error::Acknowledge4No response to connect/disconnect request.
QKnxNetIpEndpointConnection::Error::Heartbeat5State request timeout.
QKnxNetIpEndpointConnection::Error::Cemi6No cEMI frame acknowledge in time.
QKnxNetIpEndpointConnection::Error::SecureConfig7An invalid secure configuration was used to establish the connection.
QKnxNetIpEndpointConnection::Error::SerialNumber8An invalid serial number was set for the device.
QKnxNetIpEndpointConnection::Error::AuthFailed9The secure client was not successfully authenticated.
QKnxNetIpEndpointConnection::Error::Timeout10A timeout occurred during secure session handshake.
QKnxNetIpEndpointConnection::Error::Close11The server requested to close the secure session.
QKnxNetIpEndpointConnection::Error::Unknown0x80An unknown error occurred.

enum QKnxNetIpEndpointConnection::SequenceType

This enum holds the sequence type.

ConstantValue
QKnxNetIpEndpointConnection::Send0
QKnxNetIpEndpointConnection::Receive1

enum QKnxNetIpEndpointConnection::State

This enum holds the state of the KNXnet/IP connection.

ConstantValueDescription
QKnxNetIpEndpointConnection::Disconnected0Error found establishing the connection, or disconnect response received.
QKnxNetIpEndpointConnection::Starting1Preparing internal parameters for establishing the connection.
QKnxNetIpEndpointConnection::Bound2Internal UDP socket is ready for receiving packets, but the connection is not yet established.
QKnxNetIpEndpointConnection::Connecting3Connection request sent but no answer from the server.
QKnxNetIpEndpointConnection::Connected4Connection response received and connection is established.
QKnxNetIpEndpointConnection::Disconnecting5Disconnect request sent.

Member Function Documentation

[signal] void QKnxNetIpEndpointConnection::connected()

This signal is emitted after the client connects to a host and the KNXnet/IP connection is established.

[signal] void QKnxNetIpEndpointConnection::disconnected()

This signal is emitted when the KNXnet/IP connection is lost or client closes the connection.

[signal] void QKnxNetIpEndpointConnection::errorOccurred(QKnxNetIpEndpointConnection::Error error, QString errorString)

This signal is emitted when there is an error in the KNXnet/IP connection. The errorString describes the error that occurred.

[signal] void QKnxNetIpEndpointConnection::stateChanged(QKnxNetIpEndpointConnection::State state)

This signal is emitted when the KNXnet/IP connection state state changed.

[pure virtual] QKnxNetIpEndpointConnection::~QKnxNetIpEndpointConnection()

Destroys a connection and disconnects from the server.

void QKnxNetIpEndpointConnection::connectToHost(const QKnxNetIpHpai &controlEndpoint)

Establishes a connection to the KNXnet/IP control endpoint controlEndpoint.

void QKnxNetIpEndpointConnection::connectToHost(const QHostAddress &address, quint16 port)

Establishes a connection to the host with address and port via UDP.

void QKnxNetIpEndpointConnection::connectToHost(const QHostAddress &address, quint16 port, QKnxNetIp::HostProtocol protocol)

Establishes a connection to the host with address, port and protocol.

This function was introduced in Qt 5.12.

void QKnxNetIpEndpointConnection::connectToHostEncrypted(const QKnxNetIpHpai &controlEndpoint)

Establishes a connection to the KNXnet/IP control endpoint controlEndpoint.

This function was introduced in Qt 5.13.

See also setSerialNumber() and setSecureConfiguration().

void QKnxNetIpEndpointConnection::connectToHostEncrypted(const QHostAddress &address, quint16 port)

Establishes a secure session to the host with address and port.

This function was introduced in Qt 5.13.

See also setSerialNumber() and setSecureConfiguration().

void QKnxNetIpEndpointConnection::disconnectFromHost()

Closes an established connection.

QKnxNetIpEndpointConnection::Error QKnxNetIpEndpointConnection::error() const

Returns the last error code detected in the connection.

QString QKnxNetIpEndpointConnection::errorString() const

Returns an error string describing the last error detected in the connection.

quint32 QKnxNetIpEndpointConnection::heartbeatTimeout() const

Returns the value of the heartbeat timeout.

See also setHeartbeatTimeout().

QHostAddress QKnxNetIpEndpointConnection::localAddress() const

Returns the local address associated with the connection.

See also setLocalAddress().

quint16 QKnxNetIpEndpointConnection::localPort() const

Returns the local port associated with the connection.

See also setLocalPort().

bool QKnxNetIpEndpointConnection::natAware() const

Returns true if the connection uses NAT; false otherwise.

See also setNatAware().

quint8 QKnxNetIpEndpointConnection::netIpHeaderVersion(QKnxNetIpEndpointConnection::EndpointType endpoint) const

Returns the KNXnet/IP header version of the data or control connection depending on endpoint.

QKnxNetIpSecureConfiguration QKnxNetIpEndpointConnection::secureConfiguration() const

Returns the secure configuration used to establish the secure session.

This function was introduced in Qt 5.13.

See also setSecureConfiguration().

int QKnxNetIpEndpointConnection::sequenceCount(QKnxNetIpEndpointConnection::SequenceType type) const

Returns the received or sent sequence count based on type.

QKnxByteArray QKnxNetIpEndpointConnection::serialNumber() const

Returns the serial number of the device using this connection. The default value is set to 0x000000000000.

This function was introduced in Qt 5.13.

See also setSerialNumber().

void QKnxNetIpEndpointConnection::setHeartbeatTimeout(quint32 msec)

Sets the value of the heartbeat timeout. Every msec a state request is sent over the connection to keep it alive.

See also heartbeatTimeout().

void QKnxNetIpEndpointConnection::setLocalAddress(const QHostAddress &address)

Sets the local address address associated with the connection.

See also localAddress().

void QKnxNetIpEndpointConnection::setLocalPort(quint16 port)

Sets the local port port associated with the connection.

See also localPort().

void QKnxNetIpEndpointConnection::setNatAware(bool isAware)

Sets the connection to use NAT based on the isAware parameter.

See also natAware().

void QKnxNetIpEndpointConnection::setSecureConfiguration(const QKnxNetIpSecureConfiguration &config)

Sets a secure configuration to be used to establish secure session to config. The configuration cannot be changed while the secure connection is established.

This function was introduced in Qt 5.13.

See also secureConfiguration().

void QKnxNetIpEndpointConnection::setSerialNumber(const QKnxByteArray &serialNumber)

Sets the serial number to serialNumber of the device using this connection.

Note: The serial number must contain exactly 6 bytes and cannot be changed while the secure session is established.

This function was introduced in Qt 5.13.

See also serialNumber().

void QKnxNetIpEndpointConnection::setSupportedProtocolVersions(const QKnxByteArray &versions)

Sets the connection supported KNXnet/IP versions indicated in versions.

See also supportedProtocolVersions().

QKnxNetIpEndpointConnection::State QKnxNetIpEndpointConnection::state() const

Returns the state of the connection.

QKnxByteArray QKnxNetIpEndpointConnection::supportedProtocolVersions() const

Returns a byte array with the supported KNXnet/IP versions.

See also setSupportedProtocolVersions().

© 2021 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.