From fd0ac182d26737d0236d18c28fb79d1d6b315242 Mon Sep 17 00:00:00 2001 From: Nicolas Liaudat Date: Sun, 11 Dec 2022 20:35:39 +0100 Subject: [PATCH] ENABLE_INFLUXDB c++ macro definition (#1547) * macro * 2 * 2 * delete jomjol_mqtt from CMakeLists * mqtt macro * final * ENABLE_INFLUXDB c++ macro definition --- code/components/jomjol_controlGPIO/server_GPIO.cpp | 1 + code/components/jomjol_controlGPIO/server_GPIO.h | 3 ++- .../components/jomjol_flowcontroll/ClassFlowControll.cpp | 9 +++++++-- code/components/jomjol_flowcontroll/ClassFlowControll.h | 4 +++- .../components/jomjol_flowcontroll/ClassFlowInfluxDB.cpp | 4 ++++ code/components/jomjol_flowcontroll/ClassFlowInfluxDB.h | 2 ++ code/components/jomjol_influxdb/interface_influxdb.cpp | 3 ++- code/components/jomjol_influxdb/interface_influxdb.h | 2 ++ code/platformio.ini | 4 ++-- 9 files changed, 25 insertions(+), 7 deletions(-) diff --git a/code/components/jomjol_controlGPIO/server_GPIO.cpp b/code/components/jomjol_controlGPIO/server_GPIO.cpp index bfe39961..ba9019f6 100644 --- a/code/components/jomjol_controlGPIO/server_GPIO.cpp +++ b/code/components/jomjol_controlGPIO/server_GPIO.cpp @@ -705,3 +705,4 @@ GpioHandler* gpio_handler_get() { return gpioHandler; } + diff --git a/code/components/jomjol_controlGPIO/server_GPIO.h b/code/components/jomjol_controlGPIO/server_GPIO.h index 7f523721..6f104603 100644 --- a/code/components/jomjol_controlGPIO/server_GPIO.h +++ b/code/components/jomjol_controlGPIO/server_GPIO.h @@ -113,4 +113,5 @@ GpioHandler* gpio_handler_get(); -#endif //SERVER_GPIO_H \ No newline at end of file +#endif //SERVER_GPIO_H + diff --git a/code/components/jomjol_flowcontroll/ClassFlowControll.cpp b/code/components/jomjol_flowcontroll/ClassFlowControll.cpp index 5a7e9d19..ed5459da 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowControll.cpp +++ b/code/components/jomjol_flowcontroll/ClassFlowControll.cpp @@ -56,9 +56,12 @@ std::string ClassFlowControll::doSingleStep(std::string _stepname, std::string _ _classname = "ClassFlowMQTT"; } #endif //ENABLE_MQTT + +#ifdef ENABLE_INFLUXDB if ((_stepname.compare("[InfluxDB]") == 0) || (_stepname.compare(";[InfluxDB]") == 0)){ _classname = "ClassFlowInfluxDB"; } +#endif //ENABLE_INFLUXDB for (int i = 0; i < FlowControll.size(); ++i) if (FlowControll[i]->name().compare(_classname) == 0){ @@ -85,8 +88,10 @@ std::string ClassFlowControll::TranslateAktstatus(std::string _input) if (_input.compare("ClassFlowMQTT") == 0) return ("Sending MQTT"); #endif //ENABLE_MQTT +#ifdef ENABLE_INFLUXDB if (_input.compare("ClassFlowInfluxDB") == 0) return ("Sending InfluxDB"); +#endif //ENABLE_INFLUXDB if (_input.compare("ClassFlowPostProcessing") == 0) return ("Post-Processing"); if (_input.compare("ClassFlowWriteList") == 0) @@ -205,10 +210,10 @@ ClassFlow* ClassFlowControll::CreateClassFlow(std::string _type) if (toUpper(_type).compare("[MQTT]") == 0) cfc = new ClassFlowMQTT(&FlowControll); #endif //ENABLE_MQTT - +#ifdef ENABLE_INFLUXDB if (toUpper(_type).compare("[INFLUXDB]") == 0) cfc = new ClassFlowInfluxDB(&FlowControll); - +#endif //ENABLE_INFLUXDB if (toUpper(_type).compare("[WRITELIST]") == 0) cfc = new ClassFlowWriteList(&FlowControll); diff --git a/code/components/jomjol_flowcontroll/ClassFlowControll.h b/code/components/jomjol_flowcontroll/ClassFlowControll.h index be0177cd..2113c91b 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowControll.h +++ b/code/components/jomjol_flowcontroll/ClassFlowControll.h @@ -13,7 +13,9 @@ #ifdef ENABLE_MQTT #include "ClassFlowMQTT.h" #endif //ENABLE_MQTT -#include "ClassFlowInfluxDB.h" +#ifdef ENABLE_INFLUXDB + #include "ClassFlowInfluxDB.h" +#endif //ENABLE_INFLUXDB #include "ClassFlowCNNGeneral.h" #include "ClassFlowWriteList.h" diff --git a/code/components/jomjol_flowcontroll/ClassFlowInfluxDB.cpp b/code/components/jomjol_flowcontroll/ClassFlowInfluxDB.cpp index 5ced8538..f9406dca 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowInfluxDB.cpp +++ b/code/components/jomjol_flowcontroll/ClassFlowInfluxDB.cpp @@ -1,3 +1,4 @@ +#ifdef ENABLE_INFLUXDB #include #include "ClassFlowInfluxDB.h" #include "Helper.h" @@ -5,6 +6,7 @@ #include "time_sntp.h" #include "interface_influxdb.h" + #include "ClassFlowPostProcessing.h" #include "esp_log.h" @@ -162,3 +164,5 @@ bool ClassFlowInfluxDB::doFlow(string zwtime) return true; } + +#endif //ENABLE_INFLUXDB \ No newline at end of file diff --git a/code/components/jomjol_flowcontroll/ClassFlowInfluxDB.h b/code/components/jomjol_flowcontroll/ClassFlowInfluxDB.h index b7e25362..f1a0c1e5 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowInfluxDB.h +++ b/code/components/jomjol_flowcontroll/ClassFlowInfluxDB.h @@ -1,3 +1,4 @@ +#ifdef ENABLE_INFLUXDB #pragma once #include "ClassFlow.h" @@ -29,3 +30,4 @@ public: string name(){return "ClassFlowInfluxDB";}; }; +#endif //ENABLE_INFLUXDB \ No newline at end of file diff --git a/code/components/jomjol_influxdb/interface_influxdb.cpp b/code/components/jomjol_influxdb/interface_influxdb.cpp index ab20259e..7120f607 100644 --- a/code/components/jomjol_influxdb/interface_influxdb.cpp +++ b/code/components/jomjol_influxdb/interface_influxdb.cpp @@ -1,3 +1,4 @@ +#ifdef ENABLE_INFLUXDB #include "interface_influxdb.h" //#define LOG_LOCAL_LEVEL ESP_LOG_DEBUG @@ -111,4 +112,4 @@ void InfluxDBInit(std::string _uri, std::string _database, std::string _measurem void InfluxDBdestroy() { } - +#endif //ENABLE_INFLUXDB diff --git a/code/components/jomjol_influxdb/interface_influxdb.h b/code/components/jomjol_influxdb/interface_influxdb.h index 33ae0564..581c0ec2 100644 --- a/code/components/jomjol_influxdb/interface_influxdb.h +++ b/code/components/jomjol_influxdb/interface_influxdb.h @@ -1,3 +1,4 @@ +#ifdef ENABLE_INFLUXDB #ifndef INTERFACE_INFLUXDB_H #define INTERFACE_INFLUXDB_H @@ -11,3 +12,4 @@ void InfluxDBdestroy(); void InfluxDBPublish(std::string _key, std::string _content, std::string _timestamp); #endif //INTERFACE_INFLUXDB_H +#endif //ENABLE_INFLUXDB \ No newline at end of file diff --git a/code/platformio.ini b/code/platformio.ini index b0d3ecbf..e91212cf 100644 --- a/code/platformio.ini +++ b/code/platformio.ini @@ -18,8 +18,8 @@ board = esp32cam ;board = m5stack-core-esp32 framework = espidf -;Add macro definition ENABLE_MQTT -build_flags = -D ENABLE_MQTT +;Add macro definition ENABLE_MQTT, ENABLE_INFLUXDB +build_flags = -D ENABLE_MQTT -D ENABLE_INFLUXDB ;board_build.partitions = partitions_singleapp.csv board_build.partitions = partitions.csv