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. 更多...

头: #include <QKnxNetIpEndpointConnection>
qmake: QT += knx
继承: QObject
继承者:

QKnxNetIpDeviceManagement and QKnxNetIpTunnel

公共类型

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 }

公共函数

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

信号

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

详细描述

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.

另请参阅 Qt KNXnet/IP Connection Classes .

成员类型文档编制

enum class QKnxNetIpEndpointConnection:: EndpointType

This enum holds the endpoint type.

常量
QKnxNetIpEndpointConnection::EndpointType::Data 0
QKnxNetIpEndpointConnection::EndpointType::Control 1

enum class QKnxNetIpEndpointConnection:: Error

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

常量 描述
QKnxNetIpEndpointConnection::Error::None 0 No errors so far.
QKnxNetIpEndpointConnection::Error::State 1
QKnxNetIpEndpointConnection::Error::Network 2 Detected errors in the internal UDP socket connection.
QKnxNetIpEndpointConnection::Error::NotIPv4 3 Host or remote IPs not version 4.
QKnxNetIpEndpointConnection::Error::Acknowledge 4 No response to connect/disconnect request.
QKnxNetIpEndpointConnection::Error::Heartbeat 5 State request timeout.
QKnxNetIpEndpointConnection::Error::Cemi 6 No cEMI frame acknowledge in time.
QKnxNetIpEndpointConnection::Error::SecureConfig 7 An invalid secure configuration was used to establish the connection.
QKnxNetIpEndpointConnection::Error::SerialNumber 8 An invalid serial number was set for the device.
QKnxNetIpEndpointConnection::Error::AuthFailed 9 The secure client was not successfully authenticated.
QKnxNetIpEndpointConnection::Error::Timeout 10 A timeout occurred during secure session handshake.
QKnxNetIpEndpointConnection::Error::Close 11 The server requested to close the secure session.
QKnxNetIpEndpointConnection::Error::Unknown 0x80 出现未知错误。

enum QKnxNetIpEndpointConnection:: SequenceType

This enum holds the sequence type.

常量
QKnxNetIpEndpointConnection::Send 0
QKnxNetIpEndpointConnection::Receive 1

enum QKnxNetIpEndpointConnection:: State

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

常量 描述
QKnxNetIpEndpointConnection::Disconnected 0 Error found establishing the connection, or disconnect response received.
QKnxNetIpEndpointConnection::Starting 1 Preparing internal parameters for establishing the connection.
QKnxNetIpEndpointConnection::Bound 2 Internal UDP socket is ready for receiving packets, but the connection is not yet established.
QKnxNetIpEndpointConnection::Connecting 3 Connection request sent but no answer from the server.
QKnxNetIpEndpointConnection::Connected 4 Connection response received and connection is established.
QKnxNetIpEndpointConnection::Disconnecting 5 Disconnect request sent.

成员函数文档编制

[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 改变。

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

该函数在 Qt 5.12 引入。

void QKnxNetIpEndpointConnection:: connectToHostEncrypted (const QKnxNetIpHpai & controlEndpoint )

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

该函数在 Qt 5.13 引入。

另请参阅 setSerialNumber () 和 setSecureConfiguration ().

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

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

该函数在 Qt 5.13 引入。

另请参阅 setSerialNumber () 和 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.

另请参阅 setHeartbeatTimeout ().

QHostAddress QKnxNetIpEndpointConnection:: localAddress () const

Returns the local address associated with the connection.

另请参阅 setLocalAddress ().

quint16 QKnxNetIpEndpointConnection:: localPort () const

Returns the local port associated with the connection.

另请参阅 setLocalPort ().

bool QKnxNetIpEndpointConnection:: natAware () const

返回 true if the connection uses NAT; false 否则。

另请参阅 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.

该函数在 Qt 5.13 引入。

另请参阅 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 .

该函数在 Qt 5.13 引入。

另请参阅 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.

另请参阅 heartbeatTimeout ().

void QKnxNetIpEndpointConnection:: setLocalAddress (const QHostAddress & address )

Sets the local address address associated with the connection.

另请参阅 localAddress ().

void QKnxNetIpEndpointConnection:: setLocalPort ( quint16 port )

Sets the local port port associated with the connection.

另请参阅 localPort ().

void QKnxNetIpEndpointConnection:: setNatAware ( bool isAware )

Sets the connection to use NAT based on the isAware 参数。

另请参阅 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.

该函数在 Qt 5.13 引入。

另请参阅 secureConfiguration ().

void QKnxNetIpEndpointConnection:: setSerialNumber (const QKnxByteArray & serialNumber )

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

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

该函数在 Qt 5.13 引入。

另请参阅 serialNumber ().

void QKnxNetIpEndpointConnection:: setSupportedProtocolVersions (const QKnxByteArray & versions )

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

另请参阅 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.

另请参阅 setSupportedProtocolVersions ().