Fix debug category for cloud transport
This commit is contained in:
parent
a6318b4987
commit
42ca658ff7
@ -38,6 +38,9 @@
|
|||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
|
|
||||||
|
#include <QLoggingCategory>
|
||||||
|
Q_DECLARE_LOGGING_CATEGORY(dcCloud)
|
||||||
|
|
||||||
using namespace remoteproxyclient;
|
using namespace remoteproxyclient;
|
||||||
|
|
||||||
CloudTransport::CloudTransport(AWSClient *awsClient, QObject *parent):
|
CloudTransport::CloudTransport(AWSClient *awsClient, QObject *parent):
|
||||||
@ -47,27 +50,27 @@ CloudTransport::CloudTransport(AWSClient *awsClient, QObject *parent):
|
|||||||
m_remoteproxyConnection = new RemoteProxyConnection(QUuid::createUuid(), qApp->applicationName(), this);
|
m_remoteproxyConnection = new RemoteProxyConnection(QUuid::createUuid(), qApp->applicationName(), this);
|
||||||
|
|
||||||
QObject::connect(m_remoteproxyConnection, &RemoteProxyConnection::remoteConnectionEstablished, this,[this]() {
|
QObject::connect(m_remoteproxyConnection, &RemoteProxyConnection::remoteConnectionEstablished, this,[this]() {
|
||||||
qDebug() << "CloudTransport: Remote connection established.";
|
qCDebug(dcCloud) << "CloudTransport: Remote connection established.";
|
||||||
emit connected();
|
emit connected();
|
||||||
});
|
});
|
||||||
QObject::connect(m_remoteproxyConnection, &RemoteProxyConnection::disconnected, this,[this]() {
|
QObject::connect(m_remoteproxyConnection, &RemoteProxyConnection::disconnected, this,[this]() {
|
||||||
qDebug() << "CloudTransport: Disconnected.";
|
qCDebug(dcCloud) << "CloudTransport: Disconnected.";
|
||||||
emit disconnected();
|
emit disconnected();
|
||||||
});
|
});
|
||||||
|
|
||||||
QObject::connect(m_remoteproxyConnection, &RemoteProxyConnection::stateChanged, this,[](RemoteProxyConnection::State state) {
|
QObject::connect(m_remoteproxyConnection, &RemoteProxyConnection::stateChanged, this,[](RemoteProxyConnection::State state) {
|
||||||
qDebug() << "Proxy state changed:" << state;
|
qCDebug(dcCloud) << "Proxy state changed:" << state;
|
||||||
});
|
});
|
||||||
|
|
||||||
QObject::connect(m_remoteproxyConnection, &RemoteProxyConnection::ready, this,[this]() {
|
QObject::connect(m_remoteproxyConnection, &RemoteProxyConnection::ready, this,[this]() {
|
||||||
qDebug() << "Proxy ready. Authenticating channel.";
|
qCDebug(dcCloud) << "Proxy ready. Authenticating channel.";
|
||||||
m_remoteproxyConnection->authenticate(m_awsClient->idToken(), m_nonce);
|
m_remoteproxyConnection->authenticate(m_awsClient->idToken(), m_nonce);
|
||||||
});
|
});
|
||||||
QObject::connect(m_remoteproxyConnection, &RemoteProxyConnection::dataReady, this, [this](const QByteArray &data) {
|
QObject::connect(m_remoteproxyConnection, &RemoteProxyConnection::dataReady, this, [this](const QByteArray &data) {
|
||||||
emit dataReady(data);
|
emit dataReady(data);
|
||||||
});
|
});
|
||||||
QObject::connect(m_remoteproxyConnection, &RemoteProxyConnection::errorOccurred, this, [] (QAbstractSocket::SocketError error) {
|
QObject::connect(m_remoteproxyConnection, &RemoteProxyConnection::errorOccurred, this, [] (QAbstractSocket::SocketError error) {
|
||||||
qDebug() << "Remote proxy Error:" << error;
|
qCDebug(dcCloud) << "Remote proxy Error:" << error;
|
||||||
// emit NymeaTransportInterface::error(QAbstractSocket::ConnectionRefusedError);
|
// emit NymeaTransportInterface::error(QAbstractSocket::ConnectionRefusedError);
|
||||||
});
|
});
|
||||||
QObject::connect(m_remoteproxyConnection, &RemoteProxyConnection::sslErrors, this, &CloudTransport::sslErrors);
|
QObject::connect(m_remoteproxyConnection, &RemoteProxyConnection::sslErrors, this, &CloudTransport::sslErrors);
|
||||||
@ -80,16 +83,16 @@ bool CloudTransport::connect(const QUrl &url)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug() << "Connecting to" << url;
|
qCDebug(dcCloud) << "Connecting to" << url;
|
||||||
m_url = url;
|
m_url = url;
|
||||||
|
|
||||||
m_nonce = QUuid::createUuid().toString();
|
m_nonce = QUuid::createUuid().toString();
|
||||||
bool postResult = m_awsClient->postToMQTT(url.host(), m_nonce, QPointer<QObject>(this), [this](bool success) {
|
bool postResult = m_awsClient->postToMQTT(url.host(), m_nonce, QPointer<QObject>(this), [this](bool success) {
|
||||||
if (success) {
|
if (success) {
|
||||||
qDebug() << "MQTT Post done. Connecting to remote proxy";
|
qCDebug(dcCloud) << "MQTT Post done. Connecting to remote proxy";
|
||||||
m_remoteproxyConnection->connectServer(QUrl("wss://remoteproxy.nymea.io"));
|
m_remoteproxyConnection->connectServer(QUrl("wss://remoteproxy.nymea.io"));
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "Posting to MQTT failed";
|
qCDebug(dcCloud) << "Posting to MQTT failed";
|
||||||
emit error(QAbstractSocket::HostNotFoundError);
|
emit error(QAbstractSocket::HostNotFoundError);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -109,7 +112,7 @@ QUrl CloudTransport::url() const
|
|||||||
|
|
||||||
void CloudTransport::disconnect()
|
void CloudTransport::disconnect()
|
||||||
{
|
{
|
||||||
qDebug() << "CloudTransport: Disconnecting from server.";
|
qCDebug(dcCloud) << "CloudTransport: Disconnecting from server.";
|
||||||
m_remoteproxyConnection->disconnectServer();
|
m_remoteproxyConnection->disconnectServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,13 +138,13 @@ NymeaTransportInterface::ConnectionState CloudTransport::connectionState() const
|
|||||||
|
|
||||||
void CloudTransport::sendData(const QByteArray &data)
|
void CloudTransport::sendData(const QByteArray &data)
|
||||||
{
|
{
|
||||||
// qDebug() << "Cloud transport: Sending data:" << data;
|
// qCDebug(dcCloud) << "Cloud transport: Sending data:" << data;
|
||||||
m_remoteproxyConnection->sendData(data);
|
m_remoteproxyConnection->sendData(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CloudTransport::ignoreSslErrors(const QList<QSslError> &errors)
|
void CloudTransport::ignoreSslErrors(const QList<QSslError> &errors)
|
||||||
{
|
{
|
||||||
qDebug() << "CloudTransport: Ignoring SSL errors" << errors;
|
qCDebug(dcCloud) << "CloudTransport: Ignoring SSL errors" << errors;
|
||||||
m_remoteproxyConnection->ignoreSslErrors(errors);
|
m_remoteproxyConnection->ignoreSslErrors(errors);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -521,6 +521,7 @@ void JsonRpcClient::setNotificationsEnabled()
|
|||||||
}
|
}
|
||||||
JsonRpcReply *reply = createReply("JSONRPC.SetNotificationStatus", params, this, "setNotificationsEnabledResponse");
|
JsonRpcReply *reply = createReply("JSONRPC.SetNotificationStatus", params, this, "setNotificationsEnabledResponse");
|
||||||
m_replies.insert(reply->commandId(), reply);
|
m_replies.insert(reply->commandId(), reply);
|
||||||
|
qCDebug(dcJsonRpc) << "Setting notification status";
|
||||||
sendRequest(reply->requestMap());
|
sendRequest(reply->requestMap());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user