The QKnxNetIpServerDescriptionAgent class establishes a point-to-point connection with a KNXnet/IP server and requests its description. 更多...
头: | #include <QKnxNetIpServerDescriptionAgent> |
qmake: | QT += knx |
继承: | QObject |
enum class | Error { None, Network, NotIPv4, Timeout, Unknown } |
enum class | State { NotRunning, Starting, Running, Stopping } |
QKnxNetIpServerDescriptionAgent (const QHostAddress & localAddress , quint16 port , QObject * parent = nullptr) | |
QKnxNetIpServerDescriptionAgent (const QHostAddress & localAddress , QObject * parent = nullptr) | |
QKnxNetIpServerDescriptionAgent (QObject * parent = nullptr) | |
virtual | ~QKnxNetIpServerDescriptionAgent () |
QKnxNetIpServerDescriptionAgent::Error | error () const |
QString | errorString () const |
QHostAddress | localAddress () const |
quint16 | localPort () const |
quint8 | multicastTtl () const |
bool | natAware () const |
QKnxNetIpServerInfo | serverDescription () const |
void | setLocalAddress (const QHostAddress & address ) |
void | setLocalPort (quint16 port ) |
void | setMulticastTtl (quint8 ttl ) |
void | setNatAware (bool useNat ) |
void | setTimeout (int msec ) |
QKnxNetIpServerDescriptionAgent::State | state () const |
int | timeout () const |
void | start (const QHostAddress & address , quint16 port ) |
void | start (const QKnxNetIpServerInfo & server ) |
void | start (const QKnxNetIpHpai & server ) |
void | stop () |
void | descriptionReceived (QKnxNetIpServerInfo server ) |
void | errorOccurred (QKnxNetIpServerDescriptionAgent::Error error , QString errorString ) |
void | finished () |
void | started () |
void | stateChanged (QKnxNetIpServerDescriptionAgent::State state ) |
First, the QKnxNetIpServerDiscoveryAgent class is used to search the network for available KNXnet/IP devices. After successful discovery of such a device, the server needs to be chosen to fetch the description. This can be been done as illustrated by the following code snippet:
QKnxNetIpServerDescriptionAgent descriptionAgent; QHostAddress clientLocalAddress = ... descriptionAgent.setLocalAddress(clientLocalAddress); auto server = discoveryAgent.discoveredServers()[0]; // for example descriptionAgent.start(server);
When the description is received from the server, the descriptionReceived () signal is emitted. The description received through this point-to-point connection may be more complete than the one sent during discovery.
另请参阅 Qt KNXnet/IP Connection Classes .
This enum value holds the type of an error that occurred.
常量 | 值 | 描述 |
---|---|---|
QKnxNetIpServerDescriptionAgent::Error::None
|
0
|
No errors occurred. |
QKnxNetIpServerDescriptionAgent::Error::Network
|
1
|
发生网络错误。 |
QKnxNetIpServerDescriptionAgent::Error::NotIPv4
|
2
|
The network protocol used is not IPv4. |
QKnxNetIpServerDescriptionAgent::Error::Timeout
|
3
|
A timeout occurred while waiting for the description response. |
QKnxNetIpServerDescriptionAgent::Error::Unknown
|
0x80
|
出现未知错误。 |
This enum value holds the state of the description agent.
常量 | 值 | 描述 |
---|---|---|
QKnxNetIpServerDescriptionAgent::State::NotRunning
|
0
|
The description agent is not running. |
QKnxNetIpServerDescriptionAgent::State::Starting
|
1
|
The description agent is starting up. |
QKnxNetIpServerDescriptionAgent::State::Running
|
2
|
The description agent is running. |
QKnxNetIpServerDescriptionAgent::State::Stopping
|
3
|
The description agent is stopping. |
Creates a KNXnet/IP server description agent with the host address localAddress , the port number port , and the parent parent .
注意: If the port number is already bound by a different process, description requests will fail.
Creates a KNXnet/IP server description agent with the host address localAddress and the parent parent .
Creates a KNXnet/IP server description agent with the parent parent .
[signal]
void
QKnxNetIpServerDescriptionAgent::
descriptionReceived
(
QKnxNetIpServerInfo
server
)
This signal is emitted when the description of server is received.
[signal]
void
QKnxNetIpServerDescriptionAgent::
errorOccurred
(
QKnxNetIpServerDescriptionAgent::Error
error
,
QString
errorString
)
This signal is emitted when the error error with the message errorString 出现。
[signal]
void
QKnxNetIpServerDescriptionAgent::
finished
()
This signal is emitted when the description agent has finished.
[slot]
void
QKnxNetIpServerDescriptionAgent::
start
(const
QHostAddress
&
address
,
quint16
port
)
Starts the server description agent at the host address address and port number port .
[slot]
void
QKnxNetIpServerDescriptionAgent::
start
(const
QKnxNetIpServerInfo
&
server
)
Starts the server description agent server .
[slot]
void
QKnxNetIpServerDescriptionAgent::
start
(const
QKnxNetIpHpai
&
server
)
Starts the server description agent server .
[signal]
void
QKnxNetIpServerDescriptionAgent::
started
()
This signal is emitted when the description agent starts.
[signal]
void
QKnxNetIpServerDescriptionAgent::
stateChanged
(
QKnxNetIpServerDescriptionAgent::State
state
)
This signal is emitted when the state of the description agent changes to state .
[slot]
void
QKnxNetIpServerDescriptionAgent::
stop
()
Stops a server description agent.
[虚拟]
QKnxNetIpServerDescriptionAgent::
~QKnxNetIpServerDescriptionAgent
()
Deletes a KNXnet/IP server description agent.
Returns the type of an error that occurred when receiving the server description.
Returns a human-readable string that describes an error.
Returns the host address of a description agent.
另请参阅 setLocalAddress ().
Returns the port number used by a description agent.
另请参阅 setLocalPort ().
Returns the time to live (TTL) used for multicast search response messages. TTL is the maximum number of IP routers that may route the message. Each IP router that the message passes decrements the TTL by one. When the TTL has reached zero, the message is discarded.
另请参阅 setMulticastTtl ().
返回
true
if the server description agent uses network address translation (NAT).
另请参阅 setNatAware ().
Returns a description of a server.
Sets the host address of a description agent to address .
注意: If the address changes during a description request, the new address will not be used until the next run.
另请参阅 localAddress ().
Sets the port number used by a description agent to port .
注意: If the port changes during a description request, the new port will not be used until the next run.
另请参阅 localPort ().
Sets the TTL used for multicasting to
ttl
。值
1
means that the message does not leave the local network.
另请参阅 multicastTtl ().
Sets whether the server description agent is using NAT to useNat .
注意: If the setting changes during a description request, it will not be used until the next run.
另请参阅 natAware ().
Sets the timeout for the description agent to
msec
。若
msec
is
-1
, the agent will not timeout and has to be terminated by calling the
stop
函数。
另请参阅 timeout .
Returns the state of a KNXnet/IP server description agent.
Returns the timeout value used by the description agent to wait for incoming search response messages. The default value is 3000 milliseconds.
另请参阅 setTimeout .