The QKnxNetIpHpaiProxy class provides the means to read the KNXnet/IP host address protocol information (HPAI) from the generic QKnxNetIpHpai class and to create such a structure. 更多...
头: | #include <QKnxNetIpHpaiProxy> |
qmake: | QT += knx |
class | Builder |
QKnxNetIpHpaiProxy (const QKnxNetIpHpai & hpai ) | |
QHostAddress | hostAddress () const |
QKnxNetIp::HostProtocol | hostProtocol () const |
bool | isValid () const |
quint16 | port () const |
QKnxNetIpHpaiProxy::Builder | builder () |
A KNXnet/IP HPAI structure contains the information that is necessary to uniquely identify an KNXnet/IP transport connection endpoint.
The information needed to identify an KNXnet/IP transport connection endpoint includes the protocol , IP 地址 ,和 port 编号。
注意: When using QKnxNetIpHpaiProxy care must be taken to ensure that the referenced KNXnet/IP HPAI structure outlives the QKnxNetIpHpaiProxy on all code paths, lest the proxy ends up referencing deleted data.
Reading the host address and port number can be achieved like this:
auto hpai = QKnxNetIpHpai::fromBytes(...); QKnxNetIpHpaiProxy proxy(hpai); if (!proxy.isValid()) return; if (proxy.hostProtocol() == QKnxNetIp::HostProtocol::TCP_IPv4) return; // TCP support not implemented yet // read the host protocol address information auto address = proxy.hostAddress(); auto port = proxy.port();
另请参阅 builder () 和 Qt KNXnet/IP Connection Classes .
Constructs a proxy object with the given a KNXnet/IP structure hpai to read the host protocol address information (HPAI).
[static]
QKnxNetIpHpaiProxy::Builder
QKnxNetIpHpaiProxy::
builder
()
Returns a builder object to create a KNXnet/IP host protocol address information structure.
Returns the host address from KNXnet/IP structure if the object passed during construction was valid, otherwise returns a default-constructed QHostAddress .
Return the host protocol from KNXnet/IP structure if the object passed during construction was valid, otherwise returns QKnxNetIp::Unknown.
返回
true
if the KNXnet/IP structure to create the object is a valid KNXnet/IP HPAI structure, returns
false
否则。
Returns the port number carried inside the KNXnet/IP host protocol address information structure.