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(const QHostAddress &localAddress, quint16 localPort, QKnxNetIp::TunnelLayer layer, QObject *parent = nullptr)
QKnxNetIpTunnel(const QHostAddress &localAddress, quint16 localPort, QObject *parent = nullptr)
QKnxNetIpTunnel(const QHostAddress &localAddress, QObject *parent = nullptr)
QKnxNetIpTunnel(QObject *parent = nullptr)
QKnxAddress individualAddress() const
QKnxNetIp::TunnelLayer layer() const
bool sendFrame(const QKnxLinkLayerFrame &frame)
bool sendTunnelingFeatureGet(QKnx::InterfaceFeature feature)
bool sendTunnelingFeatureSet(QKnx::InterfaceFeature feature, const QKnxByteArray &value)
void setTunnelLayer(QKnxNetIp::TunnelLayer layer)

Signals

void frameReceived(QKnxLinkLayerFrame frame)
void tunnelingFeatureInfoReceived(QKnx::InterfaceFeature feature, QKnxByteArray value)
void tunnelingFeatureResponseReceived(QKnx::InterfaceFeature feature, QKnx::ReturnCode code, QKnxByteArray value)

Detailed Description

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

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, QObject *parent = nullptr)

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

QKnxNetIpTunnel::QKnxNetIpTunnel(QObject *parent = nullptr)

Creates a tunnel connection with the parent parent.

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

[signal] void QKnxNetIpTunnel::tunnelingFeatureInfoReceived(QKnx::InterfaceFeature feature, QKnxByteArray value)

This signal is emitted when the KNXnet/IP tunneling client receives data from the KNXnet/IP server consisting of a given interface feature and the corresponding feature value.

This function was introduced in Qt 5.12.

[signal] void QKnxNetIpTunnel::tunnelingFeatureResponseReceived(QKnx::InterfaceFeature feature, QKnx::ReturnCode code, QKnxByteArray value)

This signal is emitted when the KNXnet/IP tunneling client receives data from the KNXnet/IP server consisting of a given interface feature, the corresponding feature value and a return code code.

The signal is emit after a successful tunneling feature get or tunneling feature set.

This function was introduced in Qt 5.12.

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.

bool QKnxNetIpTunnel::sendTunnelingFeatureGet(QKnx::InterfaceFeature feature)

Creates a tunneling feature get frame and sets the requested feature identifier to feature.

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.

This function was introduced in Qt 5.12.

bool QKnxNetIpTunnel::sendTunnelingFeatureSet(QKnx::InterfaceFeature feature, const QKnxByteArray &value)

Creates a tunneling feature set frame and sets the requested feature identifier to feature and the feature value to set to value.

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.

This function was introduced in Qt 5.12.

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.

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