Add a bunch of Manager Methods for MQTT Commands

This commit is contained in:
Justin Hammond 2019-11-03 19:02:51 +08:00
parent ea376a48cd
commit 6a088c931b
67 changed files with 1272 additions and 13 deletions

View file

@ -100,7 +100,7 @@ public:
bool requestNodeNeighborUpdate(quint8 _node);
bool assignReturnRoute(quint8 _node);
bool deleteAllReturnRoute(quint8 _node);
bool sendNodeInfomation(quint8 _node);
bool sendNodeInformation(quint8 _node);
bool replaceFailedNode(quint8 _node);
bool requestNetworkUpdate(quint8 _node);
QString GetMetaData(quint8 _node, QTOZWManagerSource::QTOZWMetaDataField _field);

View file

@ -115,7 +115,7 @@ class QTOZWManager {
SLOT(bool requestNodeNeighborUpdate(quint8 _node))
SLOT(bool assignReturnRoute(quint8 _node))
SLOT(bool deleteAllReturnRoute(quint8 _node))
SLOT(bool sendNodeInfomation(quint8 _node))
SLOT(bool sendNodeInformation(quint8 _node))
SLOT(bool replaceFailedNode(quint8 _node))
SLOT(bool requestNetworkUpdate(quint8 _node))

View file

@ -93,7 +93,7 @@ public Q_SLOTS:
bool requestNodeNeighborUpdate(quint8 _node);
bool assignReturnRoute(quint8 _node);
bool deleteAllReturnRoute(quint8 _node);
bool sendNodeInfomation(quint8 _node);
bool sendNodeInformation(quint8 _node);
bool replaceFailedNode(quint8 _node);
bool requestNetworkUpdate(quint8 _node);
QString GetMetaData(quint8 _node, QTOZWManagerSource::QTOZWMetaDataField _field);

View file

@ -344,8 +344,8 @@ bool QTOZWManager::assignReturnRoute(quint8 _node) {
bool QTOZWManager::deleteAllReturnRoute(quint8 _node) {
CALL_DPTR_RTN(deleteAllReturnRoute(_node), bool);
}
bool QTOZWManager::sendNodeInfomation(quint8 _node) {
CALL_DPTR_RTN(sendNodeInfomation(_node), bool);
bool QTOZWManager::sendNodeInformation(quint8 _node) {
CALL_DPTR_RTN(sendNodeInformation(_node), bool);
}
bool QTOZWManager::replaceFailedNode(quint8 _node) {
CALL_DPTR_RTN(replaceFailedNode(_node), bool)

View file

@ -379,7 +379,7 @@ bool QTOZWManager_Internal::deleteAllReturnRoute(quint8 _node) {
}
return false;
}
bool QTOZWManager_Internal::sendNodeInfomation(quint8 _node) {
bool QTOZWManager_Internal::sendNodeInformation(quint8 _node) {
if (!this->checkHomeId() || !this->checkNodeId(_node))
return false;
try {

View file

@ -0,0 +1,24 @@
#include "mqttcommands/IsNodeFailed.h"
MqttCommand_IsNodeFailed::MqttCommand_IsNodeFailed(QObject *parent) :
MqttCommand(parent)
{
this->m_requiredFields << "node";
}
MqttCommand* MqttCommand_IsNodeFailed::Create(QObject *parent) {
return new MqttCommand_IsNodeFailed(parent);
}
bool MqttCommand_IsNodeFailed::processMessage(QJsonDocument msg) {
QTOZWManager *mgr = getOZWManager();
if (mgr->IsNodeFailed(msg["node"].toInt())) {
QJsonObject js;
js["status"] = "ok";
emit sendCommandUpdate(GetCommand(), js);
return true;
}
QJsonObject js;
js["status"] = "failed";
emit sendCommandUpdate(GetCommand(), js);
return false;
}

View file

@ -0,0 +1,17 @@
#ifndef ISNODEFAILED_H
#define ISNODEFAILED_H
#include "mqttcommands/mqttcommands.h"
class MqttCommand_IsNodeFailed : public MqttCommand {
Q_OBJECT
public:
static MqttCommand *Create(QObject *parent = nullptr);
static QString StaticGetCommand() { return "IsNodeFailed";};
QString GetCommand() override { return StaticGetCommand(); };
bool processMessage(QJsonDocument) override;
private:
MqttCommand_IsNodeFailed(QObject *parent = nullptr);
};
#endif // ISNODEFAILED_H

View file

@ -0,0 +1,24 @@
#include "mqttcommands/addNode.h"
MqttCommand_AddNode::MqttCommand_AddNode(QObject *parent) :
MqttCommand(parent)
{
}
MqttCommand* MqttCommand_AddNode::Create(QObject *parent) {
return new MqttCommand_AddNode(parent);
}
bool MqttCommand_AddNode::processMessage(QJsonDocument msg) {
Q_UNUSED(msg);
QTOZWManager *mgr = getOZWManager();
if (mgr->addNode(false)) {
QJsonObject js;
js["status"] = "ok";
emit sendCommandUpdate(GetCommand(), js);
return true;
}
QJsonObject js;
js["status"] = "failed";
emit sendCommandUpdate(GetCommand(), js);
return false;
}

View file

@ -0,0 +1,17 @@
#ifndef ADDNODE_H
#define ADDNODE_H
#include "mqttcommands/mqttcommands.h"
class MqttCommand_AddNode : public MqttCommand {
Q_OBJECT
public:
static MqttCommand *Create(QObject *parent = nullptr);
static QString StaticGetCommand() { return "AddNode";};
QString GetCommand() override { return StaticGetCommand(); };
bool processMessage(QJsonDocument) override;
private:
MqttCommand_AddNode(QObject *parent = nullptr);
};
#endif // PING_H

View file

@ -0,0 +1,24 @@
#include "mqttcommands/addNodeSecure.h"
MqttCommand_AddNodeSecure::MqttCommand_AddNodeSecure(QObject *parent) :
MqttCommand(parent)
{
}
MqttCommand* MqttCommand_AddNodeSecure::Create(QObject *parent) {
return new MqttCommand_AddNodeSecure(parent);
}
bool MqttCommand_AddNodeSecure::processMessage(QJsonDocument msg) {
Q_UNUSED(msg);
QTOZWManager *mgr = getOZWManager();
if (mgr->addNode(true)) {
QJsonObject js;
js["status"] = "ok";
emit sendCommandUpdate(GetCommand(), js);
return true;
}
QJsonObject js;
js["status"] = "failed";
emit sendCommandUpdate(GetCommand(), js);
return false;
}

View file

@ -0,0 +1,17 @@
#ifndef ADDNODESECURE_H
#define ADDNODESECURE_H
#include "mqttcommands/mqttcommands.h"
class MqttCommand_AddNodeSecure : public MqttCommand {
Q_OBJECT
public:
static MqttCommand *Create(QObject *parent = nullptr);
static QString StaticGetCommand() { return "AddNodeSecure";};
QString GetCommand() override { return StaticGetCommand(); };
bool processMessage(QJsonDocument) override;
private:
MqttCommand_AddNodeSecure(QObject *parent = nullptr);
};
#endif // PING_H

View file

@ -0,0 +1,24 @@
#include "mqttcommands/assignReturnRoute.h"
MqttCommand_AssignReturnRoute::MqttCommand_AssignReturnRoute(QObject *parent) :
MqttCommand(parent)
{
this->m_requiredFields << "node";
}
MqttCommand* MqttCommand_AssignReturnRoute::Create(QObject *parent) {
return new MqttCommand_AssignReturnRoute(parent);
}
bool MqttCommand_AssignReturnRoute::processMessage(QJsonDocument msg) {
QTOZWManager *mgr = getOZWManager();
if (mgr->assignReturnRoute(msg["node"].toInt())) {
QJsonObject js;
js["status"] = "ok";
emit sendCommandUpdate(GetCommand(), js);
return true;
}
QJsonObject js;
js["status"] = "failed";
emit sendCommandUpdate(GetCommand(), js);
return false;
}

View file

@ -0,0 +1,17 @@
#ifndef ASSIGNRETURNROUTE_H
#define ASSIGNRETURNROUTE_H
#include "mqttcommands/mqttcommands.h"
class MqttCommand_AssignReturnRoute : public MqttCommand {
Q_OBJECT
public:
static MqttCommand *Create(QObject *parent = nullptr);
static QString StaticGetCommand() { return "AssignReturnRoute";};
QString GetCommand() override { return StaticGetCommand(); };
bool processMessage(QJsonDocument) override;
private:
MqttCommand_AssignReturnRoute(QObject *parent = nullptr);
};
#endif // PING_H

View file

@ -0,0 +1,24 @@
#include "mqttcommands/cancelControllerCommand.h"
MqttCommand_CancelControllerCommand::MqttCommand_CancelControllerCommand(QObject *parent) :
MqttCommand(parent)
{
}
MqttCommand* MqttCommand_CancelControllerCommand::Create(QObject *parent) {
return new MqttCommand_CancelControllerCommand(parent);
}
bool MqttCommand_CancelControllerCommand::processMessage(QJsonDocument msg) {
Q_UNUSED(msg);
QTOZWManager *mgr = getOZWManager();
if (mgr->cancelControllerCommand()) {
QJsonObject js;
js["status"] = "ok";
emit sendCommandUpdate(GetCommand(), js);
return true;
}
QJsonObject js;
js["status"] = "failed";
emit sendCommandUpdate(GetCommand(), js);
return false;
}

View file

@ -0,0 +1,17 @@
#ifndef CANCELCONTROLLERCOMMAND_H
#define CANCELCONTROLLERCOMMAND_H
#include "mqttcommands/mqttcommands.h"
class MqttCommand_CancelControllerCommand : public MqttCommand {
Q_OBJECT
public:
static MqttCommand *Create(QObject *parent = nullptr);
static QString StaticGetCommand() { return "CancelControllerCommand";};
QString GetCommand() override { return StaticGetCommand(); };
bool processMessage(QJsonDocument) override;
private:
MqttCommand_CancelControllerCommand(QObject *parent = nullptr);
};
#endif // CANCELCONTROLLERCOMMAND_H

View file

@ -0,0 +1,24 @@
#include "mqttcommands/checkLatestConfigFileRevision.h"
MqttCommand_CheckLatestConfigFileRevision::MqttCommand_CheckLatestConfigFileRevision(QObject *parent) :
MqttCommand(parent)
{
this->m_requiredFields << "node";
}
MqttCommand* MqttCommand_CheckLatestConfigFileRevision::Create(QObject *parent) {
return new MqttCommand_CheckLatestConfigFileRevision(parent);
}
bool MqttCommand_CheckLatestConfigFileRevision::processMessage(QJsonDocument msg) {
QTOZWManager *mgr = getOZWManager();
if (mgr->checkLatestConfigFileRevision(msg["node"].toInt())) {
QJsonObject js;
js["status"] = "ok";
emit sendCommandUpdate(GetCommand(), js);
return true;
}
QJsonObject js;
js["status"] = "failed";
emit sendCommandUpdate(GetCommand(), js);
return false;
}

View file

@ -0,0 +1,17 @@
#ifndef CHECKLATESTCONFIGFILEREVISION_H
#define CHECKLATESTCONFIGFILEREVISION_H
#include "mqttcommands/mqttcommands.h"
class MqttCommand_CheckLatestConfigFileRevision : public MqttCommand {
Q_OBJECT
public:
static MqttCommand *Create(QObject *parent = nullptr);
static QString StaticGetCommand() { return "CheckLatestConfigFileRevision";};
QString GetCommand() override { return StaticGetCommand(); };
bool processMessage(QJsonDocument) override;
private:
MqttCommand_CheckLatestConfigFileRevision(QObject *parent = nullptr);
};
#endif // CHECKLATESTCONFIGFILEREVISION_H

View file

@ -0,0 +1,19 @@
#include "mqttcommands/checkLatestMFSRevision.h"
MqttCommand_CheckLatestMFSRevision::MqttCommand_CheckLatestMFSRevision(QObject *parent) :
MqttCommand(parent)
{
}
MqttCommand* MqttCommand_CheckLatestMFSRevision::Create(QObject *parent) {
return new MqttCommand_CheckLatestMFSRevision(parent);
}
bool MqttCommand_CheckLatestMFSRevision::processMessage(QJsonDocument msg) {
Q_UNUSED(msg);
QTOZWManager *mgr = getOZWManager();
mgr->checkLatestMFSRevision();
QJsonObject js;
js["status"] = "ok";
emit sendCommandUpdate(GetCommand(), js);
return true;
}

View file

@ -0,0 +1,17 @@
#ifndef CHECKLATESTMFSREVISION_H
#define CHECKLATESTMFSREVISION_H
#include "mqttcommands/mqttcommands.h"
class MqttCommand_CheckLatestMFSRevision : public MqttCommand {
Q_OBJECT
public:
static MqttCommand *Create(QObject *parent = nullptr);
static QString StaticGetCommand() { return "CheckLatestMFSRevision";};
QString GetCommand() override { return StaticGetCommand(); };
bool processMessage(QJsonDocument) override;
private:
MqttCommand_CheckLatestMFSRevision(QObject *parent = nullptr);
};
#endif // CHECKLATESTMFSREVISION_H

View file

@ -0,0 +1,24 @@
#include "mqttcommands/deleteAllReturnRoute.h"
MqttCommand_DeleteAllReturnRoute::MqttCommand_DeleteAllReturnRoute(QObject *parent) :
MqttCommand(parent)
{
this->m_requiredFields << "node";
}
MqttCommand* MqttCommand_DeleteAllReturnRoute::Create(QObject *parent) {
return new MqttCommand_DeleteAllReturnRoute(parent);
}
bool MqttCommand_DeleteAllReturnRoute::processMessage(QJsonDocument msg) {
QTOZWManager *mgr = getOZWManager();
if (mgr->deleteAllReturnRoute(msg["node"].toInt())) {
QJsonObject js;
js["status"] = "ok";
emit sendCommandUpdate(GetCommand(), js);
return true;
}
QJsonObject js;
js["status"] = "failed";
emit sendCommandUpdate(GetCommand(), js);
return false;
}

View file

@ -0,0 +1,17 @@
#ifndef DELETEALLRETURNROUTE_H
#define DELETEALLRETURNROUTE_H
#include "mqttcommands/mqttcommands.h"
class MqttCommand_DeleteAllReturnRoute : public MqttCommand {
Q_OBJECT
public:
static MqttCommand *Create(QObject *parent = nullptr);
static QString StaticGetCommand() { return "DeleteAllReturnRoute";};
QString GetCommand() override { return StaticGetCommand(); };
bool processMessage(QJsonDocument) override;
private:
MqttCommand_DeleteAllReturnRoute(QObject *parent = nullptr);
};
#endif // DELETEALLRETURNROUTE_H

View file

@ -0,0 +1,24 @@
#include "mqttcommands/downloadLatestConfigFileRevision.h"
MqttCommand_DownloadLatestConfigFileRevision::MqttCommand_DownloadLatestConfigFileRevision(QObject *parent) :
MqttCommand(parent)
{
this->m_requiredFields << "node";
}
MqttCommand* MqttCommand_DownloadLatestConfigFileRevision::Create(QObject *parent) {
return new MqttCommand_DownloadLatestConfigFileRevision(parent);
}
bool MqttCommand_DownloadLatestConfigFileRevision::processMessage(QJsonDocument msg) {
QTOZWManager *mgr = getOZWManager();
if (mgr->downloadLatestConfigFileRevision(msg["node"].toInt())) {
QJsonObject js;
js["status"] = "ok";
emit sendCommandUpdate(GetCommand(), js);
return true;
}
QJsonObject js;
js["status"] = "failed";
emit sendCommandUpdate(GetCommand(), js);
return false;
}

View file

@ -0,0 +1,17 @@
#ifndef DOWNLOADLATESTCONFIGFILEREVISION_H
#define DOWNLOADLATESTCONFIGFILEREVISION_H
#include "mqttcommands/mqttcommands.h"
class MqttCommand_DownloadLatestConfigFileRevision : public MqttCommand {
Q_OBJECT
public:
static MqttCommand *Create(QObject *parent = nullptr);
static QString StaticGetCommand() { return "DownloadLatestConfigFileRevision";};
QString GetCommand() override { return StaticGetCommand(); };
bool processMessage(QJsonDocument) override;
private:
MqttCommand_DownloadLatestConfigFileRevision(QObject *parent = nullptr);
};
#endif // DOWNLOADLATESTCONFIGFILEREVISION_H

View file

@ -0,0 +1,24 @@
#include "mqttcommands/downloadLatestMFSRevision.h"
MqttCommand_DownloadLatestMFSRevision::MqttCommand_DownloadLatestMFSRevision(QObject *parent) :
MqttCommand(parent)
{
}
MqttCommand* MqttCommand_DownloadLatestMFSRevision::Create(QObject *parent) {
return new MqttCommand_DownloadLatestMFSRevision(parent);
}
bool MqttCommand_DownloadLatestMFSRevision::processMessage(QJsonDocument msg) {
Q_UNUSED(msg);
QTOZWManager *mgr = getOZWManager();
if (mgr->downloadLatestMFSRevision()) {
QJsonObject js;
js["status"] = "ok";
emit sendCommandUpdate(GetCommand(), js);
return true;
}
QJsonObject js;
js["status"] = "failed";
emit sendCommandUpdate(GetCommand(), js);
return false;
}

View file

@ -0,0 +1,17 @@
#ifndef DOWNLOADLATESTMFSREVISION_H
#define DOWNLOADLATESTMFSREVISION_H
#include "mqttcommands/mqttcommands.h"
class MqttCommand_DownloadLatestMFSRevision : public MqttCommand {
Q_OBJECT
public:
static MqttCommand *Create(QObject *parent = nullptr);
static QString StaticGetCommand() { return "DownloadLatestMFSRevision";};
QString GetCommand() override { return StaticGetCommand(); };
bool processMessage(QJsonDocument) override;
private:
MqttCommand_DownloadLatestMFSRevision(QObject *parent = nullptr);
};
#endif // DOWNLOADLATESTMFSREVISION_H

View file

@ -0,0 +1,19 @@
#include "mqttcommands/hardResetController.h"
MqttCommand_HardResetController::MqttCommand_HardResetController(QObject *parent) :
MqttCommand(parent)
{
}
MqttCommand* MqttCommand_HardResetController::Create(QObject *parent) {
return new MqttCommand_HardResetController(parent);
}
bool MqttCommand_HardResetController::processMessage(QJsonDocument msg) {
Q_UNUSED(msg);
QTOZWManager *mgr = getOZWManager();
mgr->hardResetController();
QJsonObject js;
js["status"] = "ok";
emit sendCommandUpdate(GetCommand(), js);
return true;
}

View file

@ -0,0 +1,17 @@
#ifndef HARDRESETCONTROLLER_H
#define HARDRESETCONTROLLER_H
#include "mqttcommands/mqttcommands.h"
class MqttCommand_HardResetController : public MqttCommand {
Q_OBJECT
public:
static MqttCommand *Create(QObject *parent = nullptr);
static QString StaticGetCommand() { return "HardResetController";};
QString GetCommand() override { return StaticGetCommand(); };
bool processMessage(QJsonDocument) override;
private:
MqttCommand_HardResetController(QObject *parent = nullptr);
};
#endif // HARDRESETCONTROLLER_H

View file

@ -0,0 +1,24 @@
#include "mqttcommands/hasNodeFailed.h"
MqttCommand_HasNodeFailed::MqttCommand_HasNodeFailed(QObject *parent) :
MqttCommand(parent)
{
this->m_requiredFields << "node";
}
MqttCommand* MqttCommand_HasNodeFailed::Create(QObject *parent) {
return new MqttCommand_HasNodeFailed(parent);
}
bool MqttCommand_HasNodeFailed::processMessage(QJsonDocument msg) {
QTOZWManager *mgr = getOZWManager();
if (mgr->hasNodeFailed(msg["node"].toInt())) {
QJsonObject js;
js["status"] = "ok";
emit sendCommandUpdate(GetCommand(), js);
return true;
}
QJsonObject js;
js["status"] = "failed";
emit sendCommandUpdate(GetCommand(), js);
return false;
}

View file

@ -0,0 +1,17 @@
#ifndef HASNODEFAILED_H
#define HASNODEFAILED_H
#include "mqttcommands/mqttcommands.h"
class MqttCommand_HasNodeFailed : public MqttCommand {
Q_OBJECT
public:
static MqttCommand *Create(QObject *parent = nullptr);
static QString StaticGetCommand() { return "HadNodeFailed";};
QString GetCommand() override { return StaticGetCommand(); };
bool processMessage(QJsonDocument) override;
private:
MqttCommand_HasNodeFailed(QObject *parent = nullptr);
};
#endif // HASNODEFAILED_H

View file

@ -0,0 +1,19 @@
#include "mqttcommands/healNetwork.h"
MqttCommand_HealNetwork::MqttCommand_HealNetwork(QObject *parent) :
MqttCommand(parent)
{
this->m_requiredFields << "doreturnroute";
}
MqttCommand* MqttCommand_HealNetwork::Create(QObject *parent) {
return new MqttCommand_HealNetwork(parent);
}
bool MqttCommand_HealNetwork::processMessage(QJsonDocument msg) {
QTOZWManager *mgr = getOZWManager();
mgr->healNetwork(msg["doreturnroute"].toBool());
QJsonObject js;
js["status"] = "ok";
emit sendCommandUpdate(GetCommand(), js);
return true;
}

View file

@ -0,0 +1,17 @@
#ifndef HEALNETWORK_H
#define HEALNETWORK_H
#include "mqttcommands/mqttcommands.h"
class MqttCommand_HealNetwork : public MqttCommand {
Q_OBJECT
public:
static MqttCommand *Create(QObject *parent = nullptr);
static QString StaticGetCommand() { return "HealNetwork";};
QString GetCommand() override { return StaticGetCommand(); };
bool processMessage(QJsonDocument) override;
private:
MqttCommand_HealNetwork(QObject *parent = nullptr);
};
#endif // PING_H

View file

@ -0,0 +1,19 @@
#include "mqttcommands/healNetworkNode.h"
MqttCommand_HealNetworkNode::MqttCommand_HealNetworkNode(QObject *parent) :
MqttCommand(parent)
{
this->m_requiredFields << "node" << "doreturnroute";
}
MqttCommand* MqttCommand_HealNetworkNode::Create(QObject *parent) {
return new MqttCommand_HealNetworkNode(parent);
}
bool MqttCommand_HealNetworkNode::processMessage(QJsonDocument msg) {
QTOZWManager *mgr = getOZWManager();
mgr->healNetworkNode(msg["node"].toInt(), msg["doreturnroute"].toBool());
QJsonObject js;
js["status"] = "ok";
emit sendCommandUpdate(GetCommand(), js);
return true;
}

View file

@ -0,0 +1,17 @@
#ifndef HEALNETWORKNODE_H
#define HEALNETWORKNODE_H
#include "mqttcommands/mqttcommands.h"
class MqttCommand_HealNetworkNode : public MqttCommand {
Q_OBJECT
public:
static MqttCommand *Create(QObject *parent = nullptr);
static QString StaticGetCommand() { return "HealNetworkNode";};
QString GetCommand() override { return StaticGetCommand(); };
bool processMessage(QJsonDocument) override;
private:
MqttCommand_HealNetworkNode(QObject *parent = nullptr);
};
#endif // HEALNETWORKNODE_H

View file

@ -1,5 +1,34 @@
#include "mqttcommands/mqttcommands.h"
#include "mqttcommands/ping.h"
#include "mqttcommands/open.h"
#include "mqttcommands/refreshnodeinfo.h"
#include "mqttcommands/requestNodeState.h"
#include "mqttcommands/requestNodeDynamic.h"
#include "mqttcommands/requestConfigParam.h"
#include "mqttcommands/requestAllConfigParam.h"
#include "mqttcommands/softResetController.h"
#include "mqttcommands/hardResetController.h"
#include "mqttcommands/cancelControllerCommand.h"
#include "mqttcommands/testNetworkNode.h"
#include "mqttcommands/testNetwork.h"
#include "mqttcommands/healNetworkNode.h"
#include "mqttcommands/healNetwork.h"
#include "mqttcommands/addNode.h"
#include "mqttcommands/addNodeSecure.h"
#include "mqttcommands/removeNode.h"
#include "mqttcommands/removeFailedNode.h"
#include "mqttcommands/hasNodeFailed.h"
#include "mqttcommands/requestNodeNeighborUpdate.h"
#include "mqttcommands/assignReturnRoute.h"
#include "mqttcommands/deleteAllReturnRoute.h"
#include "mqttcommands/sendNodeInformation.h"
#include "mqttcommands/replaceFailedNode.h"
#include "mqttcommands/requestNetworkUpdate.h"
#include "mqttcommands/IsNodeFailed.h"
#include "mqttcommands/checkLatestConfigFileRevision.h"
#include "mqttcommands/checkLatestMFSRevision.h"
#include "mqttcommands/downloadLatestConfigFileRevision.h"
#include "mqttcommands/downloadLatestMFSRevision.h"
MqttCommand::MqttCommand(QObject *parent) :
@ -73,6 +102,35 @@ void MqttCommands::Register(QString command, pfnCreateCommand_t _create) {
void MqttCommands::setupCommands() {
this->Register(MqttCommand_Ping::StaticGetCommand(), &MqttCommand_Ping::Create);
this->Register(MqttCommand_Open::StaticGetCommand(), &MqttCommand_Open::Create);
this->Register(MqttCommand_RefreshNodeInfo::StaticGetCommand(), &MqttCommand_RefreshNodeInfo::Create);
this->Register(MqttCommand_RequestNodeState::StaticGetCommand(), &MqttCommand_RequestNodeState::Create);
this->Register(MqttCommand_RequestNodeDynamic::StaticGetCommand(), &MqttCommand_RequestNodeDynamic::Create);
this->Register(MqttCommand_RequestConfigParam::StaticGetCommand(), &MqttCommand_RequestConfigParam::Create);
this->Register(MqttCommand_RequestAllConfigParam::StaticGetCommand(), &MqttCommand_RequestAllConfigParam::Create);
this->Register(MqttCommand_SoftResetController::StaticGetCommand(), &MqttCommand_SoftResetController::Create);
this->Register(MqttCommand_HardResetController::StaticGetCommand(), &MqttCommand_HardResetController::Create);
this->Register(MqttCommand_CancelControllerCommand::StaticGetCommand(), &MqttCommand_CancelControllerCommand::Create);
this->Register(MqttCommand_TestNetworkNode::StaticGetCommand(), &MqttCommand_TestNetworkNode::Create);
this->Register(MqttCommand_TestNetwork::StaticGetCommand(), &MqttCommand_TestNetwork::Create);
this->Register(MqttCommand_HealNetworkNode::StaticGetCommand(), &MqttCommand_HealNetworkNode::Create);
this->Register(MqttCommand_HealNetwork::StaticGetCommand(), &MqttCommand_HealNetwork::Create);
this->Register(MqttCommand_AddNode::StaticGetCommand(), &MqttCommand_AddNode::Create);
this->Register(MqttCommand_AddNodeSecure::StaticGetCommand(), &MqttCommand_AddNodeSecure::Create);
this->Register(MqttCommand_RemoveNode::StaticGetCommand(), &MqttCommand_RemoveNode::Create);
this->Register(MqttCommand_RemoveFailedNode::StaticGetCommand(), &MqttCommand_RemoveFailedNode::Create);
this->Register(MqttCommand_HasNodeFailed::StaticGetCommand(), &MqttCommand_HasNodeFailed::Create);
this->Register(MqttCommand_RequestNodeNeighborUpdate::StaticGetCommand(), &MqttCommand_RequestNodeNeighborUpdate::Create);
this->Register(MqttCommand_AssignReturnRoute::StaticGetCommand(), &MqttCommand_AssignReturnRoute::Create);
this->Register(MqttCommand_DeleteAllReturnRoute::StaticGetCommand(), &MqttCommand_DeleteAllReturnRoute::Create);
this->Register(MqttCommand_SendNodeInformation::StaticGetCommand(), &MqttCommand_SendNodeInformation::Create);
this->Register(MqttCommand_ReplaceFailedNode::StaticGetCommand(), &MqttCommand_ReplaceFailedNode::Create);
this->Register(MqttCommand_RequestNetworkUpdate::StaticGetCommand(), &MqttCommand_RequestNetworkUpdate::Create);
this->Register(MqttCommand_IsNodeFailed::StaticGetCommand(), &MqttCommand_IsNodeFailed::Create);
this->Register(MqttCommand_CheckLatestConfigFileRevision::StaticGetCommand(), &MqttCommand_CheckLatestConfigFileRevision::Create);
this->Register(MqttCommand_CheckLatestMFSRevision::StaticGetCommand(), &MqttCommand_CheckLatestMFSRevision::Create);
this->Register(MqttCommand_DownloadLatestConfigFileRevision::StaticGetCommand(), &MqttCommand_DownloadLatestConfigFileRevision::Create);
this->Register(MqttCommand_DownloadLatestMFSRevision::StaticGetCommand(), &MqttCommand_DownloadLatestMFSRevision::Create);
}
void MqttCommands::setupSubscriptions(QMqttClient *mqttclient, QString topTopic) {

View file

@ -17,7 +17,6 @@ class mqttpublisher;
class MqttCommand : public QObject {
Q_OBJECT
public:
MqttCommand(QObject *parent = nullptr);
void Setup(QMqttSubscription *);
void messageReceived(QMqttMessage msg);
virtual bool processMessage(QJsonDocument) = 0;
@ -25,6 +24,7 @@ public:
signals:
void sendCommandUpdate(QString, QJsonObject);
protected:
MqttCommand(QObject *parent = nullptr);
QTOZWManager *getOZWManager();
mqttpublisher *getMqttPublisher();
QVector<QString> m_requiredFields;

View file

@ -0,0 +1,24 @@
#include "mqttcommands/open.h"
MqttCommand_Open::MqttCommand_Open(QObject *parent) :
MqttCommand(parent)
{
this->m_requiredFields << "serialport";
}
MqttCommand* MqttCommand_Open::Create(QObject *parent) {
return new MqttCommand_Open(parent);
}
bool MqttCommand_Open::processMessage(QJsonDocument msg) {
QTOZWManager *mgr = getOZWManager();
if (mgr->open(msg["serialport"].toString())) {
QJsonObject js;
js["status"] = "ok";
emit sendCommandUpdate(GetCommand(), js);
return true;
}
QJsonObject js;
js["status"] = "failed";
emit sendCommandUpdate(GetCommand(), js);
return false;
}

View file

@ -0,0 +1,17 @@
#ifndef OPEN_H
#define OPEN_H
#include "mqttcommands/mqttcommands.h"
class MqttCommand_Open : public MqttCommand {
Q_OBJECT
public:
static MqttCommand *Create(QObject *parent = nullptr);
static QString StaticGetCommand() { return "Open";};
QString GetCommand() override { return StaticGetCommand(); };
bool processMessage(QJsonDocument) override;
private:
MqttCommand_Open(QObject *parent = nullptr);
};
#endif // PING_H

View file

@ -6,11 +6,12 @@
class MqttCommand_Ping : public MqttCommand {
Q_OBJECT
public:
MqttCommand_Ping(QObject *parent = nullptr);
static MqttCommand *Create(QObject *parent = nullptr);
static QString StaticGetCommand() { return "Ping";};
QString GetCommand() override { return StaticGetCommand(); };
bool processMessage(QJsonDocument) override;
private:
MqttCommand_Ping(QObject *parent = nullptr);
};
#endif // PING_H

View file

@ -0,0 +1,24 @@
#include "mqttcommands/refreshnodeinfo.h"
MqttCommand_RefreshNodeInfo::MqttCommand_RefreshNodeInfo(QObject *parent) :
MqttCommand(parent)
{
this->m_requiredFields << "node";
}
MqttCommand* MqttCommand_RefreshNodeInfo::Create(QObject *parent) {
return new MqttCommand_RefreshNodeInfo(parent);
}
bool MqttCommand_RefreshNodeInfo::processMessage(QJsonDocument msg) {
QTOZWManager *mgr = getOZWManager();
if (mgr->refreshNodeInfo(msg["node"].toInt())) {
QJsonObject js;
js["status"] = "ok";
emit sendCommandUpdate(GetCommand(), js);
return true;
}
QJsonObject js;
js["status"] = "failed";
emit sendCommandUpdate(GetCommand(), js);
return false;
}

View file

@ -0,0 +1,17 @@
#ifndef REFRESHNODEINFO_H
#define REFRESHNODEINFO_H
#include "mqttcommands/mqttcommands.h"
class MqttCommand_RefreshNodeInfo : public MqttCommand {
Q_OBJECT
public:
static MqttCommand *Create(QObject *parent = nullptr);
static QString StaticGetCommand() { return "RefreshNodeInfo";};
QString GetCommand() override { return StaticGetCommand(); };
bool processMessage(QJsonDocument) override;
private:
MqttCommand_RefreshNodeInfo(QObject *parent = nullptr);
};
#endif // PING_H

View file

@ -0,0 +1,24 @@
#include "mqttcommands/removeFailedNode.h"
MqttCommand_RemoveFailedNode::MqttCommand_RemoveFailedNode(QObject *parent) :
MqttCommand(parent)
{
this->m_requiredFields << "node";
}
MqttCommand* MqttCommand_RemoveFailedNode::Create(QObject *parent) {
return new MqttCommand_RemoveFailedNode(parent);
}
bool MqttCommand_RemoveFailedNode::processMessage(QJsonDocument msg) {
QTOZWManager *mgr = getOZWManager();
if (mgr->removeFailedNode(msg["node"].toInt())) {
QJsonObject js;
js["status"] = "ok";
emit sendCommandUpdate(GetCommand(), js);
return true;
}
QJsonObject js;
js["status"] = "failed";
emit sendCommandUpdate(GetCommand(), js);
return false;
}

View file

@ -0,0 +1,17 @@
#ifndef REMOVEFAILEDNODE_H
#define REMOVEFAILEDNODE_H
#include "mqttcommands/mqttcommands.h"
class MqttCommand_RemoveFailedNode : public MqttCommand {
Q_OBJECT
public:
static MqttCommand *Create(QObject *parent = nullptr);
static QString StaticGetCommand() { return "RemoveFailedNode";};
QString GetCommand() override { return StaticGetCommand(); };
bool processMessage(QJsonDocument) override;
private:
MqttCommand_RemoveFailedNode(QObject *parent = nullptr);
};
#endif // PING_H

View file

@ -0,0 +1,19 @@
#include "mqttcommands/removeNode.h"
MqttCommand_RemoveNode::MqttCommand_RemoveNode(QObject *parent) :
MqttCommand(parent)
{
}
MqttCommand* MqttCommand_RemoveNode::Create(QObject *parent) {
return new MqttCommand_RemoveNode(parent);
}
bool MqttCommand_RemoveNode::processMessage(QJsonDocument msg) {
Q_UNUSED(msg);
QTOZWManager *mgr = getOZWManager();
mgr->removeNode();
QJsonObject js;
js["status"] = "ok";
emit sendCommandUpdate(GetCommand(), js);
return true;
}

View file

@ -0,0 +1,17 @@
#ifndef REMOVENODE_H
#define REMOVENODE_H
#include "mqttcommands/mqttcommands.h"
class MqttCommand_RemoveNode : public MqttCommand {
Q_OBJECT
public:
static MqttCommand *Create(QObject *parent = nullptr);
static QString StaticGetCommand() { return "RemoveNode";};
QString GetCommand() override { return StaticGetCommand(); };
bool processMessage(QJsonDocument) override;
private:
MqttCommand_RemoveNode(QObject *parent = nullptr);
};
#endif // PING_H

View file

@ -0,0 +1,24 @@
#include "mqttcommands/replaceFailedNode.h"
MqttCommand_ReplaceFailedNode::MqttCommand_ReplaceFailedNode(QObject *parent) :
MqttCommand(parent)
{
this->m_requiredFields << "node";
}
MqttCommand* MqttCommand_ReplaceFailedNode::Create(QObject *parent) {
return new MqttCommand_ReplaceFailedNode(parent);
}
bool MqttCommand_ReplaceFailedNode::processMessage(QJsonDocument msg) {
QTOZWManager *mgr = getOZWManager();
if (mgr->replaceFailedNode(msg["node"].toInt())) {
QJsonObject js;
js["status"] = "ok";
emit sendCommandUpdate(GetCommand(), js);
return true;
}
QJsonObject js;
js["status"] = "failed";
emit sendCommandUpdate(GetCommand(), js);
return false;
}

View file

@ -0,0 +1,17 @@
#ifndef REPLACEFAILEDNODE_H
#define REPLACEFAILEDNODE_H
#include "mqttcommands/mqttcommands.h"
class MqttCommand_ReplaceFailedNode : public MqttCommand {
Q_OBJECT
public:
static MqttCommand *Create(QObject *parent = nullptr);
static QString StaticGetCommand() { return "ReplaceFailedNode";};
QString GetCommand() override { return StaticGetCommand(); };
bool processMessage(QJsonDocument) override;
private:
MqttCommand_ReplaceFailedNode(QObject *parent = nullptr);
};
#endif // REPLACEFAILEDNODE_H

View file

@ -0,0 +1,19 @@
#include "mqttcommands/requestAllConfigParam.h"
MqttCommand_RequestAllConfigParam::MqttCommand_RequestAllConfigParam(QObject *parent) :
MqttCommand(parent)
{
this->m_requiredFields << "node";
}
MqttCommand* MqttCommand_RequestAllConfigParam::Create(QObject *parent) {
return new MqttCommand_RequestAllConfigParam(parent);
}
bool MqttCommand_RequestAllConfigParam::processMessage(QJsonDocument msg) {
QTOZWManager *mgr = getOZWManager();
mgr->requestAllConfigParam(msg["node"].toInt());
QJsonObject js;
js["status"] = "ok";
emit sendCommandUpdate(GetCommand(), js);
return true;
}

View file

@ -0,0 +1,17 @@
#ifndef REQUESTALLCONFIGPARAM_H
#define REQUESTALLCONFIGPARAM_H
#include "mqttcommands/mqttcommands.h"
class MqttCommand_RequestAllConfigParam : public MqttCommand {
Q_OBJECT
public:
static MqttCommand *Create(QObject *parent = nullptr);
static QString StaticGetCommand() { return "RequestAllConfigParam";};
QString GetCommand() override { return StaticGetCommand(); };
bool processMessage(QJsonDocument) override;
private:
MqttCommand_RequestAllConfigParam(QObject *parent = nullptr);
};
#endif // REQUESTALLCONFIGPARAM_H

View file

@ -0,0 +1,19 @@
#include "mqttcommands/requestConfigParam.h"
MqttCommand_RequestConfigParam::MqttCommand_RequestConfigParam(QObject *parent) :
MqttCommand(parent)
{
this->m_requiredFields << "node" << "param";
}
MqttCommand* MqttCommand_RequestConfigParam::Create(QObject *parent) {
return new MqttCommand_RequestConfigParam(parent);
}
bool MqttCommand_RequestConfigParam::processMessage(QJsonDocument msg) {
QTOZWManager *mgr = getOZWManager();
mgr->requestConfigParam(msg["node"].toInt(), msg["param"].toInt());
QJsonObject js;
js["status"] = "ok";
emit sendCommandUpdate(GetCommand(), js);
return true;
}

View file

@ -0,0 +1,17 @@
#ifndef REQUESTCONFIGPARAM_H
#define REQUESTCONFIGPARAM_H
#include "mqttcommands/mqttcommands.h"
class MqttCommand_RequestConfigParam : public MqttCommand {
Q_OBJECT
public:
static MqttCommand *Create(QObject *parent = nullptr);
static QString StaticGetCommand() { return "RequestConfigParam";};
QString GetCommand() override { return StaticGetCommand(); };
bool processMessage(QJsonDocument) override;
private:
MqttCommand_RequestConfigParam(QObject *parent = nullptr);
};
#endif // PING_H

View file

@ -0,0 +1,24 @@
#include "mqttcommands/requestNetworkUpdate.h"
MqttCommand_RequestNetworkUpdate::MqttCommand_RequestNetworkUpdate(QObject *parent) :
MqttCommand(parent)
{
this->m_requiredFields << "MqttCommand_RequestNetworkUpdate";
}
MqttCommand* MqttCommand_RequestNetworkUpdate::Create(QObject *parent) {
return new MqttCommand_RequestNetworkUpdate(parent);
}
bool MqttCommand_RequestNetworkUpdate::processMessage(QJsonDocument msg) {
QTOZWManager *mgr = getOZWManager();
if (mgr->requestNetworkUpdate(msg["node"].toInt())) {
QJsonObject js;
js["status"] = "ok";
emit sendCommandUpdate(GetCommand(), js);
return true;
}
QJsonObject js;
js["status"] = "failed";
emit sendCommandUpdate(GetCommand(), js);
return false;
}

View file

@ -0,0 +1,17 @@
#ifndef REQUESTNETWORKUPDATE_H
#define REQUESTNETWORKUPDATE_H
#include "mqttcommands/mqttcommands.h"
class MqttCommand_RequestNetworkUpdate : public MqttCommand {
Q_OBJECT
public:
static MqttCommand *Create(QObject *parent = nullptr);
static QString StaticGetCommand() { return "RequestNetworkUpdate";};
QString GetCommand() override { return StaticGetCommand(); };
bool processMessage(QJsonDocument) override;
private:
MqttCommand_RequestNetworkUpdate(QObject *parent = nullptr);
};
#endif // REQUESTNETWORKUPDATE_H

View file

@ -0,0 +1,24 @@
#include "mqttcommands/requestNodeDynamic.h"
MqttCommand_RequestNodeDynamic::MqttCommand_RequestNodeDynamic(QObject *parent) :
MqttCommand(parent)
{
this->m_requiredFields << "node";
}
MqttCommand* MqttCommand_RequestNodeDynamic::Create(QObject *parent) {
return new MqttCommand_RequestNodeDynamic(parent);
}
bool MqttCommand_RequestNodeDynamic::processMessage(QJsonDocument msg) {
QTOZWManager *mgr = getOZWManager();
if (mgr->requestNodeDynamic(msg["node"].toInt())) {
QJsonObject js;
js["status"] = "ok";
emit sendCommandUpdate(GetCommand(), js);
return true;
}
QJsonObject js;
js["status"] = "failed";
emit sendCommandUpdate(GetCommand(), js);
return false;
}

View file

@ -0,0 +1,17 @@
#ifndef REQUESTNODEDYNAMIC_H
#define REQUESTNODEDYNAMIC_H
#include "mqttcommands/mqttcommands.h"
class MqttCommand_RequestNodeDynamic : public MqttCommand {
Q_OBJECT
public:
static MqttCommand *Create(QObject *parent = nullptr);
static QString StaticGetCommand() { return "RequestNodeDynamic";};
QString GetCommand() override { return StaticGetCommand(); };
bool processMessage(QJsonDocument) override;
private:
MqttCommand_RequestNodeDynamic(QObject *parent = nullptr);
};
#endif // REQUESTNODEDYNAMIC_H

View file

@ -0,0 +1,24 @@
#include "mqttcommands/requestNodeNeighborUpdate.h"
MqttCommand_RequestNodeNeighborUpdate::MqttCommand_RequestNodeNeighborUpdate(QObject *parent) :
MqttCommand(parent)
{
this->m_requiredFields << "node";
}
MqttCommand* MqttCommand_RequestNodeNeighborUpdate::Create(QObject *parent) {
return new MqttCommand_RequestNodeNeighborUpdate(parent);
}
bool MqttCommand_RequestNodeNeighborUpdate::processMessage(QJsonDocument msg) {
QTOZWManager *mgr = getOZWManager();
if (mgr->requestNodeNeighborUpdate(msg["node"].toInt())) {
QJsonObject js;
js["status"] = "ok";
emit sendCommandUpdate(GetCommand(), js);
return true;
}
QJsonObject js;
js["status"] = "failed";
emit sendCommandUpdate(GetCommand(), js);
return false;
}

View file

@ -0,0 +1,17 @@
#ifndef REQUESTNODENEIGHBORUPDATE_H
#define REQUESTNODENEIGHBORUPDATE_H
#include "mqttcommands/mqttcommands.h"
class MqttCommand_RequestNodeNeighborUpdate : public MqttCommand {
Q_OBJECT
public:
static MqttCommand *Create(QObject *parent = nullptr);
static QString StaticGetCommand() { return "RequestNodeNeighborUpdate";};
QString GetCommand() override { return StaticGetCommand(); };
bool processMessage(QJsonDocument) override;
private:
MqttCommand_RequestNodeNeighborUpdate(QObject *parent = nullptr);
};
#endif // REQUESTNODENEIGHBORUPDATE_H

View file

@ -0,0 +1,24 @@
#include "mqttcommands/requestNodeState.h"
MqttCommand_RequestNodeState::MqttCommand_RequestNodeState(QObject *parent) :
MqttCommand(parent)
{
this->m_requiredFields << "node";
}
MqttCommand* MqttCommand_RequestNodeState::Create(QObject *parent) {
return new MqttCommand_RequestNodeState(parent);
}
bool MqttCommand_RequestNodeState::processMessage(QJsonDocument msg) {
QTOZWManager *mgr = getOZWManager();
if (mgr->requestNodeState(msg["node"].toInt())) {
QJsonObject js;
js["status"] = "ok";
emit sendCommandUpdate(GetCommand(), js);
return true;
}
QJsonObject js;
js["status"] = "failed";
emit sendCommandUpdate(GetCommand(), js);
return false;
}

View file

@ -0,0 +1,17 @@
#ifndef REQUESTNODESTATE_H
#define REQUESTNODESTATE_H
#include "mqttcommands/mqttcommands.h"
class MqttCommand_RequestNodeState : public MqttCommand {
Q_OBJECT
public:
static MqttCommand *Create(QObject *parent = nullptr);
static QString StaticGetCommand() { return "RequestNodeState";};
QString GetCommand() override { return StaticGetCommand(); };
bool processMessage(QJsonDocument) override;
private:
MqttCommand_RequestNodeState(QObject *parent = nullptr);
};
#endif // REQUESTNODESTATE_H

View file

@ -0,0 +1,24 @@
#include "mqttcommands/sendNodeInformation.h"
MqttCommand_SendNodeInformation::MqttCommand_SendNodeInformation(QObject *parent) :
MqttCommand(parent)
{
this->m_requiredFields << "node";
}
MqttCommand* MqttCommand_SendNodeInformation::Create(QObject *parent) {
return new MqttCommand_SendNodeInformation(parent);
}
bool MqttCommand_SendNodeInformation::processMessage(QJsonDocument msg) {
QTOZWManager *mgr = getOZWManager();
if (mgr->sendNodeInformation(msg["node"].toInt())) {
QJsonObject js;
js["status"] = "ok";
emit sendCommandUpdate(GetCommand(), js);
return true;
}
QJsonObject js;
js["status"] = "failed";
emit sendCommandUpdate(GetCommand(), js);
return false;
}

View file

@ -0,0 +1,17 @@
#ifndef SENTNODEINFORMATION_H
#define SENTNODEINFORMATION_H
#include "mqttcommands/mqttcommands.h"
class MqttCommand_SendNodeInformation : public MqttCommand {
Q_OBJECT
public:
static MqttCommand *Create(QObject *parent = nullptr);
static QString StaticGetCommand() { return "SendNodeInformation";};
QString GetCommand() override { return StaticGetCommand(); };
bool processMessage(QJsonDocument) override;
private:
MqttCommand_SendNodeInformation(QObject *parent = nullptr);
};
#endif // PING_H

View file

@ -0,0 +1,19 @@
#include "mqttcommands/softResetController.h"
MqttCommand_SoftResetController::MqttCommand_SoftResetController(QObject *parent) :
MqttCommand(parent)
{
}
MqttCommand* MqttCommand_SoftResetController::Create(QObject *parent) {
return new MqttCommand_SoftResetController(parent);
}
bool MqttCommand_SoftResetController::processMessage(QJsonDocument msg) {
Q_UNUSED(msg);
QTOZWManager *mgr = getOZWManager();
mgr->softResetController();
QJsonObject js;
js["status"] = "ok";
emit sendCommandUpdate(GetCommand(), js);
return true;
}

View file

@ -0,0 +1,17 @@
#ifndef SOFTRESETCONTROLLER_H
#define SOFTRESETCONTROLLER_H
#include "mqttcommands/mqttcommands.h"
class MqttCommand_SoftResetController : public MqttCommand {
Q_OBJECT
public:
static MqttCommand *Create(QObject *parent = nullptr);
static QString StaticGetCommand() { return "SoftResetController";};
QString GetCommand() override { return StaticGetCommand(); };
bool processMessage(QJsonDocument) override;
private:
MqttCommand_SoftResetController(QObject *parent = nullptr);
};
#endif // SOFTRESETCONTROLLER_H

View file

@ -0,0 +1,19 @@
#include "mqttcommands/testNetwork.h"
MqttCommand_TestNetwork::MqttCommand_TestNetwork(QObject *parent) :
MqttCommand(parent)
{
this->m_requiredFields << "count";
}
MqttCommand* MqttCommand_TestNetwork::Create(QObject *parent) {
return new MqttCommand_TestNetwork(parent);
}
bool MqttCommand_TestNetwork::processMessage(QJsonDocument msg) {
QTOZWManager *mgr = getOZWManager();
mgr->testNetwork(msg["count"].toInt());
QJsonObject js;
js["status"] = "ok";
emit sendCommandUpdate(GetCommand(), js);
return true;
}

View file

@ -0,0 +1,17 @@
#ifndef TESTNETWORK_H
#define TESTNETWORK_H
#include "mqttcommands/mqttcommands.h"
class MqttCommand_TestNetwork : public MqttCommand {
Q_OBJECT
public:
static MqttCommand *Create(QObject *parent = nullptr);
static QString StaticGetCommand() { return "TestNetwork";};
QString GetCommand() override { return StaticGetCommand(); };
bool processMessage(QJsonDocument) override;
private:
MqttCommand_TestNetwork(QObject *parent = nullptr);
};
#endif // TESTNETWORK_H

View file

@ -0,0 +1,19 @@
#include "mqttcommands/testNetworkNode.h"
MqttCommand_TestNetworkNode::MqttCommand_TestNetworkNode(QObject *parent) :
MqttCommand(parent)
{
this->m_requiredFields << "node" << "count";
}
MqttCommand* MqttCommand_TestNetworkNode::Create(QObject *parent) {
return new MqttCommand_TestNetworkNode(parent);
}
bool MqttCommand_TestNetworkNode::processMessage(QJsonDocument msg) {
QTOZWManager *mgr = getOZWManager();
mgr->testNetworkNode(msg["node"].toInt(), msg["count"].toInt());
QJsonObject js;
js["status"] = "ok";
emit sendCommandUpdate(GetCommand(), js);
return true;
}

View file

@ -0,0 +1,17 @@
#ifndef TESTNETWORKNODE_H
#define TESTNETWORKNODE_H
#include "mqttcommands/mqttcommands.h"
class MqttCommand_TestNetworkNode : public MqttCommand {
Q_OBJECT
public:
static MqttCommand *Create(QObject *parent = nullptr);
static QString StaticGetCommand() { return "TestNetworkNode";};
QString GetCommand() override { return StaticGetCommand(); };
bool processMessage(QJsonDocument) override;
private:
MqttCommand_TestNetworkNode(QObject *parent = nullptr);
};
#endif // PING_H

View file

@ -4,7 +4,7 @@ QT += remoteobjects mqtt
TARGET = ../ozwdaemon
CONFIG += c++11 console
CONFIG += c++11 console silent
CONFIG -= app_bundle
# The following define makes your compiler emit warnings if you use
@ -20,10 +20,40 @@ DEFINES += QT_DEPRECATED_WARNINGS
SOURCES += \
main.cpp \
mqttcommands/ping.cpp \
mqttpublisher.cpp \
qtozwdaemon.cpp \
mqttcommands/mqttcommands.cpp
mqttcommands/mqttcommands.cpp \
mqttcommands/ping.cpp \
mqttcommands/open.cpp \
mqttcommands/refreshnodeinfo.cpp \
mqttcommands/requestNodeState.cpp \
mqttcommands/requestNodeDynamic.cpp \
mqttcommands/requestConfigParam.cpp \
mqttcommands/requestAllConfigParam.cpp \
mqttcommands/softResetController.cpp \
mqttcommands/hardResetController.cpp \
mqttcommands/cancelControllerCommand.cpp \
mqttcommands/testNetworkNode.cpp \
mqttcommands/testNetwork.cpp \
mqttcommands/healNetworkNode.cpp \
mqttcommands/healNetwork.cpp \
mqttcommands/addNode.cpp \
mqttcommands/addNodeSecure.cpp \
mqttcommands/removeNode.cpp \
mqttcommands/removeFailedNode.cpp \
mqttcommands/hasNodeFailed.cpp \
mqttcommands/requestNodeNeighborUpdate.cpp \
mqttcommands/assignReturnRoute.cpp \
mqttcommands/deleteAllReturnRoute.cpp \
mqttcommands/sendNodeInformation.cpp \
mqttcommands/replaceFailedNode.cpp \
mqttcommands/requestNetworkUpdate.cpp \
mqttcommands/IsNodeFailed.cpp \
mqttcommands/checkLatestConfigFileRevision.cpp \
mqttcommands/checkLatestMFSRevision.cpp \
mqttcommands/downloadLatestConfigFileRevision.cpp \
mqttcommands/downloadLatestMFSRevision.cpp
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
@ -31,10 +61,41 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
HEADERS += \
mqttcommands/ping.h \
mqttpublisher.h \
qtozwdaemon.h \
mqttcommands/mqttcommands.h
mqttcommands/mqttcommands.h \
mqttcommands/ping.h \
mqttcommands/open.h \
mqttcommands/refreshnodeinfo.h \
mqttcommands/requestNodeState.h \
mqttcommands/requestNodeDynamic.h \
mqttcommands/requestConfigParam.h \
mqttcommands/requestAllConfigParam.h \
mqttcommands/softResetController.h \
mqttcommands/hardResetController.h \
mqttcommands/cancelControllerCommand.h \
mqttcommands/testNetworkNode.h \
mqttcommands/testNetwork.h \
mqttcommands/healNetworkNode.h \
mqttcommands/healNetwork.h \
mqttcommands/addNode.h \
mqttcommands/addNodeSecure.h \
mqttcommands/removeNode.h \
mqttcommands/removeFailedNode.h \
mqttcommands/hasNodeFailed.h \
mqttcommands/requestNodeNeighborUpdate.h \
mqttcommands/assignReturnRoute.h \
mqttcommands/deleteAllReturnRoute.h \
mqttcommands/sendNodeInformation.h \
mqttcommands/replaceFailedNode.h \
mqttcommands/requestNetworkUpdate.h \
mqttcommands/IsNodeFailed.h \
mqttcommands/checkLatestConfigFileRevision.h \
mqttcommands/CheckLatestMFSRevision.h \
mqttcommands/downloadLatestConfigFileRevision.h \
mqttcommands/downloadLatestMFSRevision.h
include(../qt-openzwave.pri)