From e995d6c498093fc3df523a07a06d3e1560acaaa4 Mon Sep 17 00:00:00 2001 From: Slider0007 <115730895+Slider0007@users.noreply.github.com> Date: Thu, 30 Mar 2023 21:56:45 +0200 Subject: [PATCH] Renaming & cleanup of some modules / functions in source code (#2265) * Rename module tag name * Rename server_tflite.cpp -> MainFlowControl.cpp * Remove redundandant MQTTMainTopic function * Update * Remove obsolete GetMQTTMainTopic --- .../jomjol_controlGPIO/server_GPIO.cpp | 8 +- .../ClassControllCamera.cpp | 2 +- .../jomjol_fileserver_ota/server_file.cpp | 4 +- .../jomjol_fileserver_ota/server_ota.cpp | 12 +-- .../ClassFlowAlignment.cpp | 6 +- .../jomjol_flowcontroll/ClassFlowControll.cpp | 14 +--- .../jomjol_flowcontroll/ClassFlowControll.h | 4 - .../jomjol_flowcontroll/ClassFlowImage.cpp | 3 +- .../jomjol_flowcontroll/ClassFlowInfluxDB.cpp | 2 +- .../ClassFlowInfluxDBv2.cpp | 2 +- .../jomjol_flowcontroll/ClassFlowMQTT.cpp | 6 -- .../jomjol_flowcontroll/ClassFlowMQTT.h | 1 - .../ClassFlowTakeImage.cpp | 2 +- .../MainFlowControl.cpp} | 84 +++++++++---------- .../MainFlowControl.h} | 28 +++---- .../components/jomjol_mqtt/interface_mqtt.cpp | 4 +- .../jomjol_tfliteclass/CMakeLists.txt | 2 +- code/main/main.cpp | 8 +- code/main/server_main.cpp | 2 +- 19 files changed, 84 insertions(+), 110 deletions(-) rename code/components/{jomjol_tfliteclass/server_tflite.cpp => jomjol_flowcontroll/MainFlowControl.cpp} (94%) rename code/components/{jomjol_tfliteclass/server_tflite.h => jomjol_flowcontroll/MainFlowControl.h} (55%) diff --git a/code/components/jomjol_controlGPIO/server_GPIO.cpp b/code/components/jomjol_controlGPIO/server_GPIO.cpp index 16d4d46c..64a8e17c 100644 --- a/code/components/jomjol_controlGPIO/server_GPIO.cpp +++ b/code/components/jomjol_controlGPIO/server_GPIO.cpp @@ -8,8 +8,6 @@ #include "esp_system.h" #include "esp_event.h" -#include "server_tflite.h" - #include "esp_log.h" #include @@ -22,8 +20,10 @@ #include "ClassLogFile.h" #include "configFile.h" #include "Helper.h" + #ifdef ENABLE_MQTT - #include "interface_mqtt.h" +#include "interface_mqtt.h" +#include "server_mqtt.h" #endif //ENABLE_MQTT @@ -331,7 +331,7 @@ bool GpioHandler::readConfig() #ifdef ENABLE_MQTT // std::string mainTopicMQTT = ""; - std::string mainTopicMQTT = GetMQTTMainTopic(); + std::string mainTopicMQTT = mqttServer_getMainTopic(); if (mainTopicMQTT.length() > 0) { mainTopicMQTT = mainTopicMQTT + "/GPIO"; diff --git a/code/components/jomjol_controlcamera/ClassControllCamera.cpp b/code/components/jomjol_controlcamera/ClassControllCamera.cpp index 8058fbf0..2ca43fda 100644 --- a/code/components/jomjol_controlcamera/ClassControllCamera.cpp +++ b/code/components/jomjol_controlcamera/ClassControllCamera.cpp @@ -28,7 +28,7 @@ #include "esp_camera.h" #include "driver/ledc.h" -#include "server_tflite.h" +#include "MainFlowControl.h" static const char *TAG = "CAM"; diff --git a/code/components/jomjol_fileserver_ota/server_file.cpp b/code/components/jomjol_fileserver_ota/server_file.cpp index 07a2c7c0..86d34df1 100644 --- a/code/components/jomjol_fileserver_ota/server_file.cpp +++ b/code/components/jomjol_fileserver_ota/server_file.cpp @@ -36,7 +36,7 @@ extern "C" { #include "../../include/defines.h" #include "ClassLogFile.h" -#include "server_tflite.h" +#include "MainFlowControl.h" #include "server_help.h" #ifdef ENABLE_MQTT @@ -74,7 +74,7 @@ static esp_err_t send_datafile(httpd_req_t *req, bool send_full_file); esp_err_t get_numbers_file_handler(httpd_req_t *req) { - std::string ret = tfliteflow.getNumbersName(); + std::string ret = flowctrl.getNumbersName(); // ESP_LOGI(TAG, "Result get_numbers_file_handler: %s", ret.c_str()); diff --git a/code/components/jomjol_fileserver_ota/server_ota.cpp b/code/components/jomjol_fileserver_ota/server_ota.cpp index 6763090d..ebab26ff 100644 --- a/code/components/jomjol_fileserver_ota/server_ota.cpp +++ b/code/components/jomjol_fileserver_ota/server_ota.cpp @@ -26,7 +26,7 @@ #include -#include "server_tflite.h" +#include "MainFlowControl.h" #include "server_file.h" #include "server_GPIO.h" #ifdef ENABLE_MQTT @@ -467,7 +467,7 @@ esp_err_t handler_ota_update(httpd_req_t *req) { const char* resp_str; - KillTFliteTasks(); + DeleteMainFlowTask(); gpio_handler_deinit(); if (ota_update_task(fn)) { @@ -546,7 +546,7 @@ esp_err_t handler_ota_update(httpd_req_t *req) /* const char* resp_str; - KillTFliteTasks(); + DeleteMainFlowTask(); gpio_handler_deinit(); if (ota_update_task(fn)) { @@ -576,7 +576,7 @@ void hard_restart() } -void task_reboot(void *KillAutoFlow) +void task_reboot(void *DeleteMainFlow) { // write a reboot, to identify a reboot by purpouse FILE* pfile = fopen("/sdcard/reboot.txt", "w"); @@ -586,8 +586,8 @@ void task_reboot(void *KillAutoFlow) vTaskDelay(3000 / portTICK_PERIOD_MS); - if ((bool)KillAutoFlow) { - KillTFliteTasks(); // Kill autoflow task if executed in extra task, if not don't kill parent task + if ((bool)DeleteMainFlow) { + DeleteMainFlowTask(); // Kill autoflow task if executed in extra task, if not don't kill parent task } Camera.LightOnOff(false); diff --git a/code/components/jomjol_flowcontroll/ClassFlowAlignment.cpp b/code/components/jomjol_flowcontroll/ClassFlowAlignment.cpp index a8ffcfbc..ef7af016 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowAlignment.cpp +++ b/code/components/jomjol_flowcontroll/ClassFlowAlignment.cpp @@ -1,7 +1,7 @@ #include "ClassFlowAlignment.h" #include "ClassFlowTakeImage.h" #include "ClassFlow.h" -#include "server_tflite.h" +#include "MainFlowControl.h" #include "CRotateImage.h" #include "esp_log.h" @@ -256,8 +256,8 @@ bool ClassFlowAlignment::doFlow(string time) if(References[0].alignment_algo != 3){ DrawRef(ImageTMP); } - tfliteflow.DigitalDrawROI(ImageTMP); - tfliteflow.AnalogDrawROI(ImageTMP); + flowctrl.DigitalDrawROI(ImageTMP); + flowctrl.AnalogDrawROI(ImageTMP); ImageTMP->writeToMemoryAsJPG((ImageData*)AlgROI, 90); } #endif diff --git a/code/components/jomjol_flowcontroll/ClassFlowControll.cpp b/code/components/jomjol_flowcontroll/ClassFlowControll.cpp index 42eaae70..f0d75c58 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowControll.cpp +++ b/code/components/jomjol_flowcontroll/ClassFlowControll.cpp @@ -25,10 +25,10 @@ extern "C" { #endif //ENABLE_MQTT #include "server_help.h" -#include "server_tflite.h" +#include "MainFlowControl.h" #include "../../include/defines.h" -static const char* TAG = "CTRL"; +static const char* TAG = "FLOWCTRL"; //#define DEBUG_DETAIL_ON @@ -162,16 +162,8 @@ void ClassFlowControll::AnalogDrawROI(CImageBasis *_zw) #ifdef ENABLE_MQTT -string ClassFlowControll::GetMQTTMainTopic() +bool ClassFlowControll::StartMQTTService() { - for (int i = 0; i < FlowControll.size(); ++i) - if (FlowControll[i]->name().compare("ClassFlowMQTT") == 0) - return ((ClassFlowMQTT*) (FlowControll[i]))->GetMQTTMainTopic(); - - return ""; -} - -bool ClassFlowControll::StartMQTTService() { /* Start the MQTT service */ for (int i = 0; i < FlowControll.size(); ++i) { if (FlowControll[i]->name().compare("ClassFlowMQTT") == 0) { diff --git a/code/components/jomjol_flowcontroll/ClassFlowControll.h b/code/components/jomjol_flowcontroll/ClassFlowControll.h index cb6dfda1..48a72fcc 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowControll.h +++ b/code/components/jomjol_flowcontroll/ClassFlowControll.h @@ -55,10 +55,6 @@ public: string TranslateAktstatus(std::string _input); - #ifdef ENABLE_MQTT - string GetMQTTMainTopic(); - #endif //ENABLE_MQTT - #ifdef ALGROI_LOAD_FROM_MEM_AS_JPG void DigitalDrawROI(CImageBasis *_zw); void AnalogDrawROI(CImageBasis *_zw); diff --git a/code/components/jomjol_flowcontroll/ClassFlowImage.cpp b/code/components/jomjol_flowcontroll/ClassFlowImage.cpp index 29a3f6b2..79a32190 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowImage.cpp +++ b/code/components/jomjol_flowcontroll/ClassFlowImage.cpp @@ -17,7 +17,8 @@ extern "C" { #include "esp_log.h" #include "../../include/defines.h" -static const char* TAG = "IMG"; +static const char* TAG = "FLOWIMAGE"; + ClassFlowImage::ClassFlowImage(const char* logTag) { diff --git a/code/components/jomjol_flowcontroll/ClassFlowInfluxDB.cpp b/code/components/jomjol_flowcontroll/ClassFlowInfluxDB.cpp index 114d7e28..dd331eed 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowInfluxDB.cpp +++ b/code/components/jomjol_flowcontroll/ClassFlowInfluxDB.cpp @@ -15,7 +15,7 @@ #include -static const char* TAG = "class_flow_influxDb"; +static const char* TAG = "INFLUXDB"; void ClassFlowInfluxDB::SetInitialParameter(void) { diff --git a/code/components/jomjol_flowcontroll/ClassFlowInfluxDBv2.cpp b/code/components/jomjol_flowcontroll/ClassFlowInfluxDBv2.cpp index d88ec25b..0df9e29b 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowInfluxDBv2.cpp +++ b/code/components/jomjol_flowcontroll/ClassFlowInfluxDBv2.cpp @@ -15,7 +15,7 @@ #include -static const char* TAG = "class_flow_influxDbv2"; +static const char* TAG = "INFLUXDBV2"; void ClassFlowInfluxDBv2::SetInitialParameter(void) { diff --git a/code/components/jomjol_flowcontroll/ClassFlowMQTT.cpp b/code/components/jomjol_flowcontroll/ClassFlowMQTT.cpp index 00df4811..cb5147a2 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowMQTT.cpp +++ b/code/components/jomjol_flowcontroll/ClassFlowMQTT.cpp @@ -183,12 +183,6 @@ bool ClassFlowMQTT::ReadParameter(FILE* pfile, string& aktparamgraph) } -string ClassFlowMQTT::GetMQTTMainTopic() -{ - return maintopic; -} - - bool ClassFlowMQTT::Start(float AutoInterval) { roundInterval = AutoInterval; // Minutes diff --git a/code/components/jomjol_flowcontroll/ClassFlowMQTT.h b/code/components/jomjol_flowcontroll/ClassFlowMQTT.h index 3bf92499..55b5ae16 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowMQTT.h +++ b/code/components/jomjol_flowcontroll/ClassFlowMQTT.h @@ -31,7 +31,6 @@ public: ClassFlowMQTT(std::vector* lfc); ClassFlowMQTT(std::vector* lfc, ClassFlow *_prev); - string GetMQTTMainTopic(); bool Start(float AutoInterval); bool ReadParameter(FILE* pfile, string& aktparamgraph); diff --git a/code/components/jomjol_flowcontroll/ClassFlowTakeImage.cpp b/code/components/jomjol_flowcontroll/ClassFlowTakeImage.cpp index bb8584af..5e0b2d5a 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowTakeImage.cpp +++ b/code/components/jomjol_flowcontroll/ClassFlowTakeImage.cpp @@ -15,7 +15,7 @@ // #define WIFITURNOFF -static const char* TAG = "flow_make_image"; +static const char* TAG = "TAKEIMAGE"; esp_err_t ClassFlowTakeImage::camera_capture(){ string nm = namerawimage; diff --git a/code/components/jomjol_tfliteclass/server_tflite.cpp b/code/components/jomjol_flowcontroll/MainFlowControl.cpp similarity index 94% rename from code/components/jomjol_tfliteclass/server_tflite.cpp rename to code/components/jomjol_flowcontroll/MainFlowControl.cpp index 2a71840c..7cef99b2 100644 --- a/code/components/jomjol_tfliteclass/server_tflite.cpp +++ b/code/components/jomjol_flowcontroll/MainFlowControl.cpp @@ -1,4 +1,4 @@ -#include "server_tflite.h" +#include "MainFlowControl.h" #include #include @@ -28,7 +28,7 @@ #include "psram.h" -ClassFlowControll tfliteflow; +ClassFlowControll flowctrl; TaskHandle_t xHandletask_autodoFlow = NULL; @@ -41,7 +41,8 @@ bool auto_isrunning = false; int countRounds = 0; bool isPlannedReboot = false; -static const char *TAG = "TFLITE SERVER"; +static const char *TAG = "MAINCTRL"; + //#define DEBUG_DETAIL_ON @@ -75,26 +76,26 @@ int getCountFlowRounds() esp_err_t GetJPG(std::string _filename, httpd_req_t *req) { - return tfliteflow.GetJPGStream(_filename, req); + return flowctrl.GetJPGStream(_filename, req); } esp_err_t GetRawJPG(httpd_req_t *req) { - return tfliteflow.SendRawJPG(req); + return flowctrl.SendRawJPG(req); } -bool isSetupModusActive() { - return tfliteflow.getStatusSetupModus(); - return false; +bool isSetupModusActive() +{ + return flowctrl.getStatusSetupModus(); } -void KillTFliteTasks() +void DeleteMainFlowTask() { #ifdef DEBUG_DETAIL_ON - ESP_LOGD(TAG, "KillTFliteTasks: xHandletask_autodoFlow: %ld", (long) xHandletask_autodoFlow); + ESP_LOGD(TAG, "DeleteMainFlowTask: xHandletask_autodoFlow: %ld", (long) xHandletask_autodoFlow); #endif if( xHandletask_autodoFlow != NULL ) { @@ -109,19 +110,19 @@ void KillTFliteTasks() void doInit(void) { - #ifdef DEBUG_DETAIL_ON - ESP_LOGD(TAG, "Start tfliteflow.InitFlow(config);"); + #ifdef DEBUG_DETAIL_ON + ESP_LOGD(TAG, "Start flowctrl.InitFlow(config);"); #endif - tfliteflow.InitFlow(CONFIG_FILE); - #ifdef DEBUG_DETAIL_ON - ESP_LOGD(TAG, "Finished tfliteflow.InitFlow(config);"); + flowctrl.InitFlow(CONFIG_FILE); + #ifdef DEBUG_DETAIL_ON + ESP_LOGD(TAG, "Finished flowctrl.InitFlow(config);"); #endif /* GPIO handler has to be initialized before MQTT init to ensure proper topic subscription */ gpio_handler_init(); #ifdef ENABLE_MQTT - tfliteflow.StartMQTTService(); + flowctrl.StartMQTTService(); #endif //ENABLE_MQTT } @@ -131,7 +132,7 @@ bool doflow(void) std::string zw_time = getCurrentTimeString(LOGFILE_TIME_FORMAT); ESP_LOGD(TAG, "doflow - start %s", zw_time.c_str()); flowisrunning = true; - tfliteflow.doFlow(zw_time); + flowctrl.doFlow(zw_time); flowisrunning = false; #ifdef DEBUG_DETAIL_ON @@ -278,7 +279,7 @@ esp_err_t handler_json(httpd_req_t *req) httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*"); httpd_resp_set_type(req, "application/json"); - std::string zw = tfliteflow.getJSON(); + std::string zw = flowctrl.getJSON(); if (zw.length() > 0) { httpd_resp_send(req, zw.c_str(), zw.length()); @@ -371,7 +372,7 @@ esp_err_t handler_wasserzaehler(httpd_req_t *req) _intype = READOUT_TYPE_ERROR; - zw = tfliteflow.getReadoutAll(_intype); + zw = flowctrl.getReadoutAll(_intype); ESP_LOGD(TAG, "ZW: %s", zw.c_str()); if (zw.length() > 0) httpd_resp_send(req, zw.c_str(), zw.length()); @@ -380,7 +381,7 @@ esp_err_t handler_wasserzaehler(httpd_req_t *req) } - std::string *status = tfliteflow.getActStatus(); + std::string *status = flowctrl.getActStatus(); string query = std::string(_query); // ESP_LOGD(TAG, "Query: %s, query.c_str()); if (query.find("full") != std::string::npos) @@ -398,8 +399,7 @@ esp_err_t handler_wasserzaehler(httpd_req_t *req) httpd_resp_sendstr_chunk(req, txt.c_str()); } - - zw = tfliteflow.getReadout(_rawValue, _noerror, 0); + zw = flowctrl.getReadout(_rawValue, _noerror, 0); if (zw.length() > 0) httpd_resp_sendstr_chunk(req, zw.c_str()); @@ -418,11 +418,11 @@ esp_err_t handler_wasserzaehler(httpd_req_t *req) txt += "\n"; std::vector htmlinfodig; - htmlinfodig = tfliteflow.GetAllDigital(); + htmlinfodig = flowctrl.GetAllDigital(); for (int i = 0; i < htmlinfodig.size(); ++i) { - if (tfliteflow.GetTypeDigital() == Digital) + if (flowctrl.GetTypeDigital() == Digital) { if (htmlinfodig[i]->val == 10) zw = "NaN"; @@ -453,7 +453,7 @@ esp_err_t handler_wasserzaehler(httpd_req_t *req) txt += "
\n"; std::vector htmlinfoana; - htmlinfoana = tfliteflow.GetAllAnalog(); + htmlinfoana = flowctrl.GetAllAnalog(); for (int i = 0; i < htmlinfoana.size(); ++i) { std::stringstream stream; @@ -675,7 +675,7 @@ esp_err_t handler_editflow(httpd_req_t *req) Camera.SetBrightnessContrastSaturation(bri, con, sat); Camera.SetLEDIntensity(intens); ESP_LOGD(TAG, "test_take - vor TakeImage"); - std::string zw = tfliteflow.doSingleStep("[TakeImage]", _host); + std::string zw = flowctrl.doSingleStep("[TakeImage]", _host); httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*"); httpd_resp_send(req, zw.c_str(), zw.length()); } @@ -690,7 +690,7 @@ esp_err_t handler_editflow(httpd_req_t *req) // ESP_LOGD(TAG, "Parameter host: %s", _host.c_str()); // string zwzw = "Do " + _task + " start\n"; ESP_LOGD(TAG, zwzw.c_str()); - std::string zw = tfliteflow.doSingleStep("[Alignment]", _host); + std::string zw = flowctrl.doSingleStep("[Alignment]", _host); httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*"); httpd_resp_send(req, zw.c_str(), zw.length()); } @@ -718,7 +718,7 @@ esp_err_t handler_statusflow(httpd_req_t *req) ESP_LOGD(TAG, "handler_statusflow: %s", req->uri); #endif - string* zw = tfliteflow.getActStatusWithTime(); + string* zw = flowctrl.getActStatusWithTime(); resp_str = zw->c_str(); httpd_resp_send(req, resp_str, HTTPD_RESP_USE_STRLEN); @@ -848,7 +848,7 @@ esp_err_t handler_prevalue(httpd_req_t *req) } if (strlen(_value) == 0) { // If no value is povided --> return actual PreValue - sReturnMessage = tfliteflow.GetPrevalue(std::string(_numbersname)); + sReturnMessage = flowctrl.GetPrevalue(std::string(_numbersname)); if (sReturnMessage.empty()) { sReturnMessage = "E92: Numbers name not found"; @@ -860,14 +860,14 @@ esp_err_t handler_prevalue(httpd_req_t *req) // New value is positive: Set PreValue to provided value and return value // New value is negative and actual RAW value is a valid number: Set PreValue to RAW value and return value LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "REST API handler_prevalue called: numbersname: " + std::string(_numbersname) + - ", value: " + std::string(_value)); - if (!tfliteflow.UpdatePrevalue(_value, _numbersname, true)) { + ", value: " + std::string(_value)); + if (!flowctrl.UpdatePrevalue(_value, _numbersname, true)) { sReturnMessage = "E93: Update request rejected. Please check device logs for more details"; httpd_resp_send(req, sReturnMessage.c_str(), sReturnMessage.length()); return ESP_FAIL; } - sReturnMessage = tfliteflow.GetPrevalue(std::string(_numbersname)); + sReturnMessage = flowctrl.GetPrevalue(std::string(_numbersname)); if (sReturnMessage.empty()) { sReturnMessage = "E94: Numbers name not found"; @@ -894,7 +894,7 @@ void task_autodoFlow(void *pvParameter) if (!isPlannedReboot && (esp_reset_reason() == ESP_RST_PANIC)) { - tfliteflow.setActStatus("Initialization (delayed)"); + flowctrl.setActStatus("Initialization (delayed)"); //#ifdef ENABLE_MQTT //MQTTPublish(mqttServer_getMainTopic() + "/" + "status", "Initialization (delayed)", false); // Right now, not possible -> MQTT Service is going to be started later //#endif //ENABLE_MQTT @@ -904,13 +904,13 @@ void task_autodoFlow(void *pvParameter) ESP_LOGD(TAG, "task_autodoFlow: start"); doInit(); - auto_isrunning = tfliteflow.isAutoStart(auto_interval); + auto_isrunning = flowctrl.isAutoStart(auto_interval); if (isSetupModusActive()) { auto_isrunning = false; std::string zw_time = getCurrentTimeString(LOGFILE_TIME_FORMAT); - tfliteflow.doFlowTakeImageOnly(zw_time); + flowctrl.doFlowTakeImageOnly(zw_time); } while (auto_isrunning) @@ -981,7 +981,7 @@ void task_autodoFlow(void *pvParameter) } -void TFliteDoAutoStart() +void StartMainFlowTask() { BaseType_t xReturned; @@ -998,17 +998,9 @@ void TFliteDoAutoStart() } -#ifdef ENABLE_MQTT -std::string GetMQTTMainTopic() +void register_server_main_flow_task_uri(httpd_handle_t server) { - return tfliteflow.GetMQTTMainTopic(); -} -#endif//ENABLE_MQTT - - -void register_server_tflite_uri(httpd_handle_t server) -{ - ESP_LOGI(TAG, "server_part_camera - Registering URI handlers"); + ESP_LOGI(TAG, "server_main_flow_task - Registering URI handlers"); httpd_uri_t camuri = { }; camuri.method = HTTP_GET; diff --git a/code/components/jomjol_tfliteclass/server_tflite.h b/code/components/jomjol_flowcontroll/MainFlowControl.h similarity index 55% rename from code/components/jomjol_tfliteclass/server_tflite.h rename to code/components/jomjol_flowcontroll/MainFlowControl.h index 91aa1075..a667132a 100644 --- a/code/components/jomjol_tfliteclass/server_tflite.h +++ b/code/components/jomjol_flowcontroll/MainFlowControl.h @@ -1,7 +1,7 @@ #pragma once -#ifndef SERVERTFLITE_H -#define SERVERTFLITE_H +#ifndef MAINFLOWCONTROL_H +#define MAINFLOWCONTROL_H #include #include @@ -10,25 +10,25 @@ #include "CImageBasis.h" #include "ClassFlowControll.h" -//#include "ClassControllCamera.h" +extern ClassFlowControll flowctrl; -extern ClassFlowControll tfliteflow; -void register_server_tflite_uri(httpd_handle_t server); -void KillTFliteTasks(); -void TFliteDoAutoStart(); -bool isSetupModusActive(); -int getCountFlowRounds(); +void register_server_main_flow_task_uri(httpd_handle_t server); void CheckIsPlannedReboot(); bool getIsPlannedReboot(); -esp_err_t GetJPG(std::string _filename, httpd_req_t *req); -esp_err_t GetRawJPG(httpd_req_t *req); +void StartMainFlowTask(); +void DeleteMainFlowTask(); +bool isSetupModusActive(); + +int getCountFlowRounds(); #ifdef ENABLE_MQTT -std::string GetMQTTMainTopic(); -esp_err_t MQTTCtrlFlowStart(std::string); +esp_err_t MQTTCtrlFlowStart(std::string _topic); #endif //ENABLE_MQTT -#endif //SERVERTFLITE_H +esp_err_t GetRawJPG(httpd_req_t *req); +esp_err_t GetJPG(std::string _filename, httpd_req_t *req); + +#endif //MAINFLOWCONTROL_H diff --git a/code/components/jomjol_mqtt/interface_mqtt.cpp b/code/components/jomjol_mqtt/interface_mqtt.cpp index 099985de..dc0809c5 100644 --- a/code/components/jomjol_mqtt/interface_mqtt.cpp +++ b/code/components/jomjol_mqtt/interface_mqtt.cpp @@ -5,7 +5,7 @@ #include "connect_wlan.h" #include "mqtt_client.h" #include "ClassLogFile.h" -#include "server_tflite.h" +#include "MainFlowControl.h" #include "cJSON.h" #include "../../include/defines.h" @@ -366,7 +366,7 @@ bool mqtt_handler_set_prevalue(std::string _topic, char* _data, int _data_len) if (cJSON_IsNumber(value)) { // Check if value is a number LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "handler_set_prevalue called: numbersname: " + std::string(numbersname->valuestring) + ", value: " + std::to_string(value->valuedouble)); - if (tfliteflow.UpdatePrevalue(std::to_string(value->valuedouble), std::string(numbersname->valuestring), true)) + if (flowctrl.UpdatePrevalue(std::to_string(value->valuedouble), std::string(numbersname->valuestring), true)) return ESP_OK; } else { diff --git a/code/components/jomjol_tfliteclass/CMakeLists.txt b/code/components/jomjol_tfliteclass/CMakeLists.txt index e0dea9c5..7f56336f 100644 --- a/code/components/jomjol_tfliteclass/CMakeLists.txt +++ b/code/components/jomjol_tfliteclass/CMakeLists.txt @@ -2,6 +2,6 @@ FILE(GLOB_RECURSE app_sources ${CMAKE_CURRENT_SOURCE_DIR}/*.*) idf_component_register(SRCS ${app_sources} INCLUDE_DIRS "." - REQUIRES jomjol_image_proc jomjol_logfile esp_http_server esp32-camera jomjol_controlcamera jomjol_flowcontroll jomjol_helper) + REQUIRES jomjol_image_proc jomjol_logfile jomjol_flowcontroll jomjol_helper) diff --git a/code/main/main.cpp b/code/main/main.cpp index ed5b2ab1..f461e729 100644 --- a/code/main/main.cpp +++ b/code/main/main.cpp @@ -30,7 +30,7 @@ #include "read_wlanini.h" #include "server_main.h" -#include "server_tflite.h" +#include "MainFlowControl.h" #include "server_file.h" #include "server_ota.h" #include "time_sntp.h" @@ -462,7 +462,7 @@ extern "C" void app_main(void) server = start_webserver(); register_server_camera_uri(server); - register_server_tflite_uri(server); + register_server_main_flow_task_uri(server); register_server_file_uri(server, "/sdcard"); register_server_ota_sdcard_uri(server); #ifdef ENABLE_MQTT @@ -482,12 +482,12 @@ extern "C" void app_main(void) // ******************************************** if (getSystemStatus() == 0) { // No error flag is set LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Initialization completed successfully! Starting flow task ..."); - TFliteDoAutoStart(); + StartMainFlowTask(); } else if (isSetSystemStatusFlag(SYSTEM_STATUS_CAM_FB_BAD) || // Non critical errors occured, we try to continue... isSetSystemStatusFlag(SYSTEM_STATUS_NTP_BAD)) { LogFile.WriteToFile(ESP_LOG_WARN, TAG, "Initialization completed with errors! Starting flow task ..."); - TFliteDoAutoStart(); + StartMainFlowTask(); } else { // Any other error is critical and makes running the flow impossible. Init is going to abort. LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Initialization failed. Flow task start aborted. Loading reduced web interface..."); diff --git a/code/main/server_main.cpp b/code/main/server_main.cpp index c2a0d781..e9f148aa 100644 --- a/code/main/server_main.cpp +++ b/code/main/server_main.cpp @@ -14,7 +14,7 @@ #include "esp_wifi.h" -#include "server_tflite.h" +#include "MainFlowControl.h" #include "esp_log.h" #include