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 |
继承者: |
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 .
This enum holds the endpoint type.
常量 | 值 |
---|---|
QKnxNetIpEndpointConnection::EndpointType::Data
|
0
|
QKnxNetIpEndpointConnection::EndpointType::Control
|
1
|
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
|
出现未知错误。 |
This enum holds the sequence type.
常量 | 值 |
---|---|
QKnxNetIpEndpointConnection::Send
|
0
|
QKnxNetIpEndpointConnection::Receive
|
1
|
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.
Establishes a connection to the KNXnet/IP control endpoint controlEndpoint .
Establishes a connection to the host with address and port via UDP.
Establishes a connection to the host with address , port and protocol .
该函数在 Qt 5.12 引入。
Establishes a connection to the KNXnet/IP control endpoint controlEndpoint .
该函数在 Qt 5.13 引入。
另请参阅 setSerialNumber () 和 setSecureConfiguration ().
Establishes a secure session to the host with address and port .
该函数在 Qt 5.13 引入。
另请参阅 setSerialNumber () 和 setSecureConfiguration ().
Closes an established connection.
Returns the last error code detected in the connection.
Returns an error string describing the last error detected in the connection.
Returns the value of the heartbeat timeout.
另请参阅 setHeartbeatTimeout ().
Returns the local address associated with the connection.
另请参阅 setLocalAddress ().
Returns the local port associated with the connection.
另请参阅 setLocalPort ().
返回
true
if the connection uses NAT;
false
否则。
另请参阅 setNatAware ().
Returns the KNXnet/IP header version of the data or control connection depending on endpoint .
Returns the secure configuration used to establish the secure session.
该函数在 Qt 5.13 引入。
另请参阅 setSecureConfiguration ().
Returns the received or sent sequence count based on type .
Returns the serial number of the device using this connection. The default value is set to
0x000000000000
.
该函数在 Qt 5.13 引入。
另请参阅 setSerialNumber ().
Sets the value of the heartbeat timeout. Every msec a state request is sent over the connection to keep it alive.
另请参阅 heartbeatTimeout ().
Sets the local address address associated with the connection.
另请参阅 localAddress ().
Sets the local port port associated with the connection.
另请参阅 localPort ().
Sets the connection to use NAT based on the isAware 参数。
另请参阅 natAware ().
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 ().
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 ().
Sets the connection supported KNXnet/IP versions indicated in versions .
另请参阅 supportedProtocolVersions ().
Returns the state of the connection.
Returns a byte array with the supported KNXnet/IP versions.
另请参阅 setSupportedProtocolVersions ().