Block REST API calls till resource is ready (#1609)

* Block REST API call till ressource is ready

* Update

* Update

* Update
This commit is contained in:
Slider0007
2022-12-17 20:38:24 +01:00
committed by GitHub
parent 4088e9ee75
commit 6083fe6151
4 changed files with 496 additions and 407 deletions

View File

@@ -164,6 +164,7 @@ static size_t jpg_encode_stream(void * arg, size_t index, const void* data, size
return len;
}
bool CCamera::SetBrightnessContrastSaturation(int _brightness, int _contrast, int _saturation)
{
bool result = false;
@@ -281,7 +282,6 @@ void CCamera::EnableAutoExposure(int flashdauer)
}
esp_err_t CCamera::CaptureToBasisImage(CImageBasis *_Image, int delay)
{
string ftype;
@@ -543,6 +543,7 @@ esp_err_t CCamera::CaptureToHTTP(httpd_req_t *req, int delay)
return res;
}
void CCamera::LightOnOff(bool status)
{
GpioHandler* gpioHandler = gpio_handler_get();
@@ -578,6 +579,7 @@ void CCamera::LightOnOff(bool status)
}
}
void CCamera::LEDOnOff(bool status)
{
// Init the GPIO
@@ -638,6 +640,7 @@ void CCamera::GetCameraParameter(httpd_req_t *req, int &qual, framesize_t &resol
};
}
framesize_t CCamera::TextToFramesize(const char * _size)
{
if (strcmp(_size, "QVGA") == 0)
@@ -669,6 +672,7 @@ CCamera::CCamera()
ledc_init();
}
esp_err_t CCamera::InitCam()
{
ESP_LOGD(TAG, "Init Camera");
@@ -682,9 +686,11 @@ esp_err_t CCamera::InitCam()
return err;
}
CameraInitSuccessful = true;
return ESP_OK;
}
void CCamera::SetLEDIntensity(float _intrel)
{
_intrel = min(_intrel, (float) 100);
@@ -694,3 +700,9 @@ void CCamera::SetLEDIntensity(float _intrel)
ESP_LOGD(TAG, "Set led_intensity to %d of 8191", led_intensity);
}
bool CCamera::getCameraInitSuccessful()
{
return CameraInitSuccessful;
}

View File

@@ -26,6 +26,7 @@ class CCamera {
int led_intensity = 4095;
void ledc_init(void);
bool CameraInitSuccessful = false;
public:
int image_height, image_width;
@@ -42,6 +43,7 @@ class CCamera {
void SetLEDIntensity(float _intrel);
void EnableAutoExposure(int flashdauer);
bool getCameraInitSuccessful();
framesize_t TextToFramesize(const char * text);

View File

@@ -17,7 +17,8 @@ char scratch2[SCRATCH_BUFSIZE2];
//#define DEBUG_DETAIL_ON
void PowerResetCamera(){
void PowerResetCamera()
{
ESP_LOGD(TAG, "Resetting camera by power down line");
gpio_config_t conf;
conf.intr_type = GPIO_INTR_DISABLE;
@@ -37,72 +38,102 @@ void PowerResetCamera(){
esp_err_t handler_lightOn(httpd_req_t *req)
{
#ifdef DEBUG_DETAIL_ON
#ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("handler_lightOn - Start");
ESP_LOGD(TAG, "handler_lightOn uri: %s", req->uri);
#endif
#endif
if (Camera.getCameraInitSuccessful())
{
Camera.LightOnOff(true);
const char* resp_str = (const char*) req->user_ctx;
httpd_resp_send(req, resp_str, strlen(resp_str));
}
else
{
httpd_resp_send_err(req, HTTPD_403_FORBIDDEN, "Camera Light On API not yet initialized. Please retry later...");
return ESP_ERR_NOT_FOUND;
}
#ifdef DEBUG_DETAIL_ON
#ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("handler_lightOn - Done");
#endif
#endif
return ESP_OK;
};
}
esp_err_t handler_lightOff(httpd_req_t *req)
{
#ifdef DEBUG_DETAIL_ON
#ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("handler_lightOff - Start");
ESP_LOGD(TAG, "handler_lightOff uri: %s", req->uri);
#endif
#endif
if (Camera.getCameraInitSuccessful())
{
Camera.LightOnOff(false);
const char* resp_str = (const char*) req->user_ctx;
httpd_resp_send(req, resp_str, strlen(resp_str));
}
else
{
httpd_resp_send_err(req, HTTPD_403_FORBIDDEN, "Camera Light Off API not yet initialized. Please retry later...");
return ESP_ERR_NOT_FOUND;
}
#ifdef DEBUG_DETAIL_ON
#ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("handler_lightOff - Done");
#endif
#endif
return ESP_OK;
};
}
esp_err_t handler_capture(httpd_req_t *req)
{
#ifdef DEBUG_DETAIL_ON
#ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("handler_capture - Start");
#endif
#endif
if (Camera.getCameraInitSuccessful())
{
int quality;
framesize_t res;
Camera.GetCameraParameter(req, quality, res);
#ifdef DEBUG_DETAIL_ON
#ifdef DEBUG_DETAIL_ON
ESP_LOGD(TAG, "Size: %d, Quality: %d", res, quality);
#endif
#endif
Camera.SetQualitySize(quality, res);
esp_err_t ressult;
ressult = Camera.CaptureToHTTP(req);
esp_err_t result;
result = Camera.CaptureToHTTP(req);
#ifdef DEBUG_DETAIL_ON
#ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("handler_capture - Done");
#endif
#endif
return ressult;
};
return result;
}
else
{
httpd_resp_send_err(req, HTTPD_403_FORBIDDEN, "Camera Capture API not yet initialized. Please retry later...");
return ESP_ERR_NOT_FOUND;
}
}
esp_err_t handler_capture_with_ligth(httpd_req_t *req)
{
#ifdef DEBUG_DETAIL_ON
#ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("handler_capture_with_ligth - Start");
#endif
#endif
if (Camera.getCameraInitSuccessful())
{
char _query[100];
char _delay[10];
@@ -115,47 +146,54 @@ esp_err_t handler_capture_with_ligth(httpd_req_t *req)
ESP_LOGD(TAG, "Query: %s", _query);
if (httpd_query_key_value(_query, "delay", _delay, 10) == ESP_OK)
{
#ifdef DEBUG_DETAIL_ON
#ifdef DEBUG_DETAIL_ON
ESP_LOGD(TAG, "Delay: %s", _delay);
#endif
#endif
delay = atoi(_delay);
if (delay < 0)
delay = 0;
}
};
}
Camera.GetCameraParameter(req, quality, res);
#ifdef DEBUG_DETAIL_ON
#ifdef DEBUG_DETAIL_ON
ESP_LOGD(TAG, "Size: %d, Quality: %d", res, quality);
#endif
#endif
Camera.SetQualitySize(quality, res);
Camera.LightOnOff(true);
const TickType_t xDelay = delay / portTICK_PERIOD_MS;
vTaskDelay( xDelay );
esp_err_t ressult;
ressult = Camera.CaptureToHTTP(req);
esp_err_t result;
result = Camera.CaptureToHTTP(req);
Camera.LightOnOff(false);
#ifdef DEBUG_DETAIL_ON
#ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("handler_capture_with_ligth - Done");
#endif
return ressult;
};
#endif
return result;
}
else
{
httpd_resp_send_err(req, HTTPD_403_FORBIDDEN, "Camera Capture + flashlight API not yet initialized. Please retry later...");
return ESP_ERR_NOT_FOUND;
}
}
esp_err_t handler_capture_save_to_file(httpd_req_t *req)
{
#ifdef DEBUG_DETAIL_ON
#ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("handler_capture_save_to_file - Start");
#endif
#endif
if (Camera.getCameraInitSuccessful())
{
char _query[100];
char _delay[10];
int delay = 0;
@@ -172,47 +210,51 @@ esp_err_t handler_capture_save_to_file(httpd_req_t *req)
if (httpd_query_key_value(_query, "filename", filename, 100) == ESP_OK)
{
fn.append(filename);
#ifdef DEBUG_DETAIL_ON
#ifdef DEBUG_DETAIL_ON
ESP_LOGD(TAG, "Filename: %s", fn.c_str());
#endif
#endif
}
else
fn.append("noname.jpg");
if (httpd_query_key_value(_query, "delay", _delay, 10) == ESP_OK)
{
#ifdef DEBUG_DETAIL_ON
#ifdef DEBUG_DETAIL_ON
ESP_LOGD(TAG, "Delay: %s", _delay);
#endif
#endif
delay = atoi(_delay);
if (delay < 0)
delay = 0;
}
}
else
fn.append("noname.jpg");
Camera.GetCameraParameter(req, quality, res);
#ifdef DEBUG_DETAIL_ON
#ifdef DEBUG_DETAIL_ON
ESP_LOGD(TAG, "Size: %d, Quality: %d", res, quality);
#endif
#endif
Camera.SetQualitySize(quality, res);
esp_err_t ressult;
ressult = Camera.CaptureToFile(fn, delay);
esp_err_t result;
result = Camera.CaptureToFile(fn, delay);
const char* resp_str = (const char*) fn.c_str();
httpd_resp_send(req, resp_str, strlen(resp_str));
#ifdef DEBUG_DETAIL_ON
#ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("handler_capture_save_to_file - Done");
#endif
return ressult;
};
#endif
return result;
}
else
{
httpd_resp_send_err(req, HTTPD_403_FORBIDDEN, "Camera Capture + save API not yet initialized. Please retry later...");
return ESP_ERR_NOT_FOUND;
}
}
void register_server_camera_uri(httpd_handle_t server)

View File

@@ -31,6 +31,7 @@ ClassFlowControll tfliteflow;
TaskHandle_t xHandleblink_task_doFlow = NULL;
TaskHandle_t xHandletask_autodoFlow = NULL;
bool FlowInitDone = false;
bool flowisrunning = false;
long auto_intervall = 0;
@@ -47,17 +48,18 @@ int getCountFlowRounds() {
}
esp_err_t GetJPG(std::string _filename, httpd_req_t *req)
{
return tfliteflow.GetJPGStream(_filename, req);
}
esp_err_t GetRawJPG(httpd_req_t *req)
{
return tfliteflow.SendRawJPG(req);
}
bool isSetupModusActive() {
return tfliteflow.getStatusSetupModus();
return false;
@@ -66,70 +68,72 @@ bool isSetupModusActive() {
void KillTFliteTasks()
{
#ifdef DEBUG_DETAIL_ON
#ifdef DEBUG_DETAIL_ON
ESP_LOGD(TAG, "Handle: xHandleblink_task_doFlow: %ld", (long) xHandleblink_task_doFlow);
#endif
#endif
if (xHandleblink_task_doFlow != NULL)
{
TaskHandle_t xHandleblink_task_doFlowTmp = xHandleblink_task_doFlow;
xHandleblink_task_doFlow = NULL;
vTaskDelete(xHandleblink_task_doFlowTmp);
#ifdef DEBUG_DETAIL_ON
#ifdef DEBUG_DETAIL_ON
ESP_LOGD(TAG, "Killed: xHandleblink_task_doFlow");
#endif
#endif
}
#ifdef DEBUG_DETAIL_ON
#ifdef DEBUG_DETAIL_ON
ESP_LOGD(TAG, "Handle: xHandletask_autodoFlow: %ld", (long) xHandletask_autodoFlow);
#endif
#endif
if (xHandletask_autodoFlow != NULL)
{
TaskHandle_t xHandletask_autodoFlowTmp = xHandletask_autodoFlow;
xHandletask_autodoFlow = NULL;
vTaskDelete(xHandletask_autodoFlowTmp);
#ifdef DEBUG_DETAIL_ON
#ifdef DEBUG_DETAIL_ON
ESP_LOGD(TAG, "Killed: xHandletask_autodoFlow");
#endif
#endif
}
}
void doInit(void)
{
#ifdef DEBUG_DETAIL_ON
#ifdef DEBUG_DETAIL_ON
ESP_LOGD(TAG, "Start tfliteflow.InitFlow(config);");
#endif
#endif
tfliteflow.InitFlow(CONFIG_FILE);
#ifdef DEBUG_DETAIL_ON
FlowInitDone = true;
#ifdef DEBUG_DETAIL_ON
ESP_LOGD(TAG, "Finished tfliteflow.InitFlow(config);");
#endif
#endif
#ifdef ENABLE_MQTT
#ifdef ENABLE_MQTT
tfliteflow.StartMQTTService();
#endif //ENABLE_MQTT
#endif //ENABLE_MQTT
}
bool doflow(void)
{
std::string zw_time = gettimestring(LOGFILE_TIME_FORMAT);
ESP_LOGD(TAG, "doflow - start %s", zw_time.c_str());
flowisrunning = true;
tfliteflow.doFlow(zw_time);
flowisrunning = false;
#ifdef DEBUG_DETAIL_ON
#ifdef DEBUG_DETAIL_ON
ESP_LOGD(TAG, "doflow - end %s", zw_time.c_str());
#endif
#endif
return true;
}
void blink_task_doFlow(void *pvParameter)
{
#ifdef DEBUG_DETAIL_ON
#ifdef DEBUG_DETAIL_ON
ESP_LOGD(TAG, "blink_task_doFlow");
#endif
#endif
if (!flowisrunning)
{
flowisrunning = true;
@@ -143,10 +147,10 @@ void blink_task_doFlow(void *pvParameter)
esp_err_t handler_init(httpd_req_t *req)
{
#ifdef DEBUG_DETAIL_ON
#ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("handler_init - Start");
ESP_LOGD(TAG, "handler_doinit uri: %s", req->uri);
#endif
#endif
const char* resp_str = "Init started<br>";
httpd_resp_send(req, resp_str, strlen(resp_str));
@@ -158,18 +162,19 @@ esp_err_t handler_init(httpd_req_t *req)
/* Respond with an empty chunk to signal HTTP response completion */
httpd_resp_send_chunk(req, NULL, 0);
#ifdef DEBUG_DETAIL_ON
#ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("handler_init - Done");
#endif
#endif
return ESP_OK;
};
}
esp_err_t handler_doflow(httpd_req_t *req)
{
#ifdef DEBUG_DETAIL_ON
#ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("handler_doflow - Start");
#endif
#endif
ESP_LOGD(TAG, "handler_doFlow uri: %s", req->uri);
@@ -188,23 +193,24 @@ esp_err_t handler_doflow(httpd_req_t *req)
/* Respond with an empty chunk to signal HTTP response completion */
httpd_resp_send_chunk(req, NULL, 0);
#ifdef DEBUG_DETAIL_ON
#ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("handler_doflow - Done");
#endif
#endif
return ESP_OK;
};
}
esp_err_t handler_json(httpd_req_t *req)
{
#ifdef DEBUG_DETAIL_ON
#ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("handler_json - Start");
#endif
#endif
ESP_LOGD(TAG, "handler_JSON uri: %s", req->uri);
if (FlowInitDone)
{
httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*");
httpd_resp_set_type(req, "application/json");
@@ -217,21 +223,28 @@ esp_err_t handler_json(httpd_req_t *req)
{
httpd_resp_send(req, NULL, 0);
}
}
else
{
httpd_resp_send_err(req, HTTPD_403_FORBIDDEN, "JSON API not yet initialized. Please retry later...");
return ESP_ERR_NOT_FOUND;
}
#ifdef DEBUG_DETAIL_ON
#ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("handler_JSON - Done");
#endif
#endif
return ESP_OK;
};
}
esp_err_t handler_wasserzaehler(httpd_req_t *req)
{
#ifdef DEBUG_DETAIL_ON
#ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("handler_wasserzaehler - Start");
#endif
#endif
if (FlowInitDone)
{
bool _rawValue = false;
bool _noerror = false;
bool _all = false;
@@ -245,35 +258,35 @@ esp_err_t handler_wasserzaehler(httpd_req_t *req)
if (httpd_req_get_url_query_str(req, _query, 100) == ESP_OK)
{
// ESP_LOGD(TAG, "Query: %s", _query);
// ESP_LOGD(TAG, "Query: %s", _query);
if (httpd_query_key_value(_query, "all", _size, 10) == ESP_OK)
{
#ifdef DEBUG_DETAIL_ON
#ifdef DEBUG_DETAIL_ON
ESP_LOGD(TAG, "all is found%s", _size);
#endif
#endif
_all = true;
}
if (httpd_query_key_value(_query, "type", _size, 10) == ESP_OK)
{
#ifdef DEBUG_DETAIL_ON
#ifdef DEBUG_DETAIL_ON
ESP_LOGD(TAG, "all is found: %s", _size);
#endif
#endif
_type = std::string(_size);
}
if (httpd_query_key_value(_query, "rawvalue", _size, 10) == ESP_OK)
{
#ifdef DEBUG_DETAIL_ON
#ifdef DEBUG_DETAIL_ON
ESP_LOGD(TAG, "rawvalue is found: %s", _size);
#endif
#endif
_rawValue = true;
}
if (httpd_query_key_value(_query, "noerror", _size, 10) == ESP_OK)
{
#ifdef DEBUG_DETAIL_ON
#ifdef DEBUG_DETAIL_ON
ESP_LOGD(TAG, "noerror is found: %s", _size);
#endif
#endif
_noerror = true;
}
}
@@ -306,7 +319,7 @@ esp_err_t handler_wasserzaehler(httpd_req_t *req)
httpd_resp_sendstr_chunk(req, zw.c_str());
string query = std::string(_query);
// ESP_LOGD(TAG, "Query: %s, query.c_str());
// ESP_LOGD(TAG, "Query: %s, query.c_str());
if (query.find("full") != std::string::npos)
{
string txt, zw;
@@ -361,26 +374,27 @@ esp_err_t handler_wasserzaehler(httpd_req_t *req)
}
/* Respond with an empty chunk to signal HTTP response completion */
httpd_resp_sendstr_chunk(req, NULL);
}
else
{
httpd_resp_send_err(req, HTTPD_403_FORBIDDEN, "Value API not yet initialized. Please retry later...");
return ESP_ERR_NOT_FOUND;
}
#ifdef DEBUG_DETAIL_ON
#ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("handler_wasserzaehler - Done");
#endif
#endif
return ESP_OK;
};
}
esp_err_t handler_editflow(httpd_req_t *req)
{
#ifdef DEBUG_DETAIL_ON
#ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("handler_editflow - Start");
#endif
#endif
ESP_LOGD(TAG, "handler_editflow uri: %s", req->uri);
@@ -392,9 +406,9 @@ esp_err_t handler_editflow(httpd_req_t *req)
{
if (httpd_query_key_value(_query, "task", _valuechar, 30) == ESP_OK)
{
#ifdef DEBUG_DETAIL_ON
#ifdef DEBUG_DETAIL_ON
ESP_LOGD(TAG, "task is found: %s", _valuechar);
#endif
#endif
_task = string(_valuechar);
}
}
@@ -427,10 +441,10 @@ esp_err_t handler_editflow(httpd_req_t *req)
httpd_query_key_value(_query, "out", _valuechar, 30);
out = string(_valuechar);
#ifdef DEBUG_DETAIL_ON
#ifdef DEBUG_DETAIL_ON
ESP_LOGD(TAG, "in: %s", in.c_str());
ESP_LOGD(TAG, "out: %s", out.c_str());
#endif
#endif
in = "/sdcard" + in;
out = "/sdcard" + out;
@@ -469,14 +483,14 @@ esp_err_t handler_editflow(httpd_req_t *req)
zw = string(_valuechar);
dy = stoi(zw);
#ifdef DEBUG_DETAIL_ON
#ifdef DEBUG_DETAIL_ON
ESP_LOGD(TAG, "in: %s", in.c_str());
ESP_LOGD(TAG, "out: %s", out.c_str());
ESP_LOGD(TAG, "x: %s", zw.c_str());
ESP_LOGD(TAG, "y: %s", zw.c_str());
ESP_LOGD(TAG, "dx: %s", zw.c_str());
ESP_LOGD(TAG, "dy: %s", zw.c_str());
#endif
#endif
if (httpd_query_key_value(_query, "enhance", _valuechar, 10) == ESP_OK)
{
@@ -570,25 +584,27 @@ esp_err_t handler_editflow(httpd_req_t *req)
/* Respond with an empty chunk to signal HTTP response completion */
httpd_resp_sendstr_chunk(req, NULL);
#ifdef DEBUG_DETAIL_ON
#ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("handler_editflow - Done");
#endif
#endif
return ESP_OK;
};
}
esp_err_t handler_statusflow(httpd_req_t *req)
{
#ifdef DEBUG_DETAIL_ON
#ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("handler_prevalue - Start");
#endif
#endif
if (FlowInitDone)
{
const char* resp_str;
#ifdef DEBUG_DETAIL_ON
#ifdef DEBUG_DETAIL_ON
ESP_LOGD(TAG, "handler_prevalue: %s", req->uri);
#endif
#endif
string* zw = tfliteflow.getActStatus();
resp_str = zw->c_str();
@@ -597,19 +613,26 @@ esp_err_t handler_statusflow(httpd_req_t *req)
httpd_resp_send(req, resp_str, strlen(resp_str));
/* Respond with an empty chunk to signal HTTP response completion */
httpd_resp_send_chunk(req, NULL, 0);
}
else
{
httpd_resp_send_err(req, HTTPD_403_FORBIDDEN, "Flowstatus API not yet initialized. Please retry later...");
return ESP_ERR_NOT_FOUND;
}
#ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("handler_prevalue - Start");
#endif
#ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("handler_prevalue - Done");
#endif
return ESP_OK;
};
}
esp_err_t handler_cputemp(httpd_req_t *req)
{
#ifdef DEBUG_DETAIL_ON
#ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("handler_cputemp - Start");
#endif
#endif
const char* resp_str;
char cputemp[20];
@@ -623,19 +646,22 @@ esp_err_t handler_cputemp(httpd_req_t *req)
/* Respond with an empty chunk to signal HTTP response completion */
httpd_resp_send_chunk(req, NULL, 0);
#ifdef DEBUG_DETAIL_ON
#ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("handler_cputemp - End");
#endif
#endif
return ESP_OK;
};
}
esp_err_t handler_rssi(httpd_req_t *req)
{
#ifdef DEBUG_DETAIL_ON
#ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("handler_rssi - Start");
#endif
#endif
if (getWIFIisConnected())
{
const char* resp_str;
char rssi[20];
@@ -647,13 +673,19 @@ esp_err_t handler_rssi(httpd_req_t *req)
httpd_resp_send(req, resp_str, strlen(resp_str));
/* Respond with an empty chunk to signal HTTP response completion */
httpd_resp_send_chunk(req, NULL, 0);
}
else
{
httpd_resp_send_err(req, HTTPD_403_FORBIDDEN, "RSSI API not yet initialized. Please retry later...");
return ESP_ERR_NOT_FOUND;
}
#ifdef DEBUG_DETAIL_ON
#ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("handler_rssi - End");
#endif
#endif
return ESP_OK;
};
}
esp_err_t handler_uptime(httpd_req_t *req)
@@ -680,16 +712,16 @@ esp_err_t handler_uptime(httpd_req_t *req)
esp_err_t handler_prevalue(httpd_req_t *req)
{
#ifdef DEBUG_DETAIL_ON
#ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("handler_prevalue - Start");
#endif
#endif
const char* resp_str;
string zw;
#ifdef DEBUG_DETAIL_ON
#ifdef DEBUG_DETAIL_ON
ESP_LOGD(TAG, "handler_prevalue: %s", req->uri);
#endif
#endif
char _query[100];
char _size[10] = "";
@@ -697,15 +729,15 @@ esp_err_t handler_prevalue(httpd_req_t *req)
if (httpd_req_get_url_query_str(req, _query, 100) == ESP_OK)
{
#ifdef DEBUG_DETAIL_ON
#ifdef DEBUG_DETAIL_ON
ESP_LOGD(TAG, "Query: %s", _query);
#endif
#endif
if (httpd_query_key_value(_query, "value", _size, 10) == ESP_OK)
{
#ifdef DEBUG_DETAIL_ON
#ifdef DEBUG_DETAIL_ON
ESP_LOGD(TAG, "Value: %s", _size);
#endif
#endif
}
httpd_query_key_value(_query, "numbers", _numbers, 50);
@@ -729,12 +761,13 @@ esp_err_t handler_prevalue(httpd_req_t *req)
/* Respond with an empty chunk to signal HTTP response completion */
httpd_resp_send_chunk(req, NULL, 0);
#ifdef DEBUG_DETAIL_ON
#ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("handler_prevalue - End");
#endif
#endif
return ESP_OK;
};
}
void task_autodoFlow(void *pvParameter)
{
@@ -768,20 +801,20 @@ void task_autodoFlow(void *pvParameter)
if (flowisrunning)
{
#ifdef DEBUG_DETAIL_ON
#ifdef DEBUG_DETAIL_ON
ESP_LOGD(TAG, "Autoflow: doFlow is already running!");
#endif
#endif
}
else
{
#ifdef DEBUG_DETAIL_ON
#ifdef DEBUG_DETAIL_ON
ESP_LOGD(TAG, "Autoflow: doFlow is started");
#endif
#endif
flowisrunning = true;
doflow();
#ifdef DEBUG_DETAIL_ON
#ifdef DEBUG_DETAIL_ON
ESP_LOGD(TAG, "Remove older log files");
#endif
#endif
LogFile.RemoveOldLogFile();
LogFile.RemoveOldDataLog();
}
@@ -808,6 +841,7 @@ void task_autodoFlow(void *pvParameter)
ESP_LOGD(TAG, "task_autodoFlow: end");
}
void TFliteDoAutoStart()
{
BaseType_t xReturned;
@@ -825,10 +859,9 @@ void TFliteDoAutoStart()
ESP_LOGD(TAG, "ERROR task_autodoFlow konnte nicht erzeugt werden!");
}
ESP_LOGD(TAG, "getESPHeapInfo: %s", getESPHeapInfo().c_str());
}
#ifdef ENABLE_MQTT
std::string GetMQTTMainTopic()
{