aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/coap/consolecoapclient/coaphandler.cpp4
-rw-r--r--examples/coap/quickmulticastclient/main.qml6
-rw-r--r--examples/coap/quickmulticastclient/qmlcoapmulticastclient.cpp2
-rw-r--r--examples/coap/quicksecureclient/main.qml4
-rw-r--r--examples/coap/quicksecureclient/qmlcoapsecureclient.cpp6
-rw-r--r--examples/coap/simplecoapclient/mainwindow.cpp32
6 files changed, 27 insertions, 27 deletions
diff --git a/examples/coap/consolecoapclient/coaphandler.cpp b/examples/coap/consolecoapclient/coaphandler.cpp
index 04ef6f3..650cf5c 100644
--- a/examples/coap/consolecoapclient/coaphandler.cpp
+++ b/examples/coap/consolecoapclient/coaphandler.cpp
@@ -88,7 +88,7 @@ bool CoapHandler::runDiscover(const QUrl &url)
void CoapHandler::onFinished(QCoapReply *reply)
{
- if (reply->errorReceived() == QtCoap::NoError)
+ if (reply->errorReceived() == QtCoap::Error::Ok)
qCInfo(lcCoapClient) << "Request finished with payload:" << reply->readAll();
else
qCWarning(lcCoapClient, "Request failed");
@@ -116,7 +116,7 @@ void CoapHandler::onDiscovered(QCoapDiscoveryReply *reply, QVector<QCoapResource
void CoapHandler::onResponseToMulticast(QCoapReply *reply, const QCoapMessage& message,
const QHostAddress &sender)
{
- if (reply->errorReceived() == QtCoap::NoError)
+ if (reply->errorReceived() == QtCoap::Error::Ok)
qCInfo(lcCoapClient) << "Got a response for multicast request from:" << sender.toString()
<< "with payload:" << message.payload();
else
diff --git a/examples/coap/quickmulticastclient/main.qml b/examples/coap/quickmulticastclient/main.qml
index da28624..85fc8dc 100644
--- a/examples/coap/quickmulticastclient/main.qml
+++ b/examples/coap/quickmulticastclient/main.qml
@@ -102,17 +102,17 @@ Window {
ListElement {
group: qsTr("IPv4 CoAP Nodes")
address: "224.0.1.187"
- value: QtCoap.AllCoapNodesIPv4
+ value: QtCoap.MulticastGroup.AllCoapNodesIPv4
}
ListElement {
group: qsTr("IPv6 Link Local CoAP Nodes")
address: "ff02::fd"
- value: QtCoap.AllCoapNodesIPv6LinkLocal
+ value: QtCoap.MulticastGroup.AllCoapNodesIPv6LinkLocal
}
ListElement {
group: qsTr("IPv6 Site Local CoAP Nodes")
address: "ff05::fd"
- value: QtCoap.AllCoapNodesIPv6SiteLocal
+ value: QtCoap.MulticastGroup.AllCoapNodesIPv6SiteLocal
}
ListElement {
group: qsTr("Other")
diff --git a/examples/coap/quickmulticastclient/qmlcoapmulticastclient.cpp b/examples/coap/quickmulticastclient/qmlcoapmulticastclient.cpp
index 6d0a1fd..4c3592b 100644
--- a/examples/coap/quickmulticastclient/qmlcoapmulticastclient.cpp
+++ b/examples/coap/quickmulticastclient/qmlcoapmulticastclient.cpp
@@ -56,7 +56,7 @@
Q_LOGGING_CATEGORY(lcCoapClient, "qt.coap.client")
QmlCoapMulticastClient::QmlCoapMulticastClient(QObject *parent)
- : QCoapClient(QtCoap::NoSec, parent)
+ : QCoapClient(QtCoap::SecurityMode::NoSec, parent)
{
connect(this, &QCoapClient::finished, this,
[this](QCoapReply *reply) {
diff --git a/examples/coap/quicksecureclient/main.qml b/examples/coap/quicksecureclient/main.qml
index 13eb478..34803a3 100644
--- a/examples/coap/quicksecureclient/main.qml
+++ b/examples/coap/quicksecureclient/main.qml
@@ -114,9 +114,9 @@ Window {
id: securityModeGroup
onClicked: {
if (securityModeGroup.checkedButton === preSharedMode)
- client.setSecurityMode(QtCoap.PreSharedKey);
+ client.setSecurityMode(QtCoap.SecurityMode.PreSharedKey);
else
- client.setSecurityMode(QtCoap.Certificate);
+ client.setSecurityMode(QtCoap.SecurityMode.Certificate);
}
}
RowLayout {
diff --git a/examples/coap/quicksecureclient/qmlcoapsecureclient.cpp b/examples/coap/quicksecureclient/qmlcoapsecureclient.cpp
index 3dda7b0..608ed0c 100644
--- a/examples/coap/quicksecureclient/qmlcoapsecureclient.cpp
+++ b/examples/coap/quicksecureclient/qmlcoapsecureclient.cpp
@@ -61,7 +61,7 @@ Q_LOGGING_CATEGORY(lcCoapClient, "qt.coap.client")
QmlCoapSecureClient::QmlCoapSecureClient(QObject *parent)
: QObject(parent)
, m_coapClient(nullptr)
- , m_securityMode(QtCoap::NoSec)
+ , m_securityMode(QtCoap::SecurityMode::NoSec)
{
}
@@ -75,7 +75,7 @@ QmlCoapSecureClient::~QmlCoapSecureClient()
static QString errorMessage(QtCoap::Error errorCode)
{
- const auto error = QMetaEnum::fromType<QtCoap::Error>().valueToKey(errorCode);
+ const auto error = QMetaEnum::fromType<QtCoap::Error>().valueToKey(static_cast<int>(errorCode));
return QString("Request failed with error: %1\n").arg(error);
}
@@ -95,7 +95,7 @@ void QmlCoapSecureClient::setSecurityMode(QtCoap::SecurityMode mode)
[this](QCoapReply *reply) {
if (!reply)
emit finished("Something went wrong, received a null reply");
- else if (reply->errorReceived() != QtCoap::NoError)
+ else if (reply->errorReceived() != QtCoap::Error::Ok)
emit finished(errorMessage(reply->errorReceived()));
else
emit finished(reply->message().payload());
diff --git a/examples/coap/simplecoapclient/mainwindow.cpp b/examples/coap/simplecoapclient/mainwindow.cpp
index 193e3e2..e5cda55 100644
--- a/examples/coap/simplecoapclient/mainwindow.cpp
+++ b/examples/coap/simplecoapclient/mainwindow.cpp
@@ -65,16 +65,16 @@ MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
- m_client = new QCoapClient(QtCoap::NoSec, this);
+ m_client = new QCoapClient(QtCoap::SecurityMode::NoSec, this);
connect(m_client, &QCoapClient::finished, this, &MainWindow::onFinished);
connect(m_client, &QCoapClient::error, this, &MainWindow::onError);
ui->setupUi(this);
- ui->methodComboBox->addItem("Get", QtCoap::Method::Get);
- ui->methodComboBox->addItem("Put", QtCoap::Method::Put);
- ui->methodComboBox->addItem("Post", QtCoap::Method::Post);
- ui->methodComboBox->addItem("Delete", QtCoap::Method::Delete);
+ ui->methodComboBox->addItem("Get", QVariant::fromValue(QtCoap::Method::Get));
+ ui->methodComboBox->addItem("Put", QVariant::fromValue(QtCoap::Method::Put));
+ ui->methodComboBox->addItem("Post", QVariant::fromValue(QtCoap::Method::Post));
+ ui->methodComboBox->addItem("Delete", QVariant::fromValue(QtCoap::Method::Delete));
fillHostSelector();
ui->hostComboBox->setFocus();
@@ -106,13 +106,13 @@ void MainWindow::addMessage(const QString &message, bool isError)
void MainWindow::onFinished(QCoapReply *reply)
{
- if (reply->errorReceived() == QtCoap::NoError)
+ if (reply->errorReceived() == QtCoap::Error::Ok)
addMessage(reply->message().payload());
}
static QString errorMessage(QtCoap::Error errorCode)
{
- const auto error = QMetaEnum::fromType<QtCoap::Error>().valueToKey(errorCode);
+ const auto error = QMetaEnum::fromType<QtCoap::Error>().valueToKey(static_cast<int>(errorCode));
return QString("Request failed with error: %1\n").arg(error);
}
@@ -124,7 +124,7 @@ void MainWindow::onError(QCoapReply *reply, QtCoap::Error error)
void MainWindow::onDiscovered(QCoapDiscoveryReply *reply, QVector<QCoapResource> resources)
{
- if (reply->errorReceived() != QtCoap::NoError)
+ if (reply->errorReceived() != QtCoap::Error::Ok)
return;
QString message;
@@ -138,7 +138,7 @@ void MainWindow::onDiscovered(QCoapDiscoveryReply *reply, QVector<QCoapResource>
void MainWindow::onNotified(QCoapReply *reply, const QCoapMessage &message)
{
- if (reply->errorReceived() == QtCoap::NoError)
+ if (reply->errorReceived() == QtCoap::Error::Ok)
addMessage("Received observe notification with payload: " + message.payload());
}
@@ -154,8 +154,8 @@ static QString tryToResolveHostName(const QString hostName)
void MainWindow::on_runButton_clicked()
{
- const auto msgType = ui->msgTypeCheckBox->isChecked() ? QCoapMessage::Confirmable
- : QCoapMessage::NonConfirmable;
+ const auto msgType = ui->msgTypeCheckBox->isChecked() ? QCoapMessage::MessageType::Confirmable
+ : QCoapMessage::MessageType::NonConfirmable;
QUrl url;
url.setHost(tryToResolveHostName(ui->hostComboBox->currentText()));
url.setPort(ui->portSpinBox->value());
@@ -168,16 +168,16 @@ void MainWindow::on_runButton_clicked()
const auto method = ui->methodComboBox->currentData(Qt::UserRole).value<QtCoap::Method>();
switch (method) {
- case QtCoap::Get:
+ case QtCoap::Method::Get:
m_client->get(request);
break;
- case QtCoap::Put:
+ case QtCoap::Method::Put:
m_client->put(request, m_currentData);
break;
- case QtCoap::Post:
+ case QtCoap::Method::Post:
m_client->post(request, m_currentData);
break;
- case QtCoap::Delete:
+ case QtCoap::Method::Delete:
m_client->deleteResource(request);
break;
default:
@@ -255,5 +255,5 @@ void MainWindow::on_methodComboBox_currentIndexChanged(int index)
Q_UNUSED(index);
const auto method = ui->methodComboBox->currentData(Qt::UserRole).value<QtCoap::Method>();
- ui->contentButton->setEnabled(method == QtCoap::Put || method == QtCoap::Post);
+ ui->contentButton->setEnabled(method == QtCoap::Method::Put || method == QtCoap::Method::Post);
}