Show MQTT errors in messagebox

This commit is contained in:
Alex Spataru 2021-02-27 23:11:04 -05:00
parent 48e8dc24b5
commit 92323f546d
4 changed files with 189 additions and 90 deletions

View File

@ -59,11 +59,11 @@ Control {
text: qsTr("Version") + ":" text: qsTr("Version") + ":"
} ComboBox { } ComboBox {
Layout.fillWidth: true Layout.fillWidth: true
model: Cpp_MQTT_Publisher.mqttVersions model: Cpp_MQTT_Client.mqttVersions
currentIndex: Cpp_MQTT_Publisher.mqttVersion currentIndex: Cpp_MQTT_Client.mqttVersion
onCurrentIndexChanged: { onCurrentIndexChanged: {
if (Cpp_MQTT_Publisher.mqttVersion !== currentIndex) if (Cpp_MQTT_Client.mqttVersion !== currentIndex)
Cpp_MQTT_Publisher.mqttVersion = currentIndex Cpp_MQTT_Client.mqttVersion = currentIndex
} }
} }
@ -74,11 +74,11 @@ Control {
text: qsTr("Mode") + ":" text: qsTr("Mode") + ":"
} ComboBox { } ComboBox {
Layout.fillWidth: true Layout.fillWidth: true
model: Cpp_MQTT_Publisher.clientModes model: Cpp_MQTT_Client.clientModes
currentIndex: Cpp_MQTT_Publisher.clientMode currentIndex: Cpp_MQTT_Client.clientMode
onCurrentIndexChanged: { onCurrentIndexChanged: {
if (Cpp_MQTT_Publisher.clientMode !== currentIndex) if (Cpp_MQTT_Client.clientMode !== currentIndex)
Cpp_MQTT_Publisher.clientMode = currentIndex Cpp_MQTT_Client.clientMode = currentIndex
} }
} }
@ -87,21 +87,21 @@ Control {
// //
Label { Label {
opacity: enabled ? 1 : 0.5 opacity: enabled ? 1 : 0.5
enabled: !Cpp_MQTT_Publisher.isConnectedToHost enabled: !Cpp_MQTT_Client.isConnectedToHost
Behavior on opacity {NumberAnimation{}} Behavior on opacity {NumberAnimation{}}
text: qsTr("Host") + ":" text: qsTr("Host") + ":"
} TextField { } TextField {
id: _host id: _host
Layout.fillWidth: true Layout.fillWidth: true
text: Cpp_MQTT_Publisher.host text: Cpp_MQTT_Client.host
placeholderText: Cpp_MQTT_Publisher.defaultHost placeholderText: Cpp_MQTT_Client.defaultHost
onTextChanged: { onTextChanged: {
if (Cpp_MQTT_Publisher.host !== text) if (Cpp_MQTT_Client.host !== text)
Cpp_MQTT_Publisher.host = text Cpp_MQTT_Client.host = text
} }
opacity: enabled ? 1 : 0.5 opacity: enabled ? 1 : 0.5
enabled: !Cpp_MQTT_Publisher.isConnectedToHost enabled: !Cpp_MQTT_Client.isConnectedToHost
Behavior on opacity {NumberAnimation{}} Behavior on opacity {NumberAnimation{}}
} }
@ -110,17 +110,17 @@ Control {
// //
Label { Label {
opacity: enabled ? 1 : 0.5 opacity: enabled ? 1 : 0.5
enabled: !Cpp_MQTT_Publisher.isConnectedToHost enabled: !Cpp_MQTT_Client.isConnectedToHost
Behavior on opacity {NumberAnimation{}} Behavior on opacity {NumberAnimation{}}
text: qsTr("Port") + ":" text: qsTr("Port") + ":"
} TextField { } TextField {
id: _port id: _port
Layout.fillWidth: true Layout.fillWidth: true
text: Cpp_MQTT_Publisher.port text: Cpp_MQTT_Client.port
placeholderText: Cpp_MQTT_Publisher.defaultPort placeholderText: Cpp_MQTT_Client.defaultPort
onTextChanged: { onTextChanged: {
if (Cpp_MQTT_Publisher.port !== text) if (Cpp_MQTT_Client.port !== text)
Cpp_MQTT_Publisher.port = text Cpp_MQTT_Client.port = text
} }
validator: IntValidator { validator: IntValidator {
@ -129,7 +129,7 @@ Control {
} }
opacity: enabled ? 1 : 0.5 opacity: enabled ? 1 : 0.5
enabled: !Cpp_MQTT_Publisher.isConnectedToHost enabled: !Cpp_MQTT_Client.isConnectedToHost
Behavior on opacity {NumberAnimation{}} Behavior on opacity {NumberAnimation{}}
} }
@ -138,21 +138,21 @@ Control {
// //
Label { Label {
opacity: enabled ? 1 : 0.5 opacity: enabled ? 1 : 0.5
enabled: !Cpp_MQTT_Publisher.isConnectedToHost enabled: !Cpp_MQTT_Client.isConnectedToHost
Behavior on opacity {NumberAnimation{}} Behavior on opacity {NumberAnimation{}}
text: qsTr("Topic") + ":" text: qsTr("Topic") + ":"
} TextField { } TextField {
id: _topic id: _topic
Layout.fillWidth: true Layout.fillWidth: true
text: Cpp_MQTT_Publisher.topic text: Cpp_MQTT_Client.topic
placeholderText: qsTr("MQTT topic") placeholderText: qsTr("MQTT topic")
onTextChanged: { onTextChanged: {
if (Cpp_MQTT_Publisher.topic !== text) if (Cpp_MQTT_Client.topic !== text)
Cpp_MQTT_Publisher.topic = text Cpp_MQTT_Client.topic = text
} }
opacity: enabled ? 1 : 0.5 opacity: enabled ? 1 : 0.5
enabled: !Cpp_MQTT_Publisher.isConnectedToHost enabled: !Cpp_MQTT_Client.isConnectedToHost
Behavior on opacity {NumberAnimation{}} Behavior on opacity {NumberAnimation{}}
} }
@ -161,21 +161,21 @@ Control {
// //
Label { Label {
opacity: enabled ? 1 : 0.5 opacity: enabled ? 1 : 0.5
enabled: !Cpp_MQTT_Publisher.isConnectedToHost enabled: !Cpp_MQTT_Client.isConnectedToHost
Behavior on opacity {NumberAnimation{}} Behavior on opacity {NumberAnimation{}}
text: qsTr("User") + ":" text: qsTr("User") + ":"
} TextField { } TextField {
id: _user id: _user
Layout.fillWidth: true Layout.fillWidth: true
text: Cpp_MQTT_Publisher.username text: Cpp_MQTT_Client.username
placeholderText: qsTr("MQTT username") placeholderText: qsTr("MQTT username")
onTextChanged: { onTextChanged: {
if (Cpp_MQTT_Publisher.username !== text) if (Cpp_MQTT_Client.username !== text)
Cpp_MQTT_Publisher.username = text Cpp_MQTT_Client.username = text
} }
opacity: enabled ? 1 : 0.5 opacity: enabled ? 1 : 0.5
enabled: !Cpp_MQTT_Publisher.isConnectedToHost enabled: !Cpp_MQTT_Client.isConnectedToHost
Behavior on opacity {NumberAnimation{}} Behavior on opacity {NumberAnimation{}}
} }
@ -184,7 +184,7 @@ Control {
// //
Label { Label {
opacity: enabled ? 1 : 0.5 opacity: enabled ? 1 : 0.5
enabled: !Cpp_MQTT_Publisher.isConnectedToHost enabled: !Cpp_MQTT_Client.isConnectedToHost
Behavior on opacity {NumberAnimation{}} Behavior on opacity {NumberAnimation{}}
text: qsTr("Password") + ":" text: qsTr("Password") + ":"
} RowLayout { } RowLayout {
@ -195,15 +195,15 @@ Control {
id: _password id: _password
Layout.fillWidth: true Layout.fillWidth: true
echoMode: TextField.PasswordEchoOnEdit echoMode: TextField.PasswordEchoOnEdit
text: Cpp_MQTT_Publisher.password text: Cpp_MQTT_Client.password
placeholderText: qsTr("MQTT password") placeholderText: qsTr("MQTT password")
onTextChanged: { onTextChanged: {
if (Cpp_MQTT_Publisher.password !== text) if (Cpp_MQTT_Client.password !== text)
Cpp_MQTT_Publisher.password = text Cpp_MQTT_Client.password = text
} }
opacity: enabled ? 1 : 0.5 opacity: enabled ? 1 : 0.5
enabled: !Cpp_MQTT_Publisher.isConnectedToHost enabled: !Cpp_MQTT_Client.isConnectedToHost
Behavior on opacity {NumberAnimation{}} Behavior on opacity {NumberAnimation{}}
} }
@ -233,7 +233,7 @@ Control {
Label { Label {
text: qsTr("DNS lookup") + ": " text: qsTr("DNS lookup") + ": "
opacity: enabled ? 1 : 0.5 opacity: enabled ? 1 : 0.5
enabled: !Cpp_MQTT_Publisher.isConnectedToHost enabled: !Cpp_MQTT_Client.isConnectedToHost
Behavior on opacity {NumberAnimation{}} Behavior on opacity {NumberAnimation{}}
} RowLayout { } RowLayout {
Layout.fillWidth: true Layout.fillWidth: true
@ -244,10 +244,10 @@ Control {
Layout.fillWidth: true Layout.fillWidth: true
opacity: enabled ? 1 : 0.5 opacity: enabled ? 1 : 0.5
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
onAccepted: Cpp_MQTT_Publisher.lookup(text) onAccepted: Cpp_MQTT_Client.lookup(text)
placeholderText: qsTr("Enter address (e.g. google.com)") placeholderText: qsTr("Enter address (e.g. google.com)")
enabled: !Cpp_MQTT_Publisher.isConnectedToHost && enabled: !Cpp_MQTT_Client.isConnectedToHost &&
!Cpp_MQTT_Publisher.lookupActive !Cpp_MQTT_Client.lookupActive
Behavior on opacity {NumberAnimation{}} Behavior on opacity {NumberAnimation{}}
} }
@ -258,10 +258,10 @@ Control {
Layout.maximumWidth: height Layout.maximumWidth: height
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
icon.source: "qrc:/icons/search.svg" icon.source: "qrc:/icons/search.svg"
onClicked: Cpp_MQTT_Publisher.lookup(_addrLookup.text) onClicked: Cpp_MQTT_Client.lookup(_addrLookup.text)
enabled: _addrLookup.text.length > 0 && enabled: _addrLookup.text.length > 0 &&
!Cpp_MQTT_Publisher.isConnectedToHost && !Cpp_MQTT_Client.isConnectedToHost &&
!Cpp_MQTT_Publisher.lookupActive !Cpp_MQTT_Client.lookupActive
Behavior on opacity {NumberAnimation{}} Behavior on opacity {NumberAnimation{}}
} }
@ -283,8 +283,8 @@ Control {
font.bold: true font.bold: true
Layout.fillWidth: true Layout.fillWidth: true
icon.color: palette.buttonText icon.color: palette.buttonText
checked: Cpp_MQTT_Publisher.isConnectedToHost checked: Cpp_MQTT_Client.isConnectedToHost
onClicked: Cpp_MQTT_Publisher.toggleConnection() onClicked: Cpp_MQTT_Client.toggleConnection()
palette.buttonText: checked ? "#d72d60" : "#2eed5c" palette.buttonText: checked ? "#d72d60" : "#2eed5c"
text: (checked ? qsTr("Disconnect") : qsTr("Connect")) + " " text: (checked ? qsTr("Disconnect") : qsTr("Connect")) + " "
icon.source: checked ? "qrc:/icons/disconnect.svg" : "qrc:/icons/connect.svg" icon.source: checked ? "qrc:/icons/disconnect.svg" : "qrc:/icons/connect.svg"

View File

@ -27,45 +27,45 @@
using namespace MQTT; using namespace MQTT;
static Publisher *INSTANCE = nullptr; static Client *INSTANCE = nullptr;
Publisher::Publisher() Client::Client()
{ {
m_lookupActive = false; m_lookupActive = false;
m_clientMode = MQTTClientMode::ClientPublisher; m_clientMode = MQTTClientMode::ClientPublisher;
connect(&m_client, &QMQTT::Client::connected, this, &Publisher::connectedChanged); connect(&m_client, &QMQTT::Client::connected, this, &Client::connectedChanged);
connect(&m_client, &QMQTT::Client::disconnected, this, &Publisher::connectedChanged); connect(&m_client, &QMQTT::Client::disconnected, this, &Client::connectedChanged);
connect(&m_client, &QMQTT::Client::error, this, &Publisher::onError); connect(&m_client, &QMQTT::Client::error, this, &Client::onError);
setPort(defaultPort()); setPort(defaultPort());
setHost(defaultHost()); setHost(defaultHost());
} }
Publisher::~Publisher() Client::~Client()
{ {
disconnectFromHost(); disconnectFromHost();
} }
Publisher *Publisher::getInstance() Client *Client::getInstance()
{ {
if (!INSTANCE) if (!INSTANCE)
INSTANCE = new Publisher; INSTANCE = new Client;
return INSTANCE; return INSTANCE;
} }
quint16 Publisher::port() const quint16 Client::port() const
{ {
return m_client.port(); return m_client.port();
} }
QString Publisher::topic() const QString Client::topic() const
{ {
return m_topic; return m_topic;
} }
int Publisher::mqttVersion() const int Client::mqttVersion() const
{ {
switch (m_client.version()) switch (m_client.version())
{ {
@ -81,47 +81,47 @@ int Publisher::mqttVersion() const
} }
} }
int Publisher::clientMode() const int Client::clientMode() const
{ {
return m_clientMode; return m_clientMode;
} }
QString Publisher::username() const QString Client::username() const
{ {
return m_client.username(); return m_client.username();
} }
QString Publisher::password() const QString Client::password() const
{ {
return QString::fromUtf8(m_client.password()); return QString::fromUtf8(m_client.password());
} }
QString Publisher::host() const QString Client::host() const
{ {
return m_client.host().toString(); return m_client.host().toString();
} }
bool Publisher::lookupActive() const bool Client::lookupActive() const
{ {
return m_lookupActive; return m_lookupActive;
} }
bool Publisher::isConnectedToHost() const bool Client::isConnectedToHost() const
{ {
return m_client.isConnectedToHost(); return m_client.isConnectedToHost();
} }
QStringList Publisher::clientModes() const QStringList Client::clientModes() const
{ {
return QStringList { tr("Publisher"), tr("Suscriber") }; return QStringList { tr("Publisher"), tr("Suscriber") };
} }
QStringList Publisher::mqttVersions() const QStringList Client::mqttVersions() const
{ {
return QStringList { "MQTT 3.1.0", "MQTT 3.1.1" }; return QStringList { "MQTT 3.1.0", "MQTT 3.1.1" };
} }
void Publisher::connectToHost() void Client::connectToHost()
{ {
m_client.connectToHost(); m_client.connectToHost();
} }
@ -130,7 +130,7 @@ void Publisher::connectToHost()
* Connects/disconnects the application from the current MQTT broker. This function is * Connects/disconnects the application from the current MQTT broker. This function is
* used as a convenience for the connect/disconnect button. * used as a convenience for the connect/disconnect button.
*/ */
void Publisher::toggleConnection() void Client::toggleConnection()
{ {
if (isConnectedToHost()) if (isConnectedToHost())
disconnectFromHost(); disconnectFromHost();
@ -138,7 +138,7 @@ void Publisher::toggleConnection()
connectToHost(); connectToHost();
} }
void Publisher::disconnectFromHost() void Client::disconnectFromHost()
{ {
m_client.disconnectFromHost(); m_client.disconnectFromHost();
} }
@ -146,50 +146,50 @@ void Publisher::disconnectFromHost()
/** /**
* Performs a DNS lookup for the given @a host name * Performs a DNS lookup for the given @a host name
*/ */
void Publisher::lookup(const QString &host) void Client::lookup(const QString &host)
{ {
m_lookupActive = true; m_lookupActive = true;
emit lookupActiveChanged(); emit lookupActiveChanged();
QHostInfo::lookupHost(host.simplified(), this, &Publisher::lookupFinished); QHostInfo::lookupHost(host.simplified(), this, &Client::lookupFinished);
} }
void Publisher::setPort(const quint16 port) void Client::setPort(const quint16 port)
{ {
m_client.setPort(port); m_client.setPort(port);
emit portChanged(); emit portChanged();
} }
void Publisher::setHost(const QString &host) void Client::setHost(const QString &host)
{ {
m_client.setHost(QHostAddress(host)); m_client.setHost(QHostAddress(host));
emit hostChanged(); emit hostChanged();
} }
void Publisher::setClientMode(const int mode) void Client::setClientMode(const int mode)
{ {
m_clientMode = (MQTTClientMode)mode; m_clientMode = (MQTTClientMode)mode;
emit clientModeChanged(); emit clientModeChanged();
} }
void Publisher::setTopic(const QString &topic) void Client::setTopic(const QString &topic)
{ {
m_topic = topic; m_topic = topic;
emit topicChanged(); emit topicChanged();
} }
void Publisher::setUsername(const QString &username) void Client::setUsername(const QString &username)
{ {
m_client.setUsername(username); m_client.setUsername(username);
emit usernameChanged(); emit usernameChanged();
} }
void Publisher::setPassword(const QString &password) void Client::setPassword(const QString &password)
{ {
m_client.setPassword(password.toUtf8()); m_client.setPassword(password.toUtf8());
emit passwordChanged(); emit passwordChanged();
} }
void Publisher::setMqttVersion(const int versionIndex) void Client::setMqttVersion(const int versionIndex)
{ {
switch (versionIndex) switch (versionIndex)
{ {
@ -206,19 +206,22 @@ void Publisher::setMqttVersion(const int versionIndex)
emit mqttVersionChanged(); emit mqttVersionChanged();
} }
void Publisher::sendData() void Client::sendData()
{ {
// Sort JFI list from oldest to most recent // Sort JFI list from oldest to most recent
JFI_SortList(&m_jfiList); JFI_SortList(&m_jfiList);
// Send data in CSV format
// Clear JFI list // Clear JFI list
m_jfiList.clear();
} }
/** /**
* Sets the host IP address when the lookup finishes. * Sets the host IP address when the lookup finishes.
* If the lookup fails, the error code/string shall be shown to the user in a messagebox. * If the lookup fails, the error code/string shall be shown to the user in a messagebox.
*/ */
void Publisher::lookupFinished(const QHostInfo &info) void Client::lookupFinished(const QHostInfo &info)
{ {
m_lookupActive = false; m_lookupActive = false;
emit lookupActiveChanged(); emit lookupActiveChanged();
@ -236,12 +239,109 @@ void Publisher::lookupFinished(const QHostInfo &info)
Misc::Utilities::showMessageBox(tr("IP address lookup error"), info.errorString()); Misc::Utilities::showMessageBox(tr("IP address lookup error"), info.errorString());
} }
void Publisher::onError(const QMQTT::ClientError error) void Client::onError(const QMQTT::ClientError error)
{ {
qDebug() << error; QString str;
switch (error)
{
case QMQTT::UnknownError:
str = tr("Unknown error");
break;
case QMQTT::SocketConnectionRefusedError:
str = tr("Connection refused");
break;
case QMQTT::SocketRemoteHostClosedError:
str = tr("Remote host closed the connection");
break;
case QMQTT::SocketHostNotFoundError:
str = tr("Host not found");
break;
case QMQTT::SocketAccessError:
str = tr("Socket access error");
break;
case QMQTT::SocketResourceError:
str = tr("Socket resource error");
break;
case QMQTT::SocketTimeoutError:
str = tr("Socket timeout");
break;
case QMQTT::SocketDatagramTooLargeError:
str = tr("Socket datagram too large");
break;
case QMQTT::SocketNetworkError:
str = tr("Network error");
break;
case QMQTT::SocketAddressInUseError:
str = tr("Address in use");
break;
case QMQTT::SocketAddressNotAvailableError:
str = tr("Address not available");
break;
case QMQTT::SocketUnsupportedSocketOperationError:
str = tr("Unsupported socket operation");
break;
case QMQTT::SocketUnfinishedSocketOperationError:
str = tr("Unfinished socket operation");
break;
case QMQTT::SocketProxyAuthenticationRequiredError:
str = tr("Proxy authentication required");
break;
case QMQTT::SocketSslHandshakeFailedError:
str = tr("SSL handshake failed");
break;
case QMQTT::SocketProxyConnectionRefusedError:
str = tr("Proxy connection refused");
break;
case QMQTT::SocketProxyConnectionClosedError:
str = tr("Proxy connection closed");
break;
case QMQTT::SocketProxyConnectionTimeoutError:
str = tr("Proxy connection timeout");
break;
case QMQTT::SocketProxyNotFoundError:
str = tr("Proxy not found");
break;
case QMQTT::SocketProxyProtocolError:
str = tr("Proxy protocol error");
break;
case QMQTT::SocketOperationError:
str = tr("Operation error");
break;
case QMQTT::SocketSslInternalError:
str = tr("SSL internal error");
break;
case QMQTT::SocketSslInvalidUserDataError:
str = tr("Invalid SSL user data");
break;
case QMQTT::SocketTemporaryError:
str = tr("Socket temprary error");
break;
case QMQTT::MqttUnacceptableProtocolVersionError:
str = tr("Unacceptable MQTT protocol");
break;
case QMQTT::MqttIdentifierRejectedError:
str = tr("MQTT identifier rejected");
break;
case QMQTT::MqttServerUnavailableError:
str = tr("MQTT server unavailable");
break;
case QMQTT::MqttBadUserNameOrPasswordError:
str = tr("Bad MQTT username or password");
break;
case QMQTT::MqttNotAuthorizedError:
str = tr("MQTT authorization error");
break;
case QMQTT::MqttNoPingResponse:
str = tr("MQTT no ping response");
break;
}
if (!str.isEmpty())
Misc::Utilities::showMessageBox(tr("MQTT client error"), str);
} }
void Publisher::registerJsonFrame(const JFI_Object &frameInfo) void Client::registerJsonFrame(const JFI_Object &frameInfo)
{ {
m_jfiList.append(frameInfo); m_jfiList.append(frameInfo);
} }

View File

@ -20,8 +20,8 @@
* THE SOFTWARE. * THE SOFTWARE.
*/ */
#ifndef MQTT_PUBLISHER_H #ifndef MQTT_CLIENT_H
#define MQTT_PUBLISHER_H #define MQTT_CLIENT_H
#include <QObject> #include <QObject>
#include <QHostInfo> #include <QHostInfo>
@ -41,7 +41,7 @@ enum MQTTClientMode
ClientSubscriber = 1 ClientSubscriber = 1
}; };
class Publisher : public QObject class Client : public QObject
{ {
// clang-format off // clang-format off
Q_OBJECT Q_OBJECT
@ -105,7 +105,7 @@ signals:
void lookupActiveChanged(); void lookupActiveChanged();
public: public:
static Publisher *getInstance(); static Client *getInstance();
quint16 port() const; quint16 port() const;
QString host() const; QString host() const;
@ -120,7 +120,6 @@ public:
QStringList mqttVersions() const; QStringList mqttVersions() const;
quint16 defaultPort() const { return 1883; } quint16 defaultPort() const { return 1883; }
QString defaultHost() const { return "127.0.0.1"; } QString defaultHost() const { return "127.0.0.1"; }
public slots: public slots:
@ -137,8 +136,8 @@ public slots:
void setMqttVersion(const int versionIndex); void setMqttVersion(const int versionIndex);
private: private:
Publisher(); Client();
~Publisher(); ~Client();
private slots: private slots:
void sendData(); void sendData();

View File

@ -150,7 +150,7 @@ void ModuleManager::initializeQmlInterface()
auto ioNetwork = IO::DataSources::Network::getInstance(); auto ioNetwork = IO::DataSources::Network::getInstance();
auto jsonGenerator = JSON::Generator::getInstance(); auto jsonGenerator = JSON::Generator::getInstance();
auto utilities = Misc::Utilities::getInstance(); auto utilities = Misc::Utilities::getInstance();
auto mqttPublisher = MQTT::Publisher::getInstance(); auto mqttPublisher = MQTT::Client::getInstance();
LOG_INFO() << "Finished initializing C++ modules"; LOG_INFO() << "Finished initializing C++ modules";
// Retranslate the QML interface automagically // Retranslate the QML interface automagically
@ -173,7 +173,7 @@ void ModuleManager::initializeQmlInterface()
c->setContextProperty("Cpp_IO_Serial", ioSerial); c->setContextProperty("Cpp_IO_Serial", ioSerial);
c->setContextProperty("Cpp_IO_Network", ioNetwork); c->setContextProperty("Cpp_IO_Network", ioNetwork);
c->setContextProperty("Cpp_JSON_Generator", jsonGenerator); c->setContextProperty("Cpp_JSON_Generator", jsonGenerator);
c->setContextProperty("Cpp_MQTT_Publisher", mqttPublisher); c->setContextProperty("Cpp_MQTT_Client", mqttPublisher);
// Register app info with QML // Register app info with QML
c->setContextProperty("Cpp_AppName", qApp->applicationName()); c->setContextProperty("Cpp_AppName", qApp->applicationName());
@ -211,7 +211,7 @@ void ModuleManager::stopOperations()
CSV::Player::getInstance()->closeFile(); CSV::Player::getInstance()->closeFile();
IO::Manager::getInstance()->disconnectDevice(); IO::Manager::getInstance()->disconnectDevice();
Misc::TimerEvents::getInstance()->stopTimers(); Misc::TimerEvents::getInstance()->stopTimers();
MQTT::Publisher::getInstance()->disconnectFromHost(); MQTT::Client::getInstance()->disconnectFromHost();
LOG_INFO() << "Application modules stopped"; LOG_INFO() << "Application modules stopped";
} }