aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorIvan Solovev <ivan.solovev@qt.io>2023-06-13 15:06:12 +0200
committerMarc Mutz <marc.mutz@qt.io>2023-06-21 07:45:25 +0000
commit423deb47684919d91040e399476703379065eb6b (patch)
tree27e699c358b81b75c83406db854f537e87fe20d2 /examples
parent868ce39b7056f8d882df572a82f87f40042447d6 (diff)
Remove Console CoAP Client example
The example demonstrates a subset of features from Simple CoAP Client example, but does not have any UI, and also provides only a basic documentation page. It can be safely removed, and other examples should be used instead. Task-number: QTBUG-113858 Pick-to: 6.6 6.5 Change-Id: Iec63aa530d1bf35c403151341057ceb7dd2fac66 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Sona Kurazyan <kurazyan.sona@gmail.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/coap/CMakeLists.txt1
-rw-r--r--examples/coap/coap.pro2
-rw-r--r--examples/coap/consolecoapclient/CMakeLists.txt37
-rw-r--r--examples/coap/consolecoapclient/coaphandler.cpp106
-rw-r--r--examples/coap/consolecoapclient/coaphandler.h47
-rw-r--r--examples/coap/consolecoapclient/consolecoapclient.pro14
-rw-r--r--examples/coap/consolecoapclient/main.cpp49
-rw-r--r--examples/coap/doc/consolecoapclient.qdoc9
8 files changed, 0 insertions, 265 deletions
diff --git a/examples/coap/CMakeLists.txt b/examples/coap/CMakeLists.txt
index b1028d9..2aa3a98 100644
--- a/examples/coap/CMakeLists.txt
+++ b/examples/coap/CMakeLists.txt
@@ -1,7 +1,6 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
-qt_internal_add_example(consolecoapclient)
if(TARGET Qt::Widgets)
qt_internal_add_example(simplecoapclient)
endif()
diff --git a/examples/coap/coap.pro b/examples/coap/coap.pro
index 81478f9..4002e7e 100644
--- a/examples/coap/coap.pro
+++ b/examples/coap/coap.pro
@@ -1,7 +1,5 @@
TEMPLATE = subdirs
-SUBDIRS += consolecoapclient
-
qtHaveModule(widgets): SUBDIRS += simplecoapclient
qtHaveModule(quick) {
diff --git a/examples/coap/consolecoapclient/CMakeLists.txt b/examples/coap/consolecoapclient/CMakeLists.txt
deleted file mode 100644
index 184bfa7..0000000
--- a/examples/coap/consolecoapclient/CMakeLists.txt
+++ /dev/null
@@ -1,37 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(consolecoapclient LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/coap/consolecoapclient")
-
-find_package(Qt6 REQUIRED COMPONENTS Coap Core Network)
-
-qt_add_executable(consolecoapclient
- coaphandler.cpp coaphandler.h
- main.cpp
-)
-
-set_target_properties(consolecoapclient PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(consolecoapclient PUBLIC
- Qt::Coap
- Qt::Core
- Qt::Network
-)
-
-install(TARGETS consolecoapclient
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/coap/consolecoapclient/coaphandler.cpp b/examples/coap/consolecoapclient/coaphandler.cpp
deleted file mode 100644
index 434280c..0000000
--- a/examples/coap/consolecoapclient/coaphandler.cpp
+++ /dev/null
@@ -1,106 +0,0 @@
-// Copyright (C) 2017 Witekio.
-// Copyright (C) 2018 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
-
-#include "coaphandler.h"
-
-#include <QDebug>
-#include <QLoggingCategory>
-#include <QCoapClient>
-#include <QCoapReply>
-#include <QCoapResourceDiscoveryReply>
-
-Q_LOGGING_CATEGORY(lcCoapClient, "qt.coap.client")
-
-CoapHandler::CoapHandler(QObject *parent) : QObject(parent)
-{
- connect(&m_coapClient, &QCoapClient::finished, this, &CoapHandler::onFinished);
- connect(&m_coapClient, &QCoapClient::error, this, &CoapHandler::onError);
- connect(&m_coapClient, &QCoapClient::responseToMulticastReceived,
- this, &CoapHandler::onResponseToMulticast);
-}
-
-bool CoapHandler::runGet(const QUrl &url)
-{
- return m_coapClient.get(url);
-}
-
-bool CoapHandler::runPost(const QUrl &url)
-{
- return m_coapClient.post(url);
-}
-
-bool CoapHandler::runPut(const QUrl &url)
-{
- return m_coapClient.put(url);
-}
-
-bool CoapHandler::runDelete(const QUrl &url)
-{
- return m_coapClient.deleteResource(url);
-}
-
-bool CoapHandler::runObserve(const QUrl &url)
-{
- QCoapReply *observeReply = m_coapClient.observe(url);
- if (!observeReply)
- return false;
-
- connect(observeReply, &QCoapReply::notified, this, &CoapHandler::onNotified);
- return true;
-}
-
-bool CoapHandler::runDiscover(const QUrl &url)
-{
- QCoapResourceDiscoveryReply *discoverReply = m_coapClient.discover(url);
- if (!discoverReply)
- return false;
-
- connect(discoverReply, &QCoapResourceDiscoveryReply::discovered, this, &CoapHandler::onDiscovered);
- return true;
-}
-
-void CoapHandler::onFinished(QCoapReply *reply)
-{
- if (reply->errorReceived() == QtCoap::Error::Ok)
- qCInfo(lcCoapClient) << "Request finished with payload:" << reply->readAll();
- else
- qCWarning(lcCoapClient, "Request failed");
-
- // Don't forget to remove the reply
- reply->deleteLater();
-}
-
-void CoapHandler::onNotified(QCoapReply *reply, QCoapMessage message)
-{
- Q_UNUSED(message)
-
- // You can alternatively use `message.payload();`
- qCInfo(lcCoapClient) << "Received Observe notification with payload:" << reply->readAll();
-}
-
-void CoapHandler::onDiscovered(QCoapResourceDiscoveryReply *reply, QList<QCoapResource> resources)
-{
- Q_UNUSED(reply)
-
- for (const QCoapResource &res : std::as_const(resources))
- qCInfo(lcCoapClient) << "Discovered resource:" << res.path() << res.title();
-}
-
-void CoapHandler::onResponseToMulticast(QCoapReply *reply, const QCoapMessage& message,
- const QHostAddress &sender)
-{
- if (reply->errorReceived() == QtCoap::Error::Ok)
- qCInfo(lcCoapClient) << "Got a response for multicast request from:" << sender.toString()
- << "with payload:" << message.payload();
- else
- qCWarning(lcCoapClient, "Multicast request failed");
-}
-
-void CoapHandler::onError(QCoapReply *reply, QtCoap::Error error)
-{
- if (reply)
- qCInfo(lcCoapClient) << "CoAP reply error:" << reply->errorString();
- else
- qCWarning(lcCoapClient) << "CoAP error:" << error;
-}
diff --git a/examples/coap/consolecoapclient/coaphandler.h b/examples/coap/consolecoapclient/coaphandler.h
deleted file mode 100644
index 4777c94..0000000
--- a/examples/coap/consolecoapclient/coaphandler.h
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright (C) 2017 Witekio.
-// Copyright (C) 2018 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
-
-#ifndef COAPHANDLER_H
-#define COAPHANDLER_H
-
-#include <QObject>
-#include <QCoapClient>
-#include <QCoapMessage>
-#include <QCoapResource>
-#include <qcoapnamespace.h>
-
-QT_BEGIN_NAMESPACE
-
-class QCoapReply;
-class QCoapResourceDiscoveryReply;
-class QCoapResource;
-
-QT_END_NAMESPACE
-
-class CoapHandler : public QObject
-{
- Q_OBJECT
-public:
- explicit CoapHandler(QObject *parent = nullptr);
-
- bool runGet(const QUrl &url);
- bool runPost(const QUrl &url);
- bool runPut(const QUrl &url);
- bool runDelete(const QUrl &url);
- bool runObserve(const QUrl &url);
- bool runDiscover(const QUrl &url);
-
-public Q_SLOTS:
- void onFinished(QCoapReply *reply);
- void onNotified(QCoapReply *reply, QCoapMessage message);
- void onDiscovered(QCoapResourceDiscoveryReply *reply, QList<QCoapResource> resources);
- void onResponseToMulticast(QCoapReply *reply, const QCoapMessage& message,
- const QHostAddress &sender);
- void onError(QCoapReply *reply, QtCoap::Error error);
-
-private:
- QCoapClient m_coapClient;
-};
-
-#endif // COAPHANDLER_H
diff --git a/examples/coap/consolecoapclient/consolecoapclient.pro b/examples/coap/consolecoapclient/consolecoapclient.pro
deleted file mode 100644
index 9d271ed..0000000
--- a/examples/coap/consolecoapclient/consolecoapclient.pro
+++ /dev/null
@@ -1,14 +0,0 @@
-QT -= gui
-QT += network coap
-
-TARGET = testapp
-
-HEADERS += \
- coaphandler.h
-
-SOURCES += main.cpp \
- coaphandler.cpp
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/coap/consolecoapclient
-INSTALLS += target
diff --git a/examples/coap/consolecoapclient/main.cpp b/examples/coap/consolecoapclient/main.cpp
deleted file mode 100644
index 13556e8..0000000
--- a/examples/coap/consolecoapclient/main.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright (C) 2017 Witekio.
-// Copyright (C) 2018 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
-
-#include "coaphandler.h"
-
-#include <QCoreApplication>
-#include <QCommandLineParser>
-#include <QUrl>
-
-int main(int argc, char *argv[])
-{
- QCoreApplication a(argc, argv);
-
- QCommandLineParser parser;
- parser.setApplicationDescription("Qt CoAP test application");
- parser.addHelpOption();
- parser.addPositionalArgument("url",
- "The targeted coap resource URL, e.g. 'coap://10.10.10.10/myresource'");
- parser.addOption({"get", "Use GET method for the request. This is the default method"});
- parser.addOption({"post", "Use POST method for the request"});
- parser.addOption({"put", "Use PUT method for the request"});
- parser.addOption({"delete", "Use DELETE method for the request"});
- parser.addOption({"observe", "Observe a resource"});
- parser.addOption({"discover", "Discover available resources"});
-
- parser.process(a);
-
- if (parser.positionalArguments().isEmpty()) {
- qWarning("Please provide an url for the request");
- parser.showHelp(1);
- }
-
- QUrl url = parser.positionalArguments().first();
- if (!url.isValid()) {
- qWarning("The url provided is not valid.");
- parser.showHelp(1);
- }
-
- CoapHandler handler;
- if (parser.isSet("get")) handler.runGet(url);
- if (parser.isSet("post")) handler.runPost(url);
- if (parser.isSet("put")) handler.runPut(url);
- if (parser.isSet("delete")) handler.runDelete(url);
- if (parser.isSet("observe")) handler.runObserve(url);
- if (parser.isSet("discover")) handler.runDiscover(url);
-
- return a.exec();
-}
diff --git a/examples/coap/doc/consolecoapclient.qdoc b/examples/coap/doc/consolecoapclient.qdoc
deleted file mode 100644
index 4123351..0000000
--- a/examples/coap/doc/consolecoapclient.qdoc
+++ /dev/null
@@ -1,9 +0,0 @@
-// Copyright (C) 2019 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-
-/*!
- \example consolecoapclient
- \title Console CoAP Client Example
- \ingroup qtcoap-examples
- \brief Creating a simple console application that communicates with a CoAP server.
-*/