QCoapProtocol Class
The QCoapProtocol class handles the logical part of the CoAP protocol. More...
Header: | #include <QCoapProtocol> |
Inherits: | QObject |
Public Functions
QCoapProtocol(QObject *parent = nullptr) | |
double | ackRandomFactor() const |
uint | ackTimeout() const |
quint16 | blockSize() const |
uint | maximumLatency() const |
uint | maximumRetransmitCount() const |
uint | maximumServerResponseDelay() const |
uint | maximumTimeout() const |
uint | maximumTransmitSpan() const |
uint | maximumTransmitWait() const |
uint | minimumTimeout() const |
uint | nonConfirmLifetime() const |
void | setAckRandomFactor(double ackRandomFactor) |
void | setAckTimeout(uint ackTimeout) |
void | setBlockSize(quint16 blockSize) |
void | setMaximumRetransmitCount(uint maximumRetransmitCount) |
void | setMaximumServerResponseDelay(uint responseDelay) |
void | setMinimumTokenSize(int tokenSize) |
Detailed Description
\internal
\inmodule
QtCoap
\reentrant
The QCoapProtocol is used by the QCoapClient class to handle the logical part of the protocol. It can encode requests and decode replies. It also handles what to do when a message is received, along with retransmission of lost messages.
See also QCoapClient.
Member Function Documentation
[explicit]
QCoapProtocol::QCoapProtocol(QObject *parent = nullptr)
\internal
Constructs a new QCoapProtocol and sets parent as the parent object.
double QCoapProtocol::ackRandomFactor() const
\internal
Returns the ACK_RANDOM_FACTOR value. The default is 1.5.
See also setAckRandomFactor().
uint QCoapProtocol::ackTimeout() const
\internal
Returns the ACK_TIMEOUT value in milliseconds. The default is 2000.
See also minimumTimeout() and setAckTimeout().
quint16 QCoapProtocol::blockSize() const
\internal
Returns the maximum block size wanted. The default is 0, which invites the server to choose the block size.
See also setBlockSize().
uint QCoapProtocol::maximumLatency() const
\internal
Returns the MAX_LATENCY in milliseconds, as defined in RFC 7252. This value is arbitrarily set to 100 seconds by the standard.
It is the maximum time a datagram is expected to take from the start of its transmission to the completion of its reception.
uint QCoapProtocol::maximumRetransmitCount() const
\internal
Returns the MAX_RETRANSMIT value. This is the maximum number of retransmissions of a message, before notifying a timeout error. The default is 4.
See also setMaximumRetransmitCount().
uint QCoapProtocol::maximumServerResponseDelay() const
\internal
Returns the MAX_SERVER_RESPONSE_DELAY
in milliseconds, as defined in RFC 7390 - Section 2.5.
It is the expected maximum response delay over all servers that the client can send a multicast request to.
See also setMaximumServerResponseDelay().
uint QCoapProtocol::maximumTimeout() const
\internal
Returns the maximum duration for messages timeout in milliseconds.
See also maximumTimeout(), setAckTimeout(), and setAckRandomFactor().
uint QCoapProtocol::maximumTransmitSpan() const
\internal
Returns the MAX_TRANSMIT_SPAN in milliseconds, as defined in RFC 7252.
It is the maximum time from the first transmission of a Confirmable message to its last retransmission.
uint QCoapProtocol::maximumTransmitWait() const
\internal
Returns the MAX_TRANSMIT_WAIT in milliseconds, as defined in RFC 7252.
It is the maximum time from the first transmission of a Confirmable message to the time when the sender gives up on receiving an acknowledgment or reset.
uint QCoapProtocol::minimumTimeout() const
\internal
Returns the minimum duration for messages timeout. The timeout is defined as a random value between minimumTimeout() and maximumTimeout(). This is a convenience method identical to ackTimeout().
See also ackTimeout() and setAckTimeout().
uint QCoapProtocol::nonConfirmLifetime() const
\internal
Returns the NON_LIFETIME
in milliseconds, as defined in RFC 7252.
It is the time from sending a non-confirmable message to the time its message ID can be safely reused.
[invokable]
void QCoapProtocol::setAckRandomFactor(double ackRandomFactor)
\internal
Sets the ACK_RANDOM_FACTOR value to ackRandomFactor. This value should be greater than or equal to 1. The default is 1.5.
Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.
See also ackRandomFactor() and setAckTimeout().
[invokable]
void QCoapProtocol::setAckTimeout(uint ackTimeout)
\internal
Sets the ACK_TIMEOUT value to ackTimeout in milliseconds. The default is 2000 ms.
Timeout only applies to Confirmable message. The actual timeout for reliable transmissions is a random value between ackTimeout() and ackTimeout() * ackRandomFactor().
Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.
See also ackTimeout(), setAckRandomFactor(), minimumTimeout(), and maximumTimeout().
[invokable]
void QCoapProtocol::setBlockSize(quint16 blockSize)
\internal
Sets the maximum block size wanted to blockSize.
The blockSize should be zero, or range from 16 to 1024 and be a power of 2. A size of 0 invites the server to choose the block size.
Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.
See also blockSize().
[invokable]
void QCoapProtocol::setMaximumRetransmitCount(uint maximumRetransmitCount)
\internal
Sets the MAX_RETRANSMIT value to maximumRetransmitCount, but never to more than 25. The default is 4.
Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.
See also maximumRetransmitCount().
[invokable]
void QCoapProtocol::setMaximumServerResponseDelay(uint responseDelay)
\internal
Sets the MAX_SERVER_RESPONSE_DELAY
value to responseDelay in milliseconds. The default is 250 seconds.
As defined in RFC 7390 - Section 2.5, MAX_SERVER_RESPONSE_DELAY
is the expected maximum response delay over all servers that the client can send a multicast request to.
Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.
See also maximumServerResponseDelay().
[invokable]
void QCoapProtocol::setMinimumTokenSize(int tokenSize)
\internal
Sets the minimum token size to tokenSize in bytes. For security reasons it is recommended to use tokens with a length of at least 4 bytes. The default value for this parameter is 4 bytes.
Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.