aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/coap/coap.pro1
-rw-r--r--src/coap/qcoapclient.cpp2
-rw-r--r--src/coap/qcoapclient_p.h1
-rw-r--r--src/coap/qcoapdiscoveryreply.h1
-rw-r--r--src/coap/qcoapprotocol.cpp44
-rw-r--r--src/coap/qcoapprotocol.h96
-rw-r--r--src/coap/qcoapprotocol_p.h56
-rw-r--r--tests/auto/qcoapclient/tst_qcoapclient.cpp1
8 files changed, 98 insertions, 104 deletions
diff --git a/src/coap/coap.pro b/src/coap/coap.pro
index 11e6932..fc81397 100644
--- a/src/coap/coap.pro
+++ b/src/coap/coap.pro
@@ -12,7 +12,6 @@ PUBLIC_HEADERS += \
qcoapmessage.h \
qcoapnamespace.h \
qcoapoption.h \
- qcoapprotocol.h \
qcoapreply.h \
qcoaprequest.h \
qcoapresource.h \
diff --git a/src/coap/qcoapclient.cpp b/src/coap/qcoapclient.cpp
index 21af3e2..197e407 100644
--- a/src/coap/qcoapclient.cpp
+++ b/src/coap/qcoapclient.cpp
@@ -610,8 +610,6 @@ void QCoapClient::setSecurityConfiguration(const QCoapSecurityConfiguration &con
Sets the maximum block size used by the protocol to \a blockSize
when sending requests and receiving replies. The block size must be
a power of two.
-
- \sa QCoapProtocol::setBlockSize()
*/
void QCoapClient::setBlockSize(quint16 blockSize)
{
diff --git a/src/coap/qcoapclient_p.h b/src/coap/qcoapclient_p.h
index 60cd59d..e853f60 100644
--- a/src/coap/qcoapclient_p.h
+++ b/src/coap/qcoapclient_p.h
@@ -32,7 +32,6 @@
#define QCOAPCLIENT_P_H
#include <QtCoap/qcoapclient.h>
-#include <QtCoap/qcoapprotocol.h>
#include <QtCore/qthread.h>
#include <QtCore/qpointer.h>
#include <private/qobject_p.h>
diff --git a/src/coap/qcoapdiscoveryreply.h b/src/coap/qcoapdiscoveryreply.h
index 0a09ccf..9411192 100644
--- a/src/coap/qcoapdiscoveryreply.h
+++ b/src/coap/qcoapdiscoveryreply.h
@@ -33,7 +33,6 @@
#include <QtCoap/qcoapreply.h>
#include <QtCoap/qcoapresource.h>
-#include <QtCoap/qcoapprotocol.h>
#include <QtCore/qlist.h>
QT_BEGIN_NAMESPACE
diff --git a/src/coap/qcoapprotocol.cpp b/src/coap/qcoapprotocol.cpp
index 63ee393..0e50452 100644
--- a/src/coap/qcoapprotocol.cpp
+++ b/src/coap/qcoapprotocol.cpp
@@ -43,6 +43,8 @@ QT_BEGIN_NAMESPACE
Q_LOGGING_CATEGORY(lcCoapProtocol, "qt.coap.protocol")
/*!
+ \internal
+
\class QCoapProtocol
\inmodule QtCoap
@@ -60,6 +62,8 @@ Q_LOGGING_CATEGORY(lcCoapProtocol, "qt.coap.protocol")
*/
/*!
+ \internal
+
\fn void QCoapProtocol::finished(QCoapReply *reply)
This signal is emitted along with the \l QCoapReply::finished() signal
@@ -71,6 +75,8 @@ Q_LOGGING_CATEGORY(lcCoapProtocol, "qt.coap.protocol")
*/
/*!
+ \internal
+
\fn void QCoapProtocol::responseToMulticastReceived(QCoapReply *reply,
const QCoapMessage& message,
const QHostAddress &sender)
@@ -84,6 +90,8 @@ Q_LOGGING_CATEGORY(lcCoapProtocol, "qt.coap.protocol")
*/
/*!
+ \internal
+
\fn void QCoapProtocol::error(QCoapReply *reply, QtCoap::Error error)
This signal is emitted whenever an error occurs. The \a reply parameter
@@ -94,6 +102,8 @@ Q_LOGGING_CATEGORY(lcCoapProtocol, "qt.coap.protocol")
*/
/*!
+ \internal
+
Constructs a new QCoapProtocol and sets \a parent as the parent object.
*/
QCoapProtocol::QCoapProtocol(QObject *parent) :
@@ -876,6 +886,8 @@ bool QCoapProtocolPrivate::isMessageIdRegistered(quint16 id) const
}
/*!
+ \internal
+
Returns the ACK_TIMEOUT value in milliseconds.
The default is 2000.
@@ -888,6 +900,8 @@ uint QCoapProtocol::ackTimeout() const
}
/*!
+ \internal
+
Returns the ACK_RANDOM_FACTOR value.
The default is 1.5.
@@ -900,6 +914,8 @@ double QCoapProtocol::ackRandomFactor() 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.
@@ -913,6 +929,8 @@ uint QCoapProtocol::maxRetransmit() const
}
/*!
+ \internal
+
Returns the max block size wanted.
The default is 0, which invites the server to choose the block size.
@@ -925,6 +943,8 @@ quint16 QCoapProtocol::blockSize() const
}
/*!
+ \internal
+
Returns the MAX_TRANSMIT_SPAN in milliseconds, as defined in
\l{https://tools.ietf.org/search/rfc7252#section-4.8.2}{RFC 7252}.
@@ -937,6 +957,8 @@ uint QCoapProtocol::maxTransmitSpan() const
}
/*!
+ \internal
+
Returns the MAX_TRANSMIT_WAIT in milliseconds, as defined in
\l{https://tools.ietf.org/search/rfc7252#section-4.8.2}{RFC 7252}.
@@ -951,6 +973,8 @@ uint QCoapProtocol::maxTransmitWait() const
}
/*!
+ \internal
+
Returns the MAX_LATENCY in milliseconds, as defined in
\l{https://tools.ietf.org/search/rfc7252#section-4.8.2}{RFC 7252}. This
value is arbitrarily set to 100 seconds by the standard.
@@ -964,6 +988,8 @@ constexpr uint QCoapProtocol::maxLatency()
}
/*!
+ \internal
+
Returns the minimum duration for messages timeout. The timeout is defined
as a random value between minTimeout() and maxTimeout(). This is a
convenience method identical to ackTimeout().
@@ -977,6 +1003,8 @@ uint QCoapProtocol::minTimeout() const
}
/*!
+ \internal
+
Returns the maximum duration for messages timeout in milliseconds.
\sa maxTimeout(), setAckTimeout(), setAckRandomFactor()
@@ -988,6 +1016,8 @@ uint QCoapProtocol::maxTimeout() const
}
/*!
+ \internal
+
Returns the \c NON_LIFETIME in milliseconds, as defined in
\l{https://tools.ietf.org/search/rfc7252#section-4.8.2}{RFC 7252}.
@@ -1000,6 +1030,8 @@ uint QCoapProtocol::nonConfirmLifetime() const
}
/*!
+ \internal
+
Returns the \c MAX_SERVER_RESPONSE_DELAY in milliseconds, as defined in
\l {RFC 7390 - Section 2.5}.
@@ -1015,6 +1047,8 @@ uint QCoapProtocol::maxServerResponseDelay() const
}
/*!
+ \internal
+
Sets the ACK_TIMEOUT value to \a ackTimeout in milliseconds.
The default is 2000 ms.
@@ -1031,6 +1065,8 @@ void QCoapProtocol::setAckTimeout(uint ackTimeout)
}
/*!
+ \internal
+
Sets the ACK_RANDOM_FACTOR value to \a ackRandomFactor. This value
should be greater than or equal to 1.
The default is 1.5.
@@ -1047,6 +1083,8 @@ void QCoapProtocol::setAckRandomFactor(double ackRandomFactor)
}
/*!
+ \internal
+
Sets the MAX_RETRANSMIT value to \a maxRetransmit, but never
to more than 25.
The default is 4.
@@ -1066,6 +1104,8 @@ void QCoapProtocol::setMaxRetransmit(uint maxRetransmit)
}
/*!
+ \internal
+
Sets the max block size wanted to \a blockSize.
The \a blockSize should be zero, or range from 16 to 1024 and be a
@@ -1092,6 +1132,8 @@ void QCoapProtocol::setBlockSize(quint16 blockSize)
}
/*!
+ \internal
+
Sets the \c MAX_SERVER_RESPONSE_DELAY value to \a responseDelay in milliseconds.
The default is 250 seconds.
@@ -1107,5 +1149,3 @@ void QCoapProtocol::setMaxServerResponseDelay(uint responseDelay)
}
QT_END_NAMESPACE
-
-#include "moc_qcoapprotocol.cpp"
diff --git a/src/coap/qcoapprotocol.h b/src/coap/qcoapprotocol.h
deleted file mode 100644
index 0c91443..0000000
--- a/src/coap/qcoapprotocol.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 Witekio.
-** Copyright (C) 2018 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtCoap module.
-**
-** $QT_BEGIN_LICENSE:GPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) any later version
-** approved by the KDE Free Qt Foundation. The licenses are as published by
-** the Free Software Foundation and appearing in the file LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QCOAPPROTOCOL_H
-#define QCOAPPROTOCOL_H
-
-#include <QtCoap/qcoapglobal.h>
-#include <QtCoap/qcoapreply.h>
-#include <QtCoap/qcoapresource.h>
-#include <QtCore/qobject.h>
-#include <QtNetwork/qudpsocket.h>
-#include <QtNetwork/qhostaddress.h>
-
-QT_BEGIN_NAMESPACE
-
-class QCoapInternalRequest;
-class QCoapInternalReply;
-class QCoapProtocolPrivate;
-class QCoapConnection;
-class Q_COAP_EXPORT QCoapProtocol : public QObject
-{
- Q_OBJECT
-public:
- explicit QCoapProtocol(QObject *parent = nullptr);
- ~QCoapProtocol();
-
- uint ackTimeout() const;
- double ackRandomFactor() const;
- uint maxRetransmit() const;
- quint16 blockSize() const;
- uint maxTransmitSpan() const;
- uint maxTransmitWait() const;
- static constexpr uint maxLatency();
-
- uint minTimeout() const;
- uint maxTimeout() const;
-
- uint nonConfirmLifetime() const;
- uint maxServerResponseDelay() const;
-
-Q_SIGNALS:
- void finished(QCoapReply *reply);
- void responseToMulticastReceived(QCoapReply *reply, const QCoapMessage &message,
- const QHostAddress &sender);
- void error(QCoapReply *reply, QtCoap::Error error);
-
-public:
- Q_INVOKABLE void setAckTimeout(uint ackTimeout);
- Q_INVOKABLE void setAckRandomFactor(double ackRandomFactor);
- Q_INVOKABLE void setMaxRetransmit(uint maxRetransmit);
- Q_INVOKABLE void setBlockSize(quint16 blockSize);
- Q_INVOKABLE void setMaxServerResponseDelay(uint responseDelay);
-
-private:
- Q_INVOKABLE void sendRequest(QPointer<QCoapReply> reply, QCoapConnection *connection);
- Q_INVOKABLE void cancelObserve(QPointer<QCoapReply> reply) const;
- Q_INVOKABLE void cancelObserve(const QUrl &url) const;
-
-private:
- Q_DECLARE_PRIVATE(QCoapProtocol)
-
- friend class QCoapClient;
-};
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(QHostAddress)
-
-#endif // QCOAPPROTOCOL_H
diff --git a/src/coap/qcoapprotocol_p.h b/src/coap/qcoapprotocol_p.h
index 602ef73..b50453f 100644
--- a/src/coap/qcoapprotocol_p.h
+++ b/src/coap/qcoapprotocol_p.h
@@ -31,10 +31,13 @@
#ifndef QCOAPPROTOCOL_P_H
#define QCOAPPROTOCOL_P_H
-#include <QtCoap/qcoapprotocol.h>
+#include <QtCoap/qcoapglobal.h>
+#include <QtCoap/qcoapreply.h>
+#include <QtCoap/qcoapresource.h>
#include <QtCore/qvector.h>
#include <QtCore/qqueue.h>
#include <QtCore/qpointer.h>
+#include <QtCore/qobject.h>
#include <private/qobject_p.h>
//
@@ -50,6 +53,55 @@
QT_BEGIN_NAMESPACE
+class QCoapInternalRequest;
+class QCoapInternalReply;
+class QCoapProtocolPrivate;
+class QCoapConnection;
+class Q_AUTOTEST_EXPORT QCoapProtocol : public QObject
+{
+ Q_OBJECT
+public:
+ explicit QCoapProtocol(QObject *parent = nullptr);
+ ~QCoapProtocol();
+
+ uint ackTimeout() const;
+ double ackRandomFactor() const;
+ uint maxRetransmit() const;
+ quint16 blockSize() const;
+ uint maxTransmitSpan() const;
+ uint maxTransmitWait() const;
+ static constexpr uint maxLatency();
+
+ uint minTimeout() const;
+ uint maxTimeout() const;
+
+ uint nonConfirmLifetime() const;
+ uint maxServerResponseDelay() const;
+
+Q_SIGNALS:
+ void finished(QCoapReply *reply);
+ void responseToMulticastReceived(QCoapReply *reply, const QCoapMessage &message,
+ const QHostAddress &sender);
+ void error(QCoapReply *reply, QtCoap::Error error);
+
+public:
+ Q_INVOKABLE void setAckTimeout(uint ackTimeout);
+ Q_INVOKABLE void setAckRandomFactor(double ackRandomFactor);
+ Q_INVOKABLE void setMaxRetransmit(uint maxRetransmit);
+ Q_INVOKABLE void setBlockSize(quint16 blockSize);
+ Q_INVOKABLE void setMaxServerResponseDelay(uint responseDelay);
+
+private:
+ Q_INVOKABLE void sendRequest(QPointer<QCoapReply> reply, QCoapConnection *connection);
+ Q_INVOKABLE void cancelObserve(QPointer<QCoapReply> reply) const;
+ Q_INVOKABLE void cancelObserve(const QUrl &url) const;
+
+private:
+ Q_DECLARE_PRIVATE(QCoapProtocol)
+
+ friend class QCoapClient;
+};
+
struct CoapExchangeData {
QPointer<QCoapReply> userReply;
QSharedPointer<QCoapInternalRequest> request;
@@ -115,4 +167,6 @@ public:
QT_END_NAMESPACE
+Q_DECLARE_METATYPE(QHostAddress)
+
#endif // QCOAPPROTOCOL_P_H
diff --git a/tests/auto/qcoapclient/tst_qcoapclient.cpp b/tests/auto/qcoapclient/tst_qcoapclient.cpp
index 90b44cf..2a9f9d4 100644
--- a/tests/auto/qcoapclient/tst_qcoapclient.cpp
+++ b/tests/auto/qcoapclient/tst_qcoapclient.cpp
@@ -39,6 +39,7 @@
#include <QtNetwork/qnetworkdatagram.h>
#include <private/qcoapclient_p.h>
#include <private/qcoapqudpconnection_p.h>
+#include <private/qcoapprotocol_p.h>
#include "../coapnetworksettings.h"