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 EndpointType { Data, Control }
enum Error { None, State, Network, NotIPv4, ..., Unknown }
enum SequenceType { Send, Receive }
enum State { Disconnected, Starting, Bound, Connecting, Connected, Disconnecting }

Public Functions

QKnxNetIpEndpointConnection()
virtual ~QKnxNetIpEndpointConnection() = 0
void connectToHost(const QKnxNetIpHpai &controlEndpoint)
void connectToHost(const QHostAddress &address, quint16 port)
void connectToHost(const QHostAddress &address, quint16 port, QKnxNetIp::HostProtocol proto)
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
int sequenceCount(QKnxNetIpEndpointConnection::SequenceType type) const
void setHeartbeatTimeout(quint32 msec)
void setLocalAddress(const QHostAddress &address)
void setLocalPort(quint16 port)
void setNatAware(bool isAware)
void setSupportedProtocolVersions(const QKnxByteArray &versions)
QKnxNetIpEndpointConnection::State state() const
QKnxByteArray supportedProtocolVersions() const
  • 34 public functions inherited from QObject

Signals

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

Protected Functions

QKnxNetIpEndpointConnection(QKnxNetIpEndpointConnectionPrivate &dd, QObject *parent)
  • 9 protected functions inherited from QObject

Additional Inherited Members

  • 1 property inherited from QObject
  • 1 public slot inherited from QObject
  • 1 public variable inherited from QObject
  • 10 static public members inherited from QObject
  • 2 protected variables inherited from QObject

Detailed Description

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.

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 QKnxNetIpEndpointConnection::EndpointType

This enum holds the endpoint type.

ConstantValue
QKnxNetIpEndpointConnection::Data0
QKnxNetIpEndpointConnection::Control1

enum QKnxNetIpEndpointConnection::Error

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

ConstantValueDescription
QKnxNetIpEndpointConnection::None0No errors so far.
QKnxNetIpEndpointConnection::State1 
QKnxNetIpEndpointConnection::Network2Detected errors in the internal UDP socket connection.
QKnxNetIpEndpointConnection::NotIPv43Host or remote IPs not version 4.
QKnxNetIpEndpointConnection::Acknowledge4No response to connect/disconnect request.
QKnxNetIpEndpointConnection::Heartbeat5State request timeout.
QKnxNetIpEndpointConnection::Cemi6No cEMI frame acknowledge in time.
QKnxNetIpEndpointConnection::Unknown0x80 

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

QKnxNetIpEndpointConnection::QKnxNetIpEndpointConnection()

Default constructs an instance of QKnxNetIpEndpointConnection.

[protected] QKnxNetIpEndpointConnection::QKnxNetIpEndpointConnection(QKnxNetIpEndpointConnectionPrivate &dd, QObject *parent)

Default constructs an instance of QKnxNetIpEndpointConnection.

[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.

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

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

This function was introduced in Qt 5.12.

[signal] void QKnxNetIpEndpointConnection::connected()

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

void QKnxNetIpEndpointConnection::disconnectFromHost()

Closes an established connection.

[signal] void QKnxNetIpEndpointConnection::disconnected()

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

QKnxNetIpEndpointConnection::Error QKnxNetIpEndpointConnection::error() const

Returns the last error code detected in 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.

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.

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

Returns the received or sent sequence count based on type.

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::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.

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

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

QKnxByteArray QKnxNetIpEndpointConnection::supportedProtocolVersions() const

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

See also setSupportedProtocolVersions().

© 2018 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.