mirror of
https://github.com/jomjol/AI-on-the-edge-device.git
synced 2025-12-07 20:16:55 +03:00
ENABLE_MQTT c++ macro definition (#1546)
* macro * 2 * 2 * delete jomjol_mqtt from CMakeLists * mqtt macro * final
This commit is contained in:
@@ -25,7 +25,9 @@
|
|||||||
#include "ClassLogFile.h"
|
#include "ClassLogFile.h"
|
||||||
#include "configFile.h"
|
#include "configFile.h"
|
||||||
#include "Helper.h"
|
#include "Helper.h"
|
||||||
#include "interface_mqtt.h"
|
#ifdef ENABLE_MQTT
|
||||||
|
#include "interface_mqtt.h"
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
|
|
||||||
static const char *TAG = "GPIO";
|
static const char *TAG = "GPIO";
|
||||||
QueueHandle_t gpio_queue_handle = NULL;
|
QueueHandle_t gpio_queue_handle = NULL;
|
||||||
@@ -83,12 +85,14 @@ static void gpioHandlerTask(void *arg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GpioPin::gpioInterrupt(int value) {
|
void GpioPin::gpioInterrupt(int value) {
|
||||||
|
#ifdef ENABLE_MQTT
|
||||||
if (_mqttTopic != "") {
|
if (_mqttTopic != "") {
|
||||||
ESP_LOGD(TAG, "gpioInterrupt %s %d", _mqttTopic.c_str(), value);
|
ESP_LOGD(TAG, "gpioInterrupt %s %d", _mqttTopic.c_str(), value);
|
||||||
|
|
||||||
MQTTPublish(_mqttTopic, value ? "true" : "false");
|
MQTTPublish(_mqttTopic, value ? "true" : "false");
|
||||||
currentState = value;
|
|
||||||
}
|
}
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
|
currentState = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GpioPin::init()
|
void GpioPin::init()
|
||||||
@@ -114,10 +118,12 @@ void GpioPin::init()
|
|||||||
gpio_isr_handler_add(_gpio, gpio_isr_handler, (void*)&_gpio);
|
gpio_isr_handler_add(_gpio, gpio_isr_handler, (void*)&_gpio);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_MQTT
|
||||||
if ((_mqttTopic != "") && ((_mode == GPIO_PIN_MODE_OUTPUT) || (_mode == GPIO_PIN_MODE_OUTPUT_PWM) || (_mode == GPIO_PIN_MODE_BUILT_IN_FLASH_LED))) {
|
if ((_mqttTopic != "") && ((_mode == GPIO_PIN_MODE_OUTPUT) || (_mode == GPIO_PIN_MODE_OUTPUT_PWM) || (_mode == GPIO_PIN_MODE_BUILT_IN_FLASH_LED))) {
|
||||||
std::function<bool(std::string, char*, int)> f = std::bind(&GpioPin::handleMQTT, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
|
std::function<bool(std::string, char*, int)> f = std::bind(&GpioPin::handleMQTT, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
|
||||||
MQTTregisterSubscribeFunction(_mqttTopic, f);
|
MQTTregisterSubscribeFunction(_mqttTopic, f);
|
||||||
}
|
}
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GpioPin::getValue(std::string* errorText)
|
bool GpioPin::getValue(std::string* errorText)
|
||||||
@@ -138,9 +144,11 @@ void GpioPin::setValue(bool value, gpio_set_source setSource, std::string* error
|
|||||||
} else {
|
} else {
|
||||||
gpio_set_level(_gpio, value);
|
gpio_set_level(_gpio, value);
|
||||||
|
|
||||||
|
#ifdef ENABLE_MQTT
|
||||||
if ((_mqttTopic != "") && (setSource != GPIO_SET_SOURCE_MQTT)) {
|
if ((_mqttTopic != "") && (setSource != GPIO_SET_SOURCE_MQTT)) {
|
||||||
MQTTPublish(_mqttTopic, value ? "true" : "false");
|
MQTTPublish(_mqttTopic, value ? "true" : "false");
|
||||||
}
|
}
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,11 +156,14 @@ void GpioPin::publishState() {
|
|||||||
int newState = gpio_get_level(_gpio);
|
int newState = gpio_get_level(_gpio);
|
||||||
if (newState != currentState) {
|
if (newState != currentState) {
|
||||||
ESP_LOGD(TAG,"publish state of GPIO %d new state %d", _gpio, newState);
|
ESP_LOGD(TAG,"publish state of GPIO %d new state %d", _gpio, newState);
|
||||||
|
#ifdef ENABLE_MQTT
|
||||||
MQTTPublish(_mqttTopic, newState ? "true" : "false");
|
MQTTPublish(_mqttTopic, newState ? "true" : "false");
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
currentState = newState;
|
currentState = newState;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_MQTT
|
||||||
bool GpioPin::handleMQTT(std::string, char* data, int data_len) {
|
bool GpioPin::handleMQTT(std::string, char* data, int data_len) {
|
||||||
ESP_LOGD(TAG, "GpioPin::handleMQTT data %.*s", data_len, data);
|
ESP_LOGD(TAG, "GpioPin::handleMQTT data %.*s", data_len, data);
|
||||||
|
|
||||||
@@ -174,7 +185,7 @@ bool GpioPin::handleMQTT(std::string, char* data, int data_len) {
|
|||||||
|
|
||||||
return (errorText == "");
|
return (errorText == "");
|
||||||
}
|
}
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
|
|
||||||
esp_err_t callHandleHttpRequest(httpd_req_t *req)
|
esp_err_t callHandleHttpRequest(httpd_req_t *req)
|
||||||
{
|
{
|
||||||
@@ -236,8 +247,10 @@ void GpioHandler::init()
|
|||||||
it->second->init();
|
it->second->init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_MQTT
|
||||||
std::function<void()> f = std::bind(&GpioHandler::handleMQTTconnect, this);
|
std::function<void()> f = std::bind(&GpioHandler::handleMQTTconnect, this);
|
||||||
MQTTregisterConnectFunction("gpio-handler", f);
|
MQTTregisterConnectFunction("gpio-handler", f);
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
|
|
||||||
if (xHandleTaskGpio == NULL) {
|
if (xHandleTaskGpio == NULL) {
|
||||||
gpio_queue_handle = xQueueCreate(10,sizeof(GpioResult));
|
gpio_queue_handle = xQueueCreate(10,sizeof(GpioResult));
|
||||||
@@ -261,7 +274,7 @@ void GpioHandler::taskHandler() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_MQTT
|
||||||
void GpioHandler::handleMQTTconnect()
|
void GpioHandler::handleMQTTconnect()
|
||||||
{
|
{
|
||||||
if (gpioMap != NULL) {
|
if (gpioMap != NULL) {
|
||||||
@@ -271,9 +284,12 @@ void GpioHandler::handleMQTTconnect()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
|
|
||||||
void GpioHandler::deinit() {
|
void GpioHandler::deinit() {
|
||||||
|
#ifdef ENABLE_MQTT
|
||||||
MQTTunregisterConnectFunction("gpio-handler");
|
MQTTunregisterConnectFunction("gpio-handler");
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
clear();
|
clear();
|
||||||
if (xHandleTaskGpio != NULL) {
|
if (xHandleTaskGpio != NULL) {
|
||||||
vTaskDelete(xHandleTaskGpio);
|
vTaskDelete(xHandleTaskGpio);
|
||||||
@@ -316,6 +332,7 @@ bool GpioHandler::readConfig()
|
|||||||
|
|
||||||
// ESP_LOGD(TAG, "readConfig - Start 3");
|
// ESP_LOGD(TAG, "readConfig - Start 3");
|
||||||
|
|
||||||
|
#ifdef ENABLE_MQTT
|
||||||
// std::string mainTopicMQTT = "";
|
// std::string mainTopicMQTT = "";
|
||||||
std::string mainTopicMQTT = GetMQTTMainTopic();
|
std::string mainTopicMQTT = GetMQTTMainTopic();
|
||||||
if (mainTopicMQTT.length() > 0)
|
if (mainTopicMQTT.length() > 0)
|
||||||
@@ -323,7 +340,7 @@ bool GpioHandler::readConfig()
|
|||||||
mainTopicMQTT = mainTopicMQTT + "/GPIO";
|
mainTopicMQTT = mainTopicMQTT + "/GPIO";
|
||||||
ESP_LOGD(TAG, "MAINTOPICMQTT found");
|
ESP_LOGD(TAG, "MAINTOPICMQTT found");
|
||||||
}
|
}
|
||||||
|
#endif // ENABLE_MQTT
|
||||||
bool registerISR = false;
|
bool registerISR = false;
|
||||||
while (configFile.getNextLine(&line, disabledLine, eof) && !configFile.isNewParagraph(line))
|
while (configFile.getNextLine(&line, disabledLine, eof) && !configFile.isNewParagraph(line))
|
||||||
{
|
{
|
||||||
@@ -345,7 +362,9 @@ bool GpioHandler::readConfig()
|
|||||||
gpio_pin_mode_t pinMode = resolvePinMode(toLower(zerlegt[1]));
|
gpio_pin_mode_t pinMode = resolvePinMode(toLower(zerlegt[1]));
|
||||||
gpio_int_type_t intType = resolveIntType(toLower(zerlegt[2]));
|
gpio_int_type_t intType = resolveIntType(toLower(zerlegt[2]));
|
||||||
uint16_t dutyResolution = (uint8_t)atoi(zerlegt[3].c_str());
|
uint16_t dutyResolution = (uint8_t)atoi(zerlegt[3].c_str());
|
||||||
|
#ifdef ENABLE_MQTT
|
||||||
bool mqttEnabled = toLower(zerlegt[4]) == "true";
|
bool mqttEnabled = toLower(zerlegt[4]) == "true";
|
||||||
|
#endif // ENABLE_MQTT
|
||||||
bool httpEnabled = toLower(zerlegt[5]) == "true";
|
bool httpEnabled = toLower(zerlegt[5]) == "true";
|
||||||
char gpioName[100];
|
char gpioName[100];
|
||||||
if (zerlegt.size() >= 7) {
|
if (zerlegt.size() >= 7) {
|
||||||
@@ -353,7 +372,11 @@ bool GpioHandler::readConfig()
|
|||||||
} else {
|
} else {
|
||||||
sprintf(gpioName, "GPIO%d", gpioNr);
|
sprintf(gpioName, "GPIO%d", gpioNr);
|
||||||
}
|
}
|
||||||
|
#ifdef ENABLE_MQTT
|
||||||
std::string mqttTopic = mqttEnabled ? (mainTopicMQTT + "/" + gpioName) : "";
|
std::string mqttTopic = mqttEnabled ? (mainTopicMQTT + "/" + gpioName) : "";
|
||||||
|
#else // ENABLE_MQTT
|
||||||
|
std::string mqttTopic = "";
|
||||||
|
#endif // ENABLE_MQTT
|
||||||
GpioPin* gpioPin = new GpioPin(gpioNr, gpioName, pinMode, intType,dutyResolution, mqttTopic, httpEnabled);
|
GpioPin* gpioPin = new GpioPin(gpioNr, gpioName, pinMode, intType,dutyResolution, mqttTopic, httpEnabled);
|
||||||
(*gpioMap)[gpioNr] = gpioPin;
|
(*gpioMap)[gpioNr] = gpioPin;
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,9 @@ public:
|
|||||||
void init();
|
void init();
|
||||||
bool getValue(std::string* errorText);
|
bool getValue(std::string* errorText);
|
||||||
void setValue(bool value, gpio_set_source setSource, std::string* errorText);
|
void setValue(bool value, gpio_set_source setSource, std::string* errorText);
|
||||||
|
#ifdef ENABLE_MQTT
|
||||||
bool handleMQTT(std::string, char* data, int data_len);
|
bool handleMQTT(std::string, char* data, int data_len);
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
void publishState();
|
void publishState();
|
||||||
void gpioInterrupt(int value);
|
void gpioInterrupt(int value);
|
||||||
gpio_int_type_t getInterruptType() { return _interruptType; }
|
gpio_int_type_t getInterruptType() { return _interruptType; }
|
||||||
@@ -77,7 +79,9 @@ public:
|
|||||||
void gpioInterrupt(GpioResult* gpioResult);
|
void gpioInterrupt(GpioResult* gpioResult);
|
||||||
void flashLightEnable(bool value);
|
void flashLightEnable(bool value);
|
||||||
bool isEnabled() { return _isEnabled; }
|
bool isEnabled() { return _isEnabled; }
|
||||||
|
#ifdef ENABLE_MQTT
|
||||||
void handleMQTTconnect();
|
void handleMQTTconnect();
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string _configFile;
|
std::string _configFile;
|
||||||
|
|||||||
@@ -39,7 +39,9 @@ extern "C" {
|
|||||||
#include "server_tflite.h"
|
#include "server_tflite.h"
|
||||||
|
|
||||||
#include "server_help.h"
|
#include "server_help.h"
|
||||||
#include "interface_mqtt.h"
|
#ifdef ENABLE_MQTT
|
||||||
|
#include "interface_mqtt.h"
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
#include "server_GPIO.h"
|
#include "server_GPIO.h"
|
||||||
|
|
||||||
#include "Helper.h"
|
#include "Helper.h"
|
||||||
|
|||||||
@@ -19,9 +19,10 @@ extern "C" {
|
|||||||
#include "time_sntp.h"
|
#include "time_sntp.h"
|
||||||
#include "Helper.h"
|
#include "Helper.h"
|
||||||
#include "server_ota.h"
|
#include "server_ota.h"
|
||||||
#include "interface_mqtt.h"
|
#ifdef ENABLE_MQTT
|
||||||
#include "server_mqtt.h"
|
#include "interface_mqtt.h"
|
||||||
|
#include "server_mqtt.h"
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
|
|
||||||
//#include "CImg.h"
|
//#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)){
|
if ((_stepname.compare("[Analog]") == 0) || (_stepname.compare(";[Analog]") == 0)){
|
||||||
_classname = "ClassFlowCNNGeneral";
|
_classname = "ClassFlowCNNGeneral";
|
||||||
}
|
}
|
||||||
|
#ifdef ENABLE_MQTT
|
||||||
if ((_stepname.compare("[MQTT]") == 0) || (_stepname.compare(";[MQTT]") == 0)){
|
if ((_stepname.compare("[MQTT]") == 0) || (_stepname.compare(";[MQTT]") == 0)){
|
||||||
_classname = "ClassFlowMQTT";
|
_classname = "ClassFlowMQTT";
|
||||||
}
|
}
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
if ((_stepname.compare("[InfluxDB]") == 0) || (_stepname.compare(";[InfluxDB]") == 0)){
|
if ((_stepname.compare("[InfluxDB]") == 0) || (_stepname.compare(";[InfluxDB]") == 0)){
|
||||||
_classname = "ClassFlowInfluxDB";
|
_classname = "ClassFlowInfluxDB";
|
||||||
}
|
}
|
||||||
@@ -78,8 +81,10 @@ std::string ClassFlowControll::TranslateAktstatus(std::string _input)
|
|||||||
return ("Aligning");
|
return ("Aligning");
|
||||||
if (_input.compare("ClassFlowCNNGeneral") == 0)
|
if (_input.compare("ClassFlowCNNGeneral") == 0)
|
||||||
return ("Digitalization of ROIs");
|
return ("Digitalization of ROIs");
|
||||||
|
#ifdef ENABLE_MQTT
|
||||||
if (_input.compare("ClassFlowMQTT") == 0)
|
if (_input.compare("ClassFlowMQTT") == 0)
|
||||||
return ("Sending MQTT");
|
return ("Sending MQTT");
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
if (_input.compare("ClassFlowInfluxDB") == 0)
|
if (_input.compare("ClassFlowInfluxDB") == 0)
|
||||||
return ("Sending InfluxDB");
|
return ("Sending InfluxDB");
|
||||||
if (_input.compare("ClassFlowPostProcessing") == 0)
|
if (_input.compare("ClassFlowPostProcessing") == 0)
|
||||||
@@ -130,7 +135,7 @@ t_CNNType ClassFlowControll::GetTypeAnalog()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef ENABLE_MQTT
|
||||||
string ClassFlowControll::GetMQTTMainTopic()
|
string ClassFlowControll::GetMQTTMainTopic()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < FlowControll.size(); ++i)
|
for (int i = 0; i < FlowControll.size(); ++i)
|
||||||
@@ -149,7 +154,7 @@ bool ClassFlowControll::StartMQTTService() {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
|
|
||||||
void ClassFlowControll::SetInitialParameter(void)
|
void ClassFlowControll::SetInitialParameter(void)
|
||||||
{
|
{
|
||||||
@@ -196,8 +201,10 @@ ClassFlow* ClassFlowControll::CreateClassFlow(std::string _type)
|
|||||||
cfc = new ClassFlowCNNGeneral(flowalignment);
|
cfc = new ClassFlowCNNGeneral(flowalignment);
|
||||||
flowdigit = (ClassFlowCNNGeneral*) cfc;
|
flowdigit = (ClassFlowCNNGeneral*) cfc;
|
||||||
}
|
}
|
||||||
|
#ifdef ENABLE_MQTT
|
||||||
if (toUpper(_type).compare("[MQTT]") == 0)
|
if (toUpper(_type).compare("[MQTT]") == 0)
|
||||||
cfc = new ClassFlowMQTT(&FlowControll);
|
cfc = new ClassFlowMQTT(&FlowControll);
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
|
|
||||||
if (toUpper(_type).compare("[INFLUXDB]") == 0)
|
if (toUpper(_type).compare("[INFLUXDB]") == 0)
|
||||||
cfc = new ClassFlowInfluxDB(&FlowControll);
|
cfc = new ClassFlowInfluxDB(&FlowControll);
|
||||||
@@ -287,8 +294,9 @@ void ClassFlowControll::doFlowMakeImageOnly(string time){
|
|||||||
zw_time = gettimestring("%H:%M:%S");
|
zw_time = gettimestring("%H:%M:%S");
|
||||||
std::string flowStatus = TranslateAktstatus(FlowControll[i]->name());
|
std::string flowStatus = TranslateAktstatus(FlowControll[i]->name());
|
||||||
aktstatus = flowStatus + " (" + zw_time + ")";
|
aktstatus = flowStatus + " (" + zw_time + ")";
|
||||||
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, flowStatus);
|
#ifdef ENABLE_MQTT
|
||||||
MQTTPublish(mqttServer_getMainTopic() + "/" + "status", flowStatus, false);
|
MQTTPublish(mqttServer_getMainTopic() + "/" + "status", flowStatus, false);
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
|
|
||||||
FlowControll[i]->doFlow(time);
|
FlowControll[i]->doFlow(time);
|
||||||
}
|
}
|
||||||
@@ -318,8 +326,9 @@ bool ClassFlowControll::doFlow(string time)
|
|||||||
zw_time = gettimestring("%H:%M:%S");
|
zw_time = gettimestring("%H:%M:%S");
|
||||||
std::string flowStatus = TranslateAktstatus(FlowControll[i]->name());
|
std::string flowStatus = TranslateAktstatus(FlowControll[i]->name());
|
||||||
aktstatus = flowStatus + " (" + zw_time + ")";
|
aktstatus = flowStatus + " (" + zw_time + ")";
|
||||||
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, flowStatus);
|
#ifdef ENABLE_MQTT
|
||||||
MQTTPublish(mqttServer_getMainTopic() + "/" + "status", flowStatus, false);
|
MQTTPublish(mqttServer_getMainTopic() + "/" + "status", flowStatus, false);
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
|
|
||||||
string zw = "FlowControll.doFlow - " + FlowControll[i]->name();
|
string zw = "FlowControll.doFlow - " + FlowControll[i]->name();
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
@@ -350,8 +359,9 @@ bool ClassFlowControll::doFlow(string time)
|
|||||||
zw_time = gettimestring("%H:%M:%S");
|
zw_time = gettimestring("%H:%M:%S");
|
||||||
std::string flowStatus = "Flow finished";
|
std::string flowStatus = "Flow finished";
|
||||||
aktstatus = flowStatus + " (" + zw_time + ")";
|
aktstatus = flowStatus + " (" + zw_time + ")";
|
||||||
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, flowStatus);
|
#ifdef ENABLE_MQTT
|
||||||
MQTTPublish(mqttServer_getMainTopic() + "/" + "status", flowStatus, false);
|
MQTTPublish(mqttServer_getMainTopic() + "/" + "status", flowStatus, false);
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
|
||||||
|
|
||||||
#ifndef __FLOWCONTROLL__
|
#ifndef __FLOWCONTROLL__
|
||||||
#define __FLOWCONTROLL__
|
#define __FLOWCONTROLL__
|
||||||
|
|
||||||
@@ -8,7 +10,9 @@
|
|||||||
#include "ClassFlowAlignment.h"
|
#include "ClassFlowAlignment.h"
|
||||||
#include "ClassFlowCNNGeneral.h"
|
#include "ClassFlowCNNGeneral.h"
|
||||||
#include "ClassFlowPostProcessing.h"
|
#include "ClassFlowPostProcessing.h"
|
||||||
#include "ClassFlowMQTT.h"
|
#ifdef ENABLE_MQTT
|
||||||
|
#include "ClassFlowMQTT.h"
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
#include "ClassFlowInfluxDB.h"
|
#include "ClassFlowInfluxDB.h"
|
||||||
#include "ClassFlowCNNGeneral.h"
|
#include "ClassFlowCNNGeneral.h"
|
||||||
#include "ClassFlowWriteList.h"
|
#include "ClassFlowWriteList.h"
|
||||||
@@ -54,8 +58,9 @@ public:
|
|||||||
string getNumbersName();
|
string getNumbersName();
|
||||||
|
|
||||||
string TranslateAktstatus(std::string _input);
|
string TranslateAktstatus(std::string _input);
|
||||||
|
#ifdef ENABLE_MQTT
|
||||||
string GetMQTTMainTopic();
|
string GetMQTTMainTopic();
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
|
|
||||||
esp_err_t GetJPGStream(std::string _fn, httpd_req_t *req);
|
esp_err_t GetJPGStream(std::string _fn, httpd_req_t *req);
|
||||||
esp_err_t SendRawJPG(httpd_req_t *req);
|
esp_err_t SendRawJPG(httpd_req_t *req);
|
||||||
@@ -71,7 +76,9 @@ public:
|
|||||||
|
|
||||||
t_CNNType GetTypeDigital();
|
t_CNNType GetTypeDigital();
|
||||||
t_CNNType GetTypeAnalog();
|
t_CNNType GetTypeAnalog();
|
||||||
|
#ifdef ENABLE_MQTT
|
||||||
bool StartMQTTService();
|
bool StartMQTTService();
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
|
|
||||||
int CleanTempFolder();
|
int CleanTempFolder();
|
||||||
|
|
||||||
@@ -81,3 +88,4 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
#ifdef ENABLE_MQTT
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include "ClassFlowMQTT.h"
|
#include "ClassFlowMQTT.h"
|
||||||
@@ -314,3 +316,6 @@ bool ClassFlowMQTT::doFlow(string zwtime)
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#ifdef ENABLE_MQTT
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "ClassFlow.h"
|
#include "ClassFlow.h"
|
||||||
|
|
||||||
@@ -33,3 +34,4 @@ public:
|
|||||||
string name(){return "ClassFlowMQTT";};
|
string name(){return "ClassFlowMQTT";};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#ifdef ENABLE_MQTT
|
||||||
#include "interface_mqtt.h"
|
#include "interface_mqtt.h"
|
||||||
|
|
||||||
//#define LOG_LOCAL_LEVEL ESP_LOG_DEBUG
|
//#define LOG_LOCAL_LEVEL ESP_LOG_DEBUG
|
||||||
@@ -346,3 +347,4 @@ void MQTTdestroySubscribeFunction(){
|
|||||||
subscribeFunktionMap = NULL;
|
subscribeFunktionMap = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#ifdef ENABLE_MQTT
|
||||||
#ifndef INTERFACE_MQTT_H
|
#ifndef INTERFACE_MQTT_H
|
||||||
#define INTERFACE_MQTT_H
|
#define INTERFACE_MQTT_H
|
||||||
|
|
||||||
@@ -22,5 +23,5 @@ void MQTTdestroySubscribeFunction();
|
|||||||
void MQTTconnected();
|
void MQTTconnected();
|
||||||
|
|
||||||
void MQTTdisable();
|
void MQTTdisable();
|
||||||
|
#endif //INTERFACE_MQTT_H
|
||||||
#endif //INTERFACE_MQTT_H
|
#endif //#ENABLE_MQTT
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#ifdef ENABLE_MQTT
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
@@ -243,3 +244,5 @@ void mqttServer_setMainTopic( std::string _maintopic) {
|
|||||||
std::string mqttServer_getMainTopic() {
|
std::string mqttServer_getMainTopic() {
|
||||||
return maintopic;
|
return maintopic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
#ifdef ENABLE_MQTT
|
||||||
|
|
||||||
#include "ClassFlowDefineTypes.h"
|
#include "ClassFlowDefineTypes.h"
|
||||||
|
|
||||||
#define LWT_TOPIC "connection"
|
#define LWT_TOPIC "connection"
|
||||||
@@ -17,4 +19,6 @@ void register_server_mqtt_uri(httpd_handle_t server);
|
|||||||
void publishSystemData();
|
void publishSystemData();
|
||||||
|
|
||||||
std::string getTimeUnit(void);
|
std::string getTimeUnit(void);
|
||||||
void GotConnected(std::string maintopic, int SetRetainFlag);
|
void GotConnected(std::string maintopic, int SetRetainFlag);
|
||||||
|
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
@@ -104,7 +104,9 @@ void doInit(void)
|
|||||||
ESP_LOGD(TAG, "Finished tfliteflow.InitFlow(config);");
|
ESP_LOGD(TAG, "Finished tfliteflow.InitFlow(config);");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef ENABLE_MQTT
|
||||||
tfliteflow.StartMQTTService();
|
tfliteflow.StartMQTTService();
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -803,11 +805,12 @@ void TFliteDoAutoStart()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_MQTT
|
||||||
std::string GetMQTTMainTopic()
|
std::string GetMQTTMainTopic()
|
||||||
{
|
{
|
||||||
return tfliteflow.GetMQTTMainTopic();
|
return tfliteflow.GetMQTTMainTopic();
|
||||||
}
|
}
|
||||||
|
#endif//ENABLE_MQTT
|
||||||
|
|
||||||
|
|
||||||
void register_server_tflite_uri(httpd_handle_t server)
|
void register_server_tflite_uri(httpd_handle_t server)
|
||||||
|
|||||||
@@ -15,7 +15,9 @@ void TFliteDoAutoStart();
|
|||||||
|
|
||||||
bool isSetupModusActive();
|
bool isSetupModusActive();
|
||||||
|
|
||||||
|
#ifdef ENABLE_MQTT
|
||||||
std::string GetMQTTMainTopic();
|
std::string GetMQTTMainTopic();
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
|
|
||||||
int getCountFlowRounds();
|
int getCountFlowRounds();
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,9 @@
|
|||||||
#include "ClassControllCamera.h"
|
#include "ClassControllCamera.h"
|
||||||
#include "server_main.h"
|
#include "server_main.h"
|
||||||
#include "server_camera.h"
|
#include "server_camera.h"
|
||||||
#include "server_mqtt.h"
|
#ifdef ENABLE_MQTT
|
||||||
|
#include "server_mqtt.h"
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
#include "Helper.h"
|
#include "Helper.h"
|
||||||
|
|
||||||
extern const char* GIT_TAG;
|
extern const char* GIT_TAG;
|
||||||
@@ -280,7 +282,9 @@ extern "C" void app_main(void)
|
|||||||
register_server_tflite_uri(server);
|
register_server_tflite_uri(server);
|
||||||
register_server_file_uri(server, "/sdcard");
|
register_server_file_uri(server, "/sdcard");
|
||||||
register_server_ota_sdcard_uri(server);
|
register_server_ota_sdcard_uri(server);
|
||||||
register_server_mqtt_uri(server);
|
#ifdef ENABLE_MQTT
|
||||||
|
register_server_mqtt_uri(server);
|
||||||
|
#endif //ENABLE_MQTT
|
||||||
|
|
||||||
gpio_handler_create(server);
|
gpio_handler_create(server);
|
||||||
|
|
||||||
|
|||||||
@@ -18,24 +18,28 @@ board = esp32cam
|
|||||||
;board = m5stack-core-esp32
|
;board = m5stack-core-esp32
|
||||||
framework = espidf
|
framework = espidf
|
||||||
|
|
||||||
|
;Add macro definition ENABLE_MQTT
|
||||||
|
build_flags = -D ENABLE_MQTT
|
||||||
|
|
||||||
;board_build.partitions = partitions_singleapp.csv
|
;board_build.partitions = partitions_singleapp.csv
|
||||||
board_build.partitions = partitions.csv
|
board_build.partitions = partitions.csv
|
||||||
|
|
||||||
lib_deps =
|
;lib_deps not needed
|
||||||
jomjol_configfile
|
;lib_deps =
|
||||||
jomjol_helper
|
; jomjol_configfile
|
||||||
jomjol_wlan
|
; jomjol_helper
|
||||||
jomjol_image_proc
|
; jomjol_wlan
|
||||||
jomjol_controlcamera
|
; jomjol_image_proc
|
||||||
jomjol_flowcontroll
|
; jomjol_controlcamera
|
||||||
jomjol_tfliteclass
|
; jomjol_flowcontroll
|
||||||
tflite-lib
|
; jomjol_tfliteclass
|
||||||
jomjol_fileserver_ota
|
; tflite-lib
|
||||||
jomjol_time_sntp
|
; jomjol_fileserver_ota
|
||||||
jomjol_logfile
|
; jomjol_time_sntp
|
||||||
jomjol_mqtt
|
; jomjol_logfile
|
||||||
jomjol_influxdb
|
; jomjol_mqtt
|
||||||
jomjol_controlGPIO
|
; jomjol_influxdb
|
||||||
|
; jomjol_controlGPIO
|
||||||
|
|
||||||
|
|
||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
|
|||||||
Reference in New Issue
Block a user