ENABLE_MQTT c++ macro definition (#1546)

* macro

* 2

* 2

* delete jomjol_mqtt from CMakeLists

* mqtt macro

* final
This commit is contained in:
Nicolas Liaudat
2022-12-11 16:04:56 +01:00
committed by GitHub
parent 3f85f9b755
commit 286915b647
15 changed files with 115 additions and 38 deletions

View File

@@ -19,9 +19,10 @@ extern "C" {
#include "time_sntp.h"
#include "Helper.h"
#include "server_ota.h"
#include "interface_mqtt.h"
#include "server_mqtt.h"
#ifdef ENABLE_MQTT
#include "interface_mqtt.h"
#include "server_mqtt.h"
#endif //ENABLE_MQTT
//#include "CImg.h"
@@ -50,9 +51,11 @@ std::string ClassFlowControll::doSingleStep(std::string _stepname, std::string _
if ((_stepname.compare("[Analog]") == 0) || (_stepname.compare(";[Analog]") == 0)){
_classname = "ClassFlowCNNGeneral";
}
#ifdef ENABLE_MQTT
if ((_stepname.compare("[MQTT]") == 0) || (_stepname.compare(";[MQTT]") == 0)){
_classname = "ClassFlowMQTT";
}
#endif //ENABLE_MQTT
if ((_stepname.compare("[InfluxDB]") == 0) || (_stepname.compare(";[InfluxDB]") == 0)){
_classname = "ClassFlowInfluxDB";
}
@@ -78,8 +81,10 @@ std::string ClassFlowControll::TranslateAktstatus(std::string _input)
return ("Aligning");
if (_input.compare("ClassFlowCNNGeneral") == 0)
return ("Digitalization of ROIs");
#ifdef ENABLE_MQTT
if (_input.compare("ClassFlowMQTT") == 0)
return ("Sending MQTT");
#endif //ENABLE_MQTT
if (_input.compare("ClassFlowInfluxDB") == 0)
return ("Sending InfluxDB");
if (_input.compare("ClassFlowPostProcessing") == 0)
@@ -130,7 +135,7 @@ t_CNNType ClassFlowControll::GetTypeAnalog()
#ifdef ENABLE_MQTT
string ClassFlowControll::GetMQTTMainTopic()
{
for (int i = 0; i < FlowControll.size(); ++i)
@@ -149,7 +154,7 @@ bool ClassFlowControll::StartMQTTService() {
}
return false;
}
#endif //ENABLE_MQTT
void ClassFlowControll::SetInitialParameter(void)
{
@@ -196,8 +201,10 @@ ClassFlow* ClassFlowControll::CreateClassFlow(std::string _type)
cfc = new ClassFlowCNNGeneral(flowalignment);
flowdigit = (ClassFlowCNNGeneral*) cfc;
}
#ifdef ENABLE_MQTT
if (toUpper(_type).compare("[MQTT]") == 0)
cfc = new ClassFlowMQTT(&FlowControll);
#endif //ENABLE_MQTT
if (toUpper(_type).compare("[INFLUXDB]") == 0)
cfc = new ClassFlowInfluxDB(&FlowControll);
@@ -287,8 +294,9 @@ void ClassFlowControll::doFlowMakeImageOnly(string time){
zw_time = gettimestring("%H:%M:%S");
std::string flowStatus = TranslateAktstatus(FlowControll[i]->name());
aktstatus = flowStatus + " (" + zw_time + ")";
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, flowStatus);
#ifdef ENABLE_MQTT
MQTTPublish(mqttServer_getMainTopic() + "/" + "status", flowStatus, false);
#endif //ENABLE_MQTT
FlowControll[i]->doFlow(time);
}
@@ -318,8 +326,9 @@ bool ClassFlowControll::doFlow(string time)
zw_time = gettimestring("%H:%M:%S");
std::string flowStatus = TranslateAktstatus(FlowControll[i]->name());
aktstatus = flowStatus + " (" + zw_time + ")";
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, flowStatus);
#ifdef ENABLE_MQTT
MQTTPublish(mqttServer_getMainTopic() + "/" + "status", flowStatus, false);
#endif //ENABLE_MQTT
string zw = "FlowControll.doFlow - " + FlowControll[i]->name();
#ifdef DEBUG_DETAIL_ON
@@ -350,8 +359,9 @@ bool ClassFlowControll::doFlow(string time)
zw_time = gettimestring("%H:%M:%S");
std::string flowStatus = "Flow finished";
aktstatus = flowStatus + " (" + zw_time + ")";
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, flowStatus);
#ifdef ENABLE_MQTT
MQTTPublish(mqttServer_getMainTopic() + "/" + "status", flowStatus, false);
#endif //ENABLE_MQTT
return result;
}