mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Nanoleaf Updates (#1299)
* Discover additional Nanoleaf devices * Fix Nanoleaf not turning on * Added LGTM configuration file * Allow to pass QJsonObject as payload for put * Nanoleaf - Support Restore State & Overwrite Brightness * Removed because this is already included Co-authored-by: Markus <16664240+Paulchen-Panther@users.noreply.github.com>
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include <QEventLoop>
|
||||
#include <QNetworkReply>
|
||||
#include <QByteArray>
|
||||
#include <QJsonObject>
|
||||
|
||||
//std includes
|
||||
#include <iostream>
|
||||
@@ -154,16 +155,21 @@ httpResponse ProviderRestApi::get(const QUrl &url)
|
||||
return response;
|
||||
}
|
||||
|
||||
httpResponse ProviderRestApi::put(const QString &body)
|
||||
httpResponse ProviderRestApi::put(const QJsonObject &body)
|
||||
{
|
||||
return put( getUrl(), body );
|
||||
return put( getUrl(), QJsonDocument(body).toJson(QJsonDocument::Compact));
|
||||
}
|
||||
|
||||
httpResponse ProviderRestApi::put(const QUrl &url, const QString &body)
|
||||
httpResponse ProviderRestApi::put(const QString &body)
|
||||
{
|
||||
return put( getUrl(), body.toUtf8() );
|
||||
}
|
||||
|
||||
httpResponse ProviderRestApi::put(const QUrl &url, const QByteArray &body)
|
||||
{
|
||||
// Perform request
|
||||
QNetworkRequest request(url);
|
||||
QNetworkReply* reply = _networkManager->put(request, body.toUtf8());
|
||||
QNetworkReply* reply = _networkManager->put(request, body);
|
||||
// Connect requestFinished signal to quit slot of the loop.
|
||||
QEventLoop loop;
|
||||
QEventLoop::connect(reply, &QNetworkReply::finished, &loop, &QEventLoop::quit);
|
||||
@@ -178,7 +184,7 @@ httpResponse ProviderRestApi::put(const QUrl &url, const QString &body)
|
||||
{
|
||||
if(reply->error() != QNetworkReply::NoError)
|
||||
{
|
||||
Debug(_log, "PUT: [%s] [%s]", QSTRING_CSTR( url.toString() ), QSTRING_CSTR( body ) );
|
||||
Debug(_log, "PUT: [%s] [%s]", QSTRING_CSTR( url.toString() ),body.constData() );
|
||||
}
|
||||
response = getResponse(reply);
|
||||
}
|
||||
|
Reference in New Issue
Block a user