Exit on Failure Flag

This commit is contained in:
Justin Hammond 2019-12-29 15:19:09 +08:00
parent d6634e833e
commit d8ea87468e
2 changed files with 27 additions and 8 deletions

View file

@ -77,6 +77,10 @@ int main(int argc, char *argv[])
#endif
QCommandLineOption StopOnFailure(QStringList() << "stop-on-failure",
"Exit on Driver Failure"
);
parser.addOption(StopOnFailure);
parser.process(a);
@ -173,7 +177,9 @@ int main(int argc, char *argv[])
}
#endif
if (parser.isSet(StopOnFailure)) {
settings.setValue("StopOnFailure", true);
}
QTOZWOptions options(QTOZWOptions::Local);
options.setUserPath(userPath);

View file

@ -279,15 +279,25 @@ void mqttpublisher::setOZWDaemon(qtozwdaemon *ozwdaemon) {
void mqttpublisher::updateLogStateChange()
{
qCDebug(ozwmp) << "State Change" << m_client->state();
if (settings->value("MQTTTLS").toBool() == true && this->m_client->state() == QMqttClient::ClientState::Connecting) {
QSslSocket *socket = qobject_cast<QSslSocket *>(this->m_client->transport());
socket->setPeerVerifyMode(QSslSocket::PeerVerifyMode::VerifyNone);
}
if (this->m_client->state() == QMqttClient::ClientState::Connected) {
qCDebug(ozwmp) << "MQTT State Change" << m_client->state();
if (this->m_client->state() == QMqttClient::ClientState::Connecting) {
qCInfo(ozwmp) << "MQTT Client Connecting";
if (settings->value("MQTTTLS").toBool() == true) {
QSslSocket *socket = qobject_cast<QSslSocket *>(this->m_client->transport());
socket->setPeerVerifyMode(QSslSocket::PeerVerifyMode::VerifyNone);
}
} else if (this->m_client->state() == QMqttClient::ClientState::Connected) {
qCInfo(ozwmp) << "MQTT Client Connected";
this->m_cleanTopicSubscription = this->m_client->subscribe(QMqttTopicFilter(getTopic("#")));
connect(this->m_cleanTopicSubscription, &QMqttSubscription::messageReceived, this, &mqttpublisher::cleanTopics);
this->m_commands->setupSubscriptions(this->m_client, this->getCommandTopic());
return;
} else if (this->m_client->state() == QMqttClient::ClientState::Disconnected) {
if (settings->value("StopOnFailure", false).toBool()) {
qCWarning(ozwmp) << "Exiting on Failure";
exit(-1);
}
return;
}
}
@ -609,7 +619,10 @@ void mqttpublisher::driverFailed(quint32 homeID) {
QT2JS::SetString(this->m_ozwstatus, "Status", "driverFailed");
QT2JS::SetUint(this->m_ozwstatus, "homeID", homeID);
this->sendStatusUpdate();
/* XXX TODO: Scan Nodes, Instances, CC and Value Lists and delete them */
if (settings->value("StopOnFailure", false).toBool()) {
qCWarning(ozwmp) << "Exiting on Failure";
exit(-1);
}
}
void mqttpublisher::driverReset(quint32 homeID) {
qCDebug(ozwmp) << "Publishing Event driverReset:" << homeID;