Improve some debug prints in nymeaconfiguration

pull/589/head
Michael Zanetti 2021-04-21 14:55:59 +02:00
parent 06688c2cd2
commit 483b794421
2 changed files with 13 additions and 6 deletions

View File

@ -38,6 +38,10 @@
#include "jsonrpc/jsonrpcclient.h"
#include <QUuid>
#include <QJsonDocument>
#include "logging.h"
NYMEA_LOGGING_CATEGORY(dcNymeaConfiguration, "NymeaConfiguration")
NymeaConfiguration::NymeaConfiguration(JsonRpcClient *client, QObject *parent):
JsonHandler(parent),
@ -396,16 +400,16 @@ void NymeaConfiguration::notificationReceived(const QVariantMap &notification)
QString notif = notification.value("notification").toString();
if (notif == "Configuration.BasicConfigurationChanged") {
QVariantMap params = notification.value("params").toMap().value("basicConfiguration").toMap();
qDebug() << "notif" << params;
m_debugServerEnabled = params.value("debugServerEnabled").toBool();
emit debugServerEnabledChanged();
m_serverName = params.value("serverName").toString();
emit serverNameChanged();
qCDebug(dcNymeaConfiguration()) << "Basic configuration changed. Server name:" << m_serverName << "Debug server enabled:" << m_debugServerEnabled;
return;
}
if (notif == "Configuration.CloudConfigurationChanged") {
QVariantMap params = notification.value("params").toMap().value("cloudConfiguration").toMap();
qDebug() << "notif" << params;
qCDebug(dcNymeaConfiguration()) << "Cloud coniguration changed" << params;
m_cloudEnabled = params.value("enabled").toBool();
emit cloudEnabledChanged();
return;
@ -493,17 +497,19 @@ void NymeaConfiguration::notificationReceived(const QVariantMap &notification)
policy->setPassword(policyMap.value("password").toString());
policy->setAllowedPublishTopicFilters(policyMap.value("allowedPublishTopicFilters").toStringList());
policy->setAllowedSubscribeTopicFilters(policyMap.value("allowedSubscribeTopicFilters").toStringList());
qDebug() << "MQTT policy added" << policy->clientId() << policy->username() << policy->password();
qCDebug(dcNymeaConfiguration()) << "MQTT policy changed" << policy->clientId() << policy->username() << policy->password();
return;
}
if (notif == "Configuration.MqttPolicyRemoved") {
MqttPolicy* policy = m_mqttPolicies->getPolicy(notification.value("params").toMap().value("clientId").toString());
if (!policy) {
qWarning() << "Reveived a policy removed notification for apolicy we don't know";
qCWarning(dcNymeaConfiguration()) << "Reveived a policy removed notification for apolicy we don't know";
return;
}
qCDebug(dcNymeaConfiguration()) << "MQTT policy removed" << policy->clientId() << policy->username() << policy->password();
m_mqttPolicies->removePolicy(policy);
return;
}
qDebug() << "Unhandled Configuration notification" << notif << notification;
qCWarning(dcNymeaConfiguration) << "Unhandled Configuration notification" << qUtf8Printable(QJsonDocument::fromVariant(notification).toJson());
}

View File

@ -121,6 +121,7 @@ int ThingManager::addThing(const QUuid &thingClassId, const QString &name, const
void ThingManager::notificationReceived(const QVariantMap &data)
{
qCDebug(dcThingManager()) << "ThingManager notifications received:" << qUtf8Printable(QJsonDocument::fromVariant(data).toJson());
QString notification = data.value("notification").toString();
if (notification == "Integrations.StateChanged") {
Thing *thing = m_things->getThing(data.value("params").toMap().value("thingId").toUuid());
@ -163,7 +164,7 @@ void ThingManager::notificationReceived(const QVariantMap &data)
thing->deleteLater();
} else if (notification == "Integrations.ThingChanged") {
QUuid thingId = data.value("params").toMap().value("thing").toMap().value("id").toUuid();
// qDebug() << "Thing changed notification" << thingId << data.value("params").toMap();
qCDebug(dcThingManager()) << "Thing changed notification" << thingId << data.value("params").toMap();
Thing *oldThing = m_things->getThing(thingId);
if (!oldThing) {
qWarning() << "Received a thing changed notification for a thing we don't know";