aboutsummaryrefslogtreecommitdiffstats
path: root/src/coap/qcoapclient.cpp
diff options
context:
space:
mode:
authorSona Kurazyan <sona.kurazyan@qt.io>2019-04-01 14:50:17 +0200
committerSona Kurazyan <sona.kurazyan@qt.io>2019-04-10 07:30:13 +0000
commit1587a5a78437f12f62b68fd484896ade280e3acc (patch)
treeddd3d79b0cbc5c6f8213fcda8b1dcdaa827d05a2 /src/coap/qcoapclient.cpp
parent6473d2e8072d34039537546d59fd02e3347dba29 (diff)
Remove the disabled method for setting a custom protocol
Firstly, the current QCoapProtocol interface only supports customizing some parameters like timeouts, counters, etc., which can also be done via the QCoapClient class, so there is no need for a setter method for the protocol. Secondly, the protocol runs on a separate thread, so it is not a good idea to allow users to change the protocol at runtime. Even if later we decide to support custom protocols, it can be set during the construction of the client. So the setter method is not needed. Removed the setter method and added the missing methods for customizing protocol-related parameters. Change-Id: I89375ac502be4d29d3cb617da9c2f99a3ab410ec Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'src/coap/qcoapclient.cpp')
-rw-r--r--src/coap/qcoapclient.cpp45
1 files changed, 38 insertions, 7 deletions
diff --git a/src/coap/qcoapclient.cpp b/src/coap/qcoapclient.cpp
index 5ae92a5..b438ba6 100644
--- a/src/coap/qcoapclient.cpp
+++ b/src/coap/qcoapclient.cpp
@@ -638,16 +638,47 @@ void QCoapClient::setMaxServerResponseDelay(uint responseDelay)
Q_ARG(uint, responseDelay));
}
-#if 0
-//! Disabled until fully supported
/*!
- Sets the protocol used by the client. Allows use of a custom protocol.
+ Sets the \c ACK_TIMEOUT value defined in \l {RFC 7252 - Section 4.2} to
+ \a ackTimeout in milliseconds. The default is 2000 ms.
+
+ This timeout only applies to confirmable messages. The actual timeout for
+ reliable transmissions is a random value between \c ACK_TIMEOUT and
+ \c {ACK_TIMEOUT * ACK_RANDOM_FACTOR}.
+
+ \sa setAckRandomFactor()
+*/
+void QCoapClient::setAckTimeout(uint ackTimeout)
+{
+ Q_D(QCoapClient);
+ QMetaObject::invokeMethod(d->protocol, "setAckTimeout", Qt::QueuedConnection,
+ Q_ARG(uint, ackTimeout));
+}
+
+/*!
+ Sets the \c ACK_RANDOM_FACTOR value defined in \l {RFC 7252 - Section 4.2},
+ to \a ackRandomFactor. This value should be greater than or equal to 1.
+ The default is 1.5.
+
+ \sa setAckTimeout()
+*/
+void QCoapClient::setAckRandomFactor(double ackRandomFactor)
+{
+ Q_D(QCoapClient);
+ QMetaObject::invokeMethod(d->protocol, "setAckRandomFactor", Qt::QueuedConnection,
+ Q_ARG(double, ackRandomFactor));
+}
+
+/*!
+ Sets the \c MAX_RETRANSMIT value defined in \l {RFC 7252 - Section 4.2}
+ to \a maxRetransmit. This value should be less than or equal to 25.
+ The default is 4.
*/
-void QCoapClient::setProtocol(QCoapProtocol *protocol)
+void QCoapClient::setMaxRetransmit(uint maxRetransmit)
{
Q_D(QCoapClient);
- // FIXME: Protocol running on incorrect thread
- d->protocol = protocol;
+ QMetaObject::invokeMethod(d->protocol, "setMaxRetransmit", Qt::QueuedConnection,
+ Q_ARG(uint, maxRetransmit));
}
-#endif
+
QT_END_NAMESPACE