QKnxNetIpTunnel Class

The QKnxNetIpTunnel class enables the opening and handling of a KNXnet/IP client connection to a KNXnet/IP server. More...

Header: #include <QKnxNetIpTunnel>
qmake: QT += knx
Inherits: QKnxNetIpEndpointConnection

Public Functions

QKnxNetIpTunnel(QObject *parent = nullptr)
QKnxNetIpTunnel(const QHostAddress &localAddress, QObject *parent = nullptr)
QKnxNetIpTunnel(const QHostAddress &localAddress, quint16 localPort, QObject *parent = nullptr)
QKnxNetIpTunnel(const QHostAddress &localAddress, quint16 localPort, QKnxNetIp::TunnelLayer layer, QObject *parent = nullptr)
virtual ~QKnxNetIpTunnel() override
QKnxAddress individualAddress() const
QKnxNetIp::TunnelLayer layer() const
bool sendFrame(const QKnxLinkLayerFrame &frame)
void setIndividualAddress(const QKnxAddress &address)
void setTunnelLayer(QKnxNetIp::TunnelLayer layer)

Signals

void frameReceived(QKnxLinkLayerFrame frame)

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
  • 9 protected functions inherited from QObject
  • 2 protected variables inherited from QObject

Detailed Description

The QKnxNetIpTunnel class enables the opening and handling of a KNXnet/IP client connection to a KNXnet/IP server.

A tunnel is a data connection that is established from a KNXnet/IP client to a KNXnet/IP server endpoint to access functionalities of devices on a KNX bus. The IP address of the client must be set. The client uses the connection to send link layer frames to the server.

The following code sample illustrates how to connect to the server, request a data connection, and use the connection:

QKnxNetIpTunnel tunnel;
QHostAddress clientLocalAddress = ...
tunnel.setLocalAddress(clientLocalAddress);

QHostAddress knxNetIpServerAddress = ...
quint16 knxNetIpServerDataEndPointPort = ...
tunnel.connectToHost(knxNetIpServerAddress, knxNetIpServerDataEndPointPort);

QKnxLinkLayerFrame frame = ...
tunnel.sendFrame(frame);

See also QKnxLinkLayerFrame, Qt KNX Tunneling Classes, and Qt KNXnet/IP Connection Classes.

Member Function Documentation

QKnxNetIpTunnel::QKnxNetIpTunnel(QObject *parent = nullptr)

Creates a tunnel connection with the parent parent.

QKnxNetIpTunnel::QKnxNetIpTunnel(const QHostAddress &localAddress, QObject *parent = nullptr)

Creates a tunnel connection with the KNXnet/IP client address localAddress and parent parent.

QKnxNetIpTunnel::QKnxNetIpTunnel(const QHostAddress &localAddress, quint16 localPort, QObject *parent = nullptr)

Creates a tunnel connection with the KNXnet/IP client address localAddress, port number localPort, and parent parent.

QKnxNetIpTunnel::QKnxNetIpTunnel(const QHostAddress &localAddress, quint16 localPort, QKnxNetIp::TunnelLayer layer, QObject *parent = nullptr)

Creates a tunnel connection with the KNXnet/IP client address localAddress, port number localPort, layer layer, and parent parent.

[override virtual] QKnxNetIpTunnel::~QKnxNetIpTunnel()

Destroys the instance of QKnxNetIpTunnel. The destructor is virtual.

[signal] void QKnxNetIpTunnel::frameReceived(QKnxLinkLayerFrame frame)

This signal is emitted when the KNXnet/IP client receives data (with the link layer frame frame as payload) from the KNXnet/IP server.

QKnxAddress QKnxNetIpTunnel::individualAddress() const

Returns the individual address of the KNXnet/IP client assigned by the KNXnet/IP server.

See also setIndividualAddress().

QKnxNetIp::TunnelLayer QKnxNetIpTunnel::layer() const

Returns the layer used for the tunnel connection.

bool QKnxNetIpTunnel::sendFrame(const QKnxLinkLayerFrame &frame)

Inserts the link layer frame frame into a tunneling request that is sent to a KNXnet/IP server.

If the tunnel runs in bus monitor mode, no frames can be sent to the bus.

If no connection is currently established, returns false and does not send the frame.

See also QKnxNetIpEndpointConnection::State.

void QKnxNetIpTunnel::setIndividualAddress(const QKnxAddress &address)

Sets the requested individual address of the KNXnet/IP client extended connect request information (CRI) structure to address.

If the address is a valid individual address, a extended CRI is used to send the connect request. To reset the behavior in favor of a standard CRI pass an invalid address to the function.

See also individualAddress().

void QKnxNetIpTunnel::setTunnelLayer(QKnxNetIp::TunnelLayer layer)

Sets the layer used for the tunnel connection to layer.

The layer is changed only if no connection is currently established. The new layer is set the next time a connection is created.

See also QKnxNetIpEndpointConnection::State.

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