mirror of
https://github.com/jomjol/AI-on-the-edge-device.git
synced 2025-12-08 12:36:52 +03:00
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:
@@ -164,6 +164,7 @@ static size_t jpg_encode_stream(void * arg, size_t index, const void* data, size
|
|||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool CCamera::SetBrightnessContrastSaturation(int _brightness, int _contrast, int _saturation)
|
bool CCamera::SetBrightnessContrastSaturation(int _brightness, int _contrast, int _saturation)
|
||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
@@ -281,7 +282,6 @@ void CCamera::EnableAutoExposure(int flashdauer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
esp_err_t CCamera::CaptureToBasisImage(CImageBasis *_Image, int delay)
|
esp_err_t CCamera::CaptureToBasisImage(CImageBasis *_Image, int delay)
|
||||||
{
|
{
|
||||||
string ftype;
|
string ftype;
|
||||||
@@ -543,6 +543,7 @@ esp_err_t CCamera::CaptureToHTTP(httpd_req_t *req, int delay)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CCamera::LightOnOff(bool status)
|
void CCamera::LightOnOff(bool status)
|
||||||
{
|
{
|
||||||
GpioHandler* gpioHandler = gpio_handler_get();
|
GpioHandler* gpioHandler = gpio_handler_get();
|
||||||
@@ -578,6 +579,7 @@ void CCamera::LightOnOff(bool status)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CCamera::LEDOnOff(bool status)
|
void CCamera::LEDOnOff(bool status)
|
||||||
{
|
{
|
||||||
// Init the GPIO
|
// 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)
|
framesize_t CCamera::TextToFramesize(const char * _size)
|
||||||
{
|
{
|
||||||
if (strcmp(_size, "QVGA") == 0)
|
if (strcmp(_size, "QVGA") == 0)
|
||||||
@@ -669,6 +672,7 @@ CCamera::CCamera()
|
|||||||
ledc_init();
|
ledc_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
esp_err_t CCamera::InitCam()
|
esp_err_t CCamera::InitCam()
|
||||||
{
|
{
|
||||||
ESP_LOGD(TAG, "Init Camera");
|
ESP_LOGD(TAG, "Init Camera");
|
||||||
@@ -682,9 +686,11 @@ esp_err_t CCamera::InitCam()
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CameraInitSuccessful = true;
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CCamera::SetLEDIntensity(float _intrel)
|
void CCamera::SetLEDIntensity(float _intrel)
|
||||||
{
|
{
|
||||||
_intrel = min(_intrel, (float) 100);
|
_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);
|
ESP_LOGD(TAG, "Set led_intensity to %d of 8191", led_intensity);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool CCamera::getCameraInitSuccessful()
|
||||||
|
{
|
||||||
|
return CameraInitSuccessful;
|
||||||
|
}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ class CCamera {
|
|||||||
int led_intensity = 4095;
|
int led_intensity = 4095;
|
||||||
|
|
||||||
void ledc_init(void);
|
void ledc_init(void);
|
||||||
|
bool CameraInitSuccessful = false;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int image_height, image_width;
|
int image_height, image_width;
|
||||||
@@ -42,6 +43,7 @@ class CCamera {
|
|||||||
void SetLEDIntensity(float _intrel);
|
void SetLEDIntensity(float _intrel);
|
||||||
|
|
||||||
void EnableAutoExposure(int flashdauer);
|
void EnableAutoExposure(int flashdauer);
|
||||||
|
bool getCameraInitSuccessful();
|
||||||
|
|
||||||
|
|
||||||
framesize_t TextToFramesize(const char * text);
|
framesize_t TextToFramesize(const char * text);
|
||||||
|
|||||||
@@ -17,7 +17,8 @@ char scratch2[SCRATCH_BUFSIZE2];
|
|||||||
//#define DEBUG_DETAIL_ON
|
//#define DEBUG_DETAIL_ON
|
||||||
|
|
||||||
|
|
||||||
void PowerResetCamera(){
|
void PowerResetCamera()
|
||||||
|
{
|
||||||
ESP_LOGD(TAG, "Resetting camera by power down line");
|
ESP_LOGD(TAG, "Resetting camera by power down line");
|
||||||
gpio_config_t conf;
|
gpio_config_t conf;
|
||||||
conf.intr_type = GPIO_INTR_DISABLE;
|
conf.intr_type = GPIO_INTR_DISABLE;
|
||||||
@@ -37,182 +38,223 @@ void PowerResetCamera(){
|
|||||||
|
|
||||||
esp_err_t handler_lightOn(httpd_req_t *req)
|
esp_err_t handler_lightOn(httpd_req_t *req)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
LogFile.WriteHeapInfo("handler_lightOn - Start");
|
LogFile.WriteHeapInfo("handler_lightOn - Start");
|
||||||
ESP_LOGD(TAG, "handler_lightOn uri: %s", req->uri);
|
ESP_LOGD(TAG, "handler_lightOn uri: %s", req->uri);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Camera.LightOnOff(true);
|
if (Camera.getCameraInitSuccessful())
|
||||||
const char* resp_str = (const char*) req->user_ctx;
|
{
|
||||||
httpd_resp_send(req, resp_str, strlen(resp_str));
|
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");
|
LogFile.WriteHeapInfo("handler_lightOn - Done");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
esp_err_t handler_lightOff(httpd_req_t *req)
|
esp_err_t handler_lightOff(httpd_req_t *req)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
LogFile.WriteHeapInfo("handler_lightOff - Start");
|
LogFile.WriteHeapInfo("handler_lightOff - Start");
|
||||||
ESP_LOGD(TAG, "handler_lightOff uri: %s", req->uri);
|
ESP_LOGD(TAG, "handler_lightOff uri: %s", req->uri);
|
||||||
#endif
|
#endif
|
||||||
Camera.LightOnOff(false);
|
|
||||||
const char* resp_str = (const char*) req->user_ctx;
|
|
||||||
httpd_resp_send(req, resp_str, strlen(resp_str));
|
|
||||||
|
|
||||||
#ifdef DEBUG_DETAIL_ON
|
if (Camera.getCameraInitSuccessful())
|
||||||
LogFile.WriteHeapInfo("handler_lightOff - Done");
|
{
|
||||||
#endif
|
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
|
||||||
|
LogFile.WriteHeapInfo("handler_lightOff - Done");
|
||||||
|
#endif
|
||||||
|
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
esp_err_t handler_capture(httpd_req_t *req)
|
esp_err_t handler_capture(httpd_req_t *req)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
LogFile.WriteHeapInfo("handler_capture - Start");
|
LogFile.WriteHeapInfo("handler_capture - Start");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int quality;
|
if (Camera.getCameraInitSuccessful())
|
||||||
framesize_t res;
|
{
|
||||||
|
int quality;
|
||||||
|
framesize_t res;
|
||||||
|
|
||||||
Camera.GetCameraParameter(req, quality, res);
|
Camera.GetCameraParameter(req, quality, res);
|
||||||
|
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
ESP_LOGD(TAG, "Size: %d, Quality: %d", res, quality);
|
ESP_LOGD(TAG, "Size: %d, Quality: %d", res, quality);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Camera.SetQualitySize(quality, res);
|
Camera.SetQualitySize(quality, res);
|
||||||
|
|
||||||
esp_err_t ressult;
|
esp_err_t result;
|
||||||
ressult = Camera.CaptureToHTTP(req);
|
result = Camera.CaptureToHTTP(req);
|
||||||
|
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
LogFile.WriteHeapInfo("handler_capture - Done");
|
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)
|
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");
|
LogFile.WriteHeapInfo("handler_capture_with_ligth - Start");
|
||||||
#endif
|
#endif
|
||||||
char _query[100];
|
|
||||||
char _delay[10];
|
|
||||||
|
|
||||||
int quality;
|
if (Camera.getCameraInitSuccessful())
|
||||||
framesize_t res;
|
|
||||||
int delay = 2500;
|
|
||||||
|
|
||||||
if (httpd_req_get_url_query_str(req, _query, 100) == ESP_OK)
|
|
||||||
{
|
{
|
||||||
ESP_LOGD(TAG, "Query: %s", _query);
|
char _query[100];
|
||||||
if (httpd_query_key_value(_query, "delay", _delay, 10) == ESP_OK)
|
char _delay[10];
|
||||||
|
|
||||||
|
int quality;
|
||||||
|
framesize_t res;
|
||||||
|
int delay = 2500;
|
||||||
|
|
||||||
|
if (httpd_req_get_url_query_str(req, _query, 100) == ESP_OK)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
ESP_LOGD(TAG, "Query: %s", _query);
|
||||||
ESP_LOGD(TAG, "Delay: %s", _delay);
|
if (httpd_query_key_value(_query, "delay", _delay, 10) == ESP_OK)
|
||||||
#endif
|
{
|
||||||
delay = atoi(_delay);
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
ESP_LOGD(TAG, "Delay: %s", _delay);
|
||||||
|
#endif
|
||||||
|
delay = atoi(_delay);
|
||||||
|
|
||||||
if (delay < 0)
|
if (delay < 0)
|
||||||
delay = 0;
|
delay = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
Camera.GetCameraParameter(req, quality, res);
|
Camera.GetCameraParameter(req, quality, res);
|
||||||
|
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
ESP_LOGD(TAG, "Size: %d, Quality: %d", res, quality);
|
ESP_LOGD(TAG, "Size: %d, Quality: %d", res, quality);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Camera.SetQualitySize(quality, res);
|
Camera.SetQualitySize(quality, res);
|
||||||
Camera.LightOnOff(true);
|
Camera.LightOnOff(true);
|
||||||
const TickType_t xDelay = delay / portTICK_PERIOD_MS;
|
const TickType_t xDelay = delay / portTICK_PERIOD_MS;
|
||||||
vTaskDelay( xDelay );
|
vTaskDelay( xDelay );
|
||||||
|
|
||||||
esp_err_t ressult;
|
esp_err_t result;
|
||||||
ressult = Camera.CaptureToHTTP(req);
|
result = Camera.CaptureToHTTP(req);
|
||||||
|
|
||||||
Camera.LightOnOff(false);
|
Camera.LightOnOff(false);
|
||||||
|
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
LogFile.WriteHeapInfo("handler_capture_with_ligth - Done");
|
LogFile.WriteHeapInfo("handler_capture_with_ligth - Done");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return ressult;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
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)
|
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");
|
LogFile.WriteHeapInfo("handler_capture_save_to_file - Start");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
char _query[100];
|
if (Camera.getCameraInitSuccessful())
|
||||||
char _delay[10];
|
|
||||||
int delay = 0;
|
|
||||||
char filename[100];
|
|
||||||
std::string fn = "/sdcard/";
|
|
||||||
|
|
||||||
|
|
||||||
int quality;
|
|
||||||
framesize_t res;
|
|
||||||
|
|
||||||
if (httpd_req_get_url_query_str(req, _query, 100) == ESP_OK)
|
|
||||||
{
|
{
|
||||||
ESP_LOGD(TAG, "Query: %s", _query);
|
char _query[100];
|
||||||
if (httpd_query_key_value(_query, "filename", filename, 100) == ESP_OK)
|
char _delay[10];
|
||||||
|
int delay = 0;
|
||||||
|
char filename[100];
|
||||||
|
std::string fn = "/sdcard/";
|
||||||
|
|
||||||
|
|
||||||
|
int quality;
|
||||||
|
framesize_t res;
|
||||||
|
|
||||||
|
if (httpd_req_get_url_query_str(req, _query, 100) == ESP_OK)
|
||||||
{
|
{
|
||||||
fn.append(filename);
|
ESP_LOGD(TAG, "Query: %s", _query);
|
||||||
#ifdef DEBUG_DETAIL_ON
|
if (httpd_query_key_value(_query, "filename", filename, 100) == ESP_OK)
|
||||||
ESP_LOGD(TAG, "Filename: %s", fn.c_str());
|
{
|
||||||
#endif
|
fn.append(filename);
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
ESP_LOGD(TAG, "Filename: %s", fn.c_str());
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else
|
||||||
|
fn.append("noname.jpg");
|
||||||
|
|
||||||
|
if (httpd_query_key_value(_query, "delay", _delay, 10) == ESP_OK)
|
||||||
|
{
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
ESP_LOGD(TAG, "Delay: %s", _delay);
|
||||||
|
#endif
|
||||||
|
delay = atoi(_delay);
|
||||||
|
|
||||||
|
if (delay < 0)
|
||||||
|
delay = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
fn.append("noname.jpg");
|
fn.append("noname.jpg");
|
||||||
|
|
||||||
if (httpd_query_key_value(_query, "delay", _delay, 10) == ESP_OK)
|
Camera.GetCameraParameter(req, quality, res);
|
||||||
{
|
#ifdef DEBUG_DETAIL_ON
|
||||||
#ifdef DEBUG_DETAIL_ON
|
ESP_LOGD(TAG, "Size: %d, Quality: %d", res, quality);
|
||||||
ESP_LOGD(TAG, "Delay: %s", _delay);
|
#endif
|
||||||
#endif
|
Camera.SetQualitySize(quality, res);
|
||||||
delay = atoi(_delay);
|
|
||||||
|
|
||||||
if (delay < 0)
|
esp_err_t result;
|
||||||
delay = 0;
|
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
|
||||||
|
LogFile.WriteHeapInfo("handler_capture_save_to_file - Done");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
fn.append("noname.jpg");
|
{
|
||||||
|
httpd_resp_send_err(req, HTTPD_403_FORBIDDEN, "Camera Capture + save API not yet initialized. Please retry later...");
|
||||||
Camera.GetCameraParameter(req, quality, res);
|
return ESP_ERR_NOT_FOUND;
|
||||||
#ifdef DEBUG_DETAIL_ON
|
}
|
||||||
ESP_LOGD(TAG, "Size: %d, Quality: %d", res, quality);
|
}
|
||||||
#endif
|
|
||||||
Camera.SetQualitySize(quality, res);
|
|
||||||
|
|
||||||
esp_err_t ressult;
|
|
||||||
ressult = 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
|
|
||||||
LogFile.WriteHeapInfo("handler_capture_save_to_file - Done");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return ressult;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void register_server_camera_uri(httpd_handle_t server)
|
void register_server_camera_uri(httpd_handle_t server)
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ ClassFlowControll tfliteflow;
|
|||||||
TaskHandle_t xHandleblink_task_doFlow = NULL;
|
TaskHandle_t xHandleblink_task_doFlow = NULL;
|
||||||
TaskHandle_t xHandletask_autodoFlow = NULL;
|
TaskHandle_t xHandletask_autodoFlow = NULL;
|
||||||
|
|
||||||
|
bool FlowInitDone = false;
|
||||||
bool flowisrunning = false;
|
bool flowisrunning = false;
|
||||||
|
|
||||||
long auto_intervall = 0;
|
long auto_intervall = 0;
|
||||||
@@ -47,17 +48,18 @@ int getCountFlowRounds() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
esp_err_t GetJPG(std::string _filename, httpd_req_t *req)
|
esp_err_t GetJPG(std::string _filename, httpd_req_t *req)
|
||||||
{
|
{
|
||||||
return tfliteflow.GetJPGStream(_filename, req);
|
return tfliteflow.GetJPGStream(_filename, req);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
esp_err_t GetRawJPG(httpd_req_t *req)
|
esp_err_t GetRawJPG(httpd_req_t *req)
|
||||||
{
|
{
|
||||||
return tfliteflow.SendRawJPG(req);
|
return tfliteflow.SendRawJPG(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool isSetupModusActive() {
|
bool isSetupModusActive() {
|
||||||
return tfliteflow.getStatusSetupModus();
|
return tfliteflow.getStatusSetupModus();
|
||||||
return false;
|
return false;
|
||||||
@@ -66,70 +68,72 @@ bool isSetupModusActive() {
|
|||||||
|
|
||||||
void KillTFliteTasks()
|
void KillTFliteTasks()
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
ESP_LOGD(TAG, "Handle: xHandleblink_task_doFlow: %ld", (long) xHandleblink_task_doFlow);
|
ESP_LOGD(TAG, "Handle: xHandleblink_task_doFlow: %ld", (long) xHandleblink_task_doFlow);
|
||||||
#endif
|
#endif
|
||||||
if (xHandleblink_task_doFlow != NULL)
|
if (xHandleblink_task_doFlow != NULL)
|
||||||
{
|
{
|
||||||
TaskHandle_t xHandleblink_task_doFlowTmp = xHandleblink_task_doFlow;
|
TaskHandle_t xHandleblink_task_doFlowTmp = xHandleblink_task_doFlow;
|
||||||
xHandleblink_task_doFlow = NULL;
|
xHandleblink_task_doFlow = NULL;
|
||||||
vTaskDelete(xHandleblink_task_doFlowTmp);
|
vTaskDelete(xHandleblink_task_doFlowTmp);
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
ESP_LOGD(TAG, "Killed: xHandleblink_task_doFlow");
|
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);
|
ESP_LOGD(TAG, "Handle: xHandletask_autodoFlow: %ld", (long) xHandletask_autodoFlow);
|
||||||
#endif
|
#endif
|
||||||
if (xHandletask_autodoFlow != NULL)
|
if (xHandletask_autodoFlow != NULL)
|
||||||
{
|
{
|
||||||
TaskHandle_t xHandletask_autodoFlowTmp = xHandletask_autodoFlow;
|
TaskHandle_t xHandletask_autodoFlowTmp = xHandletask_autodoFlow;
|
||||||
xHandletask_autodoFlow = NULL;
|
xHandletask_autodoFlow = NULL;
|
||||||
vTaskDelete(xHandletask_autodoFlowTmp);
|
vTaskDelete(xHandletask_autodoFlowTmp);
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
ESP_LOGD(TAG, "Killed: xHandletask_autodoFlow");
|
ESP_LOGD(TAG, "Killed: xHandletask_autodoFlow");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void doInit(void)
|
void doInit(void)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
ESP_LOGD(TAG, "Start tfliteflow.InitFlow(config);");
|
ESP_LOGD(TAG, "Start tfliteflow.InitFlow(config);");
|
||||||
#endif
|
#endif
|
||||||
tfliteflow.InitFlow(CONFIG_FILE);
|
tfliteflow.InitFlow(CONFIG_FILE);
|
||||||
#ifdef DEBUG_DETAIL_ON
|
FlowInitDone = true;
|
||||||
ESP_LOGD(TAG, "Finished tfliteflow.InitFlow(config);");
|
#ifdef DEBUG_DETAIL_ON
|
||||||
#endif
|
ESP_LOGD(TAG, "Finished tfliteflow.InitFlow(config);");
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef ENABLE_MQTT
|
#ifdef ENABLE_MQTT
|
||||||
tfliteflow.StartMQTTService();
|
tfliteflow.StartMQTTService();
|
||||||
#endif //ENABLE_MQTT
|
#endif //ENABLE_MQTT
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool doflow(void)
|
bool doflow(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
std::string zw_time = gettimestring(LOGFILE_TIME_FORMAT);
|
std::string zw_time = gettimestring(LOGFILE_TIME_FORMAT);
|
||||||
ESP_LOGD(TAG, "doflow - start %s", zw_time.c_str());
|
ESP_LOGD(TAG, "doflow - start %s", zw_time.c_str());
|
||||||
flowisrunning = true;
|
flowisrunning = true;
|
||||||
tfliteflow.doFlow(zw_time);
|
tfliteflow.doFlow(zw_time);
|
||||||
flowisrunning = false;
|
flowisrunning = false;
|
||||||
|
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
ESP_LOGD(TAG, "doflow - end %s", zw_time.c_str());
|
ESP_LOGD(TAG, "doflow - end %s", zw_time.c_str());
|
||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void blink_task_doFlow(void *pvParameter)
|
void blink_task_doFlow(void *pvParameter)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
ESP_LOGD(TAG, "blink_task_doFlow");
|
ESP_LOGD(TAG, "blink_task_doFlow");
|
||||||
#endif
|
#endif
|
||||||
if (!flowisrunning)
|
if (!flowisrunning)
|
||||||
{
|
{
|
||||||
flowisrunning = true;
|
flowisrunning = true;
|
||||||
@@ -143,10 +147,10 @@ void blink_task_doFlow(void *pvParameter)
|
|||||||
|
|
||||||
esp_err_t handler_init(httpd_req_t *req)
|
esp_err_t handler_init(httpd_req_t *req)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
LogFile.WriteHeapInfo("handler_init - Start");
|
LogFile.WriteHeapInfo("handler_init - Start");
|
||||||
ESP_LOGD(TAG, "handler_doinit uri: %s", req->uri);
|
ESP_LOGD(TAG, "handler_doinit uri: %s", req->uri);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const char* resp_str = "Init started<br>";
|
const char* resp_str = "Init started<br>";
|
||||||
httpd_resp_send(req, resp_str, strlen(resp_str));
|
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 */
|
/* Respond with an empty chunk to signal HTTP response completion */
|
||||||
httpd_resp_send_chunk(req, NULL, 0);
|
httpd_resp_send_chunk(req, NULL, 0);
|
||||||
|
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
LogFile.WriteHeapInfo("handler_init - Done");
|
LogFile.WriteHeapInfo("handler_init - Done");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
esp_err_t handler_doflow(httpd_req_t *req)
|
esp_err_t handler_doflow(httpd_req_t *req)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
LogFile.WriteHeapInfo("handler_doflow - Start");
|
LogFile.WriteHeapInfo("handler_doflow - Start");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ESP_LOGD(TAG, "handler_doFlow uri: %s", req->uri);
|
ESP_LOGD(TAG, "handler_doFlow uri: %s", req->uri);
|
||||||
|
|
||||||
@@ -188,199 +193,208 @@ esp_err_t handler_doflow(httpd_req_t *req)
|
|||||||
/* Respond with an empty chunk to signal HTTP response completion */
|
/* Respond with an empty chunk to signal HTTP response completion */
|
||||||
httpd_resp_send_chunk(req, NULL, 0);
|
httpd_resp_send_chunk(req, NULL, 0);
|
||||||
|
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
LogFile.WriteHeapInfo("handler_doflow - Done");
|
LogFile.WriteHeapInfo("handler_doflow - Done");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
esp_err_t handler_json(httpd_req_t *req)
|
esp_err_t handler_json(httpd_req_t *req)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
LogFile.WriteHeapInfo("handler_json - Start");
|
LogFile.WriteHeapInfo("handler_json - Start");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
ESP_LOGD(TAG, "handler_JSON uri: %s", req->uri);
|
ESP_LOGD(TAG, "handler_JSON uri: %s", req->uri);
|
||||||
|
|
||||||
httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*");
|
if (FlowInitDone)
|
||||||
httpd_resp_set_type(req, "application/json");
|
|
||||||
|
|
||||||
std::string zw = tfliteflow.getJSON();
|
|
||||||
if (zw.length() > 0)
|
|
||||||
{
|
{
|
||||||
httpd_resp_send(req, zw.c_str(), zw.length());
|
httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*");
|
||||||
|
httpd_resp_set_type(req, "application/json");
|
||||||
|
|
||||||
|
std::string zw = tfliteflow.getJSON();
|
||||||
|
if (zw.length() > 0)
|
||||||
|
{
|
||||||
|
httpd_resp_send(req, zw.c_str(), zw.length());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
httpd_resp_send(req, NULL, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
httpd_resp_send(req, NULL, 0);
|
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");
|
LogFile.WriteHeapInfo("handler_JSON - Done");
|
||||||
#endif
|
#endif
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
esp_err_t handler_wasserzaehler(httpd_req_t *req)
|
esp_err_t handler_wasserzaehler(httpd_req_t *req)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
LogFile.WriteHeapInfo("handler_wasserzaehler - Start");
|
LogFile.WriteHeapInfo("handler_wasserzaehler - Start");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool _rawValue = false;
|
if (FlowInitDone)
|
||||||
bool _noerror = false;
|
|
||||||
bool _all = false;
|
|
||||||
std::string _type = "value";
|
|
||||||
string zw;
|
|
||||||
|
|
||||||
ESP_LOGD(TAG, "handler_wasserzaehler uri: %s", req->uri);
|
|
||||||
|
|
||||||
char _query[100];
|
|
||||||
char _size[10];
|
|
||||||
|
|
||||||
if (httpd_req_get_url_query_str(req, _query, 100) == ESP_OK)
|
|
||||||
{
|
{
|
||||||
// ESP_LOGD(TAG, "Query: %s", _query);
|
bool _rawValue = false;
|
||||||
if (httpd_query_key_value(_query, "all", _size, 10) == ESP_OK)
|
bool _noerror = false;
|
||||||
|
bool _all = false;
|
||||||
|
std::string _type = "value";
|
||||||
|
string zw;
|
||||||
|
|
||||||
|
ESP_LOGD(TAG, "handler_wasserzaehler uri: %s", req->uri);
|
||||||
|
|
||||||
|
char _query[100];
|
||||||
|
char _size[10];
|
||||||
|
|
||||||
|
if (httpd_req_get_url_query_str(req, _query, 100) == ESP_OK)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
// ESP_LOGD(TAG, "Query: %s", _query);
|
||||||
ESP_LOGD(TAG, "all is found%s", _size);
|
if (httpd_query_key_value(_query, "all", _size, 10) == ESP_OK)
|
||||||
#endif
|
{
|
||||||
_all = true;
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
ESP_LOGD(TAG, "all is found%s", _size);
|
||||||
|
#endif
|
||||||
|
_all = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (httpd_query_key_value(_query, "type", _size, 10) == ESP_OK)
|
||||||
|
{
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
ESP_LOGD(TAG, "all is found: %s", _size);
|
||||||
|
#endif
|
||||||
|
_type = std::string(_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (httpd_query_key_value(_query, "rawvalue", _size, 10) == ESP_OK)
|
||||||
|
{
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
ESP_LOGD(TAG, "rawvalue is found: %s", _size);
|
||||||
|
#endif
|
||||||
|
_rawValue = true;
|
||||||
|
}
|
||||||
|
if (httpd_query_key_value(_query, "noerror", _size, 10) == ESP_OK)
|
||||||
|
{
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
ESP_LOGD(TAG, "noerror is found: %s", _size);
|
||||||
|
#endif
|
||||||
|
_noerror = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (httpd_query_key_value(_query, "type", _size, 10) == ESP_OK)
|
httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*");
|
||||||
|
|
||||||
|
if (_all)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
httpd_resp_set_type(req, "text/plain");
|
||||||
ESP_LOGD(TAG, "all is found: %s", _size);
|
ESP_LOGD(TAG, "TYPE: %s", _type.c_str());
|
||||||
#endif
|
int _intype = READOUT_TYPE_VALUE;
|
||||||
_type = std::string(_size);
|
if (_type == "prevalue")
|
||||||
|
_intype = READOUT_TYPE_PREVALUE;
|
||||||
|
if (_type == "raw")
|
||||||
|
_intype = READOUT_TYPE_RAWVALUE;
|
||||||
|
if (_type == "error")
|
||||||
|
_intype = READOUT_TYPE_ERROR;
|
||||||
|
|
||||||
|
|
||||||
|
zw = tfliteflow.getReadoutAll(_intype);
|
||||||
|
ESP_LOGD(TAG, "ZW: %s", zw.c_str());
|
||||||
|
if (zw.length() > 0)
|
||||||
|
httpd_resp_sendstr_chunk(req, zw.c_str());
|
||||||
|
httpd_resp_sendstr_chunk(req, NULL);
|
||||||
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (httpd_query_key_value(_query, "rawvalue", _size, 10) == ESP_OK)
|
zw = tfliteflow.getReadout(_rawValue, _noerror);
|
||||||
{
|
|
||||||
#ifdef DEBUG_DETAIL_ON
|
|
||||||
ESP_LOGD(TAG, "rawvalue is found: %s", _size);
|
|
||||||
#endif
|
|
||||||
_rawValue = true;
|
|
||||||
}
|
|
||||||
if (httpd_query_key_value(_query, "noerror", _size, 10) == ESP_OK)
|
|
||||||
{
|
|
||||||
#ifdef DEBUG_DETAIL_ON
|
|
||||||
ESP_LOGD(TAG, "noerror is found: %s", _size);
|
|
||||||
#endif
|
|
||||||
_noerror = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*");
|
|
||||||
|
|
||||||
if (_all)
|
|
||||||
{
|
|
||||||
httpd_resp_set_type(req, "text/plain");
|
|
||||||
ESP_LOGD(TAG, "TYPE: %s", _type.c_str());
|
|
||||||
int _intype = READOUT_TYPE_VALUE;
|
|
||||||
if (_type == "prevalue")
|
|
||||||
_intype = READOUT_TYPE_PREVALUE;
|
|
||||||
if (_type == "raw")
|
|
||||||
_intype = READOUT_TYPE_RAWVALUE;
|
|
||||||
if (_type == "error")
|
|
||||||
_intype = READOUT_TYPE_ERROR;
|
|
||||||
|
|
||||||
|
|
||||||
zw = tfliteflow.getReadoutAll(_intype);
|
|
||||||
ESP_LOGD(TAG, "ZW: %s", zw.c_str());
|
|
||||||
if (zw.length() > 0)
|
if (zw.length() > 0)
|
||||||
httpd_resp_sendstr_chunk(req, zw.c_str());
|
httpd_resp_sendstr_chunk(req, zw.c_str());
|
||||||
httpd_resp_sendstr_chunk(req, NULL);
|
|
||||||
return ESP_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
zw = tfliteflow.getReadout(_rawValue, _noerror);
|
string query = std::string(_query);
|
||||||
if (zw.length() > 0)
|
// ESP_LOGD(TAG, "Query: %s, query.c_str());
|
||||||
httpd_resp_sendstr_chunk(req, zw.c_str());
|
if (query.find("full") != std::string::npos)
|
||||||
|
|
||||||
string query = std::string(_query);
|
|
||||||
// ESP_LOGD(TAG, "Query: %s, query.c_str());
|
|
||||||
if (query.find("full") != std::string::npos)
|
|
||||||
{
|
|
||||||
string txt, zw;
|
|
||||||
|
|
||||||
txt = "<p>Aligned Image: <p><img src=\"/img_tmp/alg_roi.jpg\"> <p>\n";
|
|
||||||
txt = txt + "Digital Counter: <p> ";
|
|
||||||
httpd_resp_sendstr_chunk(req, txt.c_str());
|
|
||||||
|
|
||||||
std::vector<HTMLInfo*> htmlinfodig;
|
|
||||||
htmlinfodig = tfliteflow.GetAllDigital();
|
|
||||||
|
|
||||||
for (int i = 0; i < htmlinfodig.size(); ++i)
|
|
||||||
{
|
{
|
||||||
if (tfliteflow.GetTypeDigital() == Digital)
|
string txt, zw;
|
||||||
{
|
|
||||||
if (htmlinfodig[i]->val == 10)
|
|
||||||
zw = "NaN";
|
|
||||||
else
|
|
||||||
zw = to_string((int) htmlinfodig[i]->val);
|
|
||||||
|
|
||||||
txt = "<img src=\"/img_tmp/" + htmlinfodig[i]->filename + "\"> " + zw;
|
txt = "<p>Aligned Image: <p><img src=\"/img_tmp/alg_roi.jpg\"> <p>\n";
|
||||||
|
txt = txt + "Digital Counter: <p> ";
|
||||||
|
httpd_resp_sendstr_chunk(req, txt.c_str());
|
||||||
|
|
||||||
|
std::vector<HTMLInfo*> htmlinfodig;
|
||||||
|
htmlinfodig = tfliteflow.GetAllDigital();
|
||||||
|
|
||||||
|
for (int i = 0; i < htmlinfodig.size(); ++i)
|
||||||
|
{
|
||||||
|
if (tfliteflow.GetTypeDigital() == Digital)
|
||||||
|
{
|
||||||
|
if (htmlinfodig[i]->val == 10)
|
||||||
|
zw = "NaN";
|
||||||
|
else
|
||||||
|
zw = to_string((int) htmlinfodig[i]->val);
|
||||||
|
|
||||||
|
txt = "<img src=\"/img_tmp/" + htmlinfodig[i]->filename + "\"> " + zw;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::stringstream stream;
|
||||||
|
stream << std::fixed << std::setprecision(1) << htmlinfodig[i]->val;
|
||||||
|
zw = stream.str();
|
||||||
|
|
||||||
|
txt = "<img src=\"/img_tmp/" + htmlinfodig[i]->filename + "\"> " + zw;
|
||||||
|
}
|
||||||
|
httpd_resp_sendstr_chunk(req, txt.c_str());
|
||||||
|
delete htmlinfodig[i];
|
||||||
}
|
}
|
||||||
else
|
htmlinfodig.clear();
|
||||||
|
|
||||||
|
txt = " <p> Analog Meter: <p> ";
|
||||||
|
httpd_resp_sendstr_chunk(req, txt.c_str());
|
||||||
|
|
||||||
|
std::vector<HTMLInfo*> htmlinfoana;
|
||||||
|
htmlinfoana = tfliteflow.GetAllAnalog();
|
||||||
|
for (int i = 0; i < htmlinfoana.size(); ++i)
|
||||||
{
|
{
|
||||||
std::stringstream stream;
|
std::stringstream stream;
|
||||||
stream << std::fixed << std::setprecision(1) << htmlinfodig[i]->val;
|
stream << std::fixed << std::setprecision(1) << htmlinfoana[i]->val;
|
||||||
zw = stream.str();
|
zw = stream.str();
|
||||||
|
|
||||||
txt = "<img src=\"/img_tmp/" + htmlinfodig[i]->filename + "\"> " + zw;
|
txt = "<img src=\"/img_tmp/" + htmlinfoana[i]->filename + "\"> " + zw;
|
||||||
|
httpd_resp_sendstr_chunk(req, txt.c_str());
|
||||||
|
delete htmlinfoana[i];
|
||||||
}
|
}
|
||||||
httpd_resp_sendstr_chunk(req, txt.c_str());
|
htmlinfoana.clear();
|
||||||
delete htmlinfodig[i];
|
|
||||||
}
|
}
|
||||||
htmlinfodig.clear();
|
|
||||||
|
|
||||||
txt = " <p> Analog Meter: <p> ";
|
|
||||||
httpd_resp_sendstr_chunk(req, txt.c_str());
|
|
||||||
|
|
||||||
std::vector<HTMLInfo*> htmlinfoana;
|
|
||||||
htmlinfoana = tfliteflow.GetAllAnalog();
|
|
||||||
for (int i = 0; i < htmlinfoana.size(); ++i)
|
|
||||||
{
|
|
||||||
std::stringstream stream;
|
|
||||||
stream << std::fixed << std::setprecision(1) << htmlinfoana[i]->val;
|
|
||||||
zw = stream.str();
|
|
||||||
|
|
||||||
txt = "<img src=\"/img_tmp/" + htmlinfoana[i]->filename + "\"> " + zw;
|
|
||||||
httpd_resp_sendstr_chunk(req, txt.c_str());
|
|
||||||
delete htmlinfoana[i];
|
|
||||||
}
|
|
||||||
htmlinfoana.clear();
|
|
||||||
|
|
||||||
|
/* 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
|
||||||
|
LogFile.WriteHeapInfo("handler_wasserzaehler - Done");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* Respond with an empty chunk to signal HTTP response completion */
|
|
||||||
httpd_resp_sendstr_chunk(req, NULL);
|
|
||||||
|
|
||||||
#ifdef DEBUG_DETAIL_ON
|
|
||||||
LogFile.WriteHeapInfo("handler_wasserzaehler - Done");
|
|
||||||
#endif
|
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
esp_err_t handler_editflow(httpd_req_t *req)
|
esp_err_t handler_editflow(httpd_req_t *req)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
LogFile.WriteHeapInfo("handler_editflow - Start");
|
LogFile.WriteHeapInfo("handler_editflow - Start");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ESP_LOGD(TAG, "handler_editflow uri: %s", req->uri);
|
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)
|
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);
|
ESP_LOGD(TAG, "task is found: %s", _valuechar);
|
||||||
#endif
|
#endif
|
||||||
_task = string(_valuechar);
|
_task = string(_valuechar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -427,10 +441,10 @@ esp_err_t handler_editflow(httpd_req_t *req)
|
|||||||
httpd_query_key_value(_query, "out", _valuechar, 30);
|
httpd_query_key_value(_query, "out", _valuechar, 30);
|
||||||
out = string(_valuechar);
|
out = string(_valuechar);
|
||||||
|
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
ESP_LOGD(TAG, "in: %s", in.c_str());
|
ESP_LOGD(TAG, "in: %s", in.c_str());
|
||||||
ESP_LOGD(TAG, "out: %s", out.c_str());
|
ESP_LOGD(TAG, "out: %s", out.c_str());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
in = "/sdcard" + in;
|
in = "/sdcard" + in;
|
||||||
out = "/sdcard" + out;
|
out = "/sdcard" + out;
|
||||||
@@ -469,14 +483,14 @@ esp_err_t handler_editflow(httpd_req_t *req)
|
|||||||
zw = string(_valuechar);
|
zw = string(_valuechar);
|
||||||
dy = stoi(zw);
|
dy = stoi(zw);
|
||||||
|
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
ESP_LOGD(TAG, "in: %s", in.c_str());
|
ESP_LOGD(TAG, "in: %s", in.c_str());
|
||||||
ESP_LOGD(TAG, "out: %s", out.c_str());
|
ESP_LOGD(TAG, "out: %s", out.c_str());
|
||||||
ESP_LOGD(TAG, "x: %s", zw.c_str());
|
ESP_LOGD(TAG, "x: %s", zw.c_str());
|
||||||
ESP_LOGD(TAG, "y: %s", zw.c_str());
|
ESP_LOGD(TAG, "y: %s", zw.c_str());
|
||||||
ESP_LOGD(TAG, "dx: %s", zw.c_str());
|
ESP_LOGD(TAG, "dx: %s", zw.c_str());
|
||||||
ESP_LOGD(TAG, "dy: %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)
|
if (httpd_query_key_value(_query, "enhance", _valuechar, 10) == ESP_OK)
|
||||||
{
|
{
|
||||||
@@ -570,46 +584,55 @@ esp_err_t handler_editflow(httpd_req_t *req)
|
|||||||
/* Respond with an empty chunk to signal HTTP response completion */
|
/* Respond with an empty chunk to signal HTTP response completion */
|
||||||
httpd_resp_sendstr_chunk(req, NULL);
|
httpd_resp_sendstr_chunk(req, NULL);
|
||||||
|
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
LogFile.WriteHeapInfo("handler_editflow - Done");
|
LogFile.WriteHeapInfo("handler_editflow - Done");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
esp_err_t handler_statusflow(httpd_req_t *req)
|
esp_err_t handler_statusflow(httpd_req_t *req)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
LogFile.WriteHeapInfo("handler_prevalue - Start");
|
LogFile.WriteHeapInfo("handler_prevalue - Start");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const char* resp_str;
|
if (FlowInitDone)
|
||||||
|
{
|
||||||
|
const char* resp_str;
|
||||||
|
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
ESP_LOGD(TAG, "handler_prevalue: %s", req->uri);
|
ESP_LOGD(TAG, "handler_prevalue: %s", req->uri);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
string* zw = tfliteflow.getActStatus();
|
string* zw = tfliteflow.getActStatus();
|
||||||
resp_str = zw->c_str();
|
resp_str = zw->c_str();
|
||||||
|
|
||||||
httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*");
|
httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*");
|
||||||
httpd_resp_send(req, resp_str, strlen(resp_str));
|
httpd_resp_send(req, resp_str, strlen(resp_str));
|
||||||
/* Respond with an empty chunk to signal HTTP response completion */
|
/* Respond with an empty chunk to signal HTTP response completion */
|
||||||
httpd_resp_send_chunk(req, NULL, 0);
|
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
|
#ifdef DEBUG_DETAIL_ON
|
||||||
LogFile.WriteHeapInfo("handler_prevalue - Start");
|
LogFile.WriteHeapInfo("handler_prevalue - Done");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
esp_err_t handler_cputemp(httpd_req_t *req)
|
esp_err_t handler_cputemp(httpd_req_t *req)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
LogFile.WriteHeapInfo("handler_cputemp - Start");
|
LogFile.WriteHeapInfo("handler_cputemp - Start");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const char* resp_str;
|
const char* resp_str;
|
||||||
char cputemp[20];
|
char cputemp[20];
|
||||||
@@ -623,37 +646,46 @@ esp_err_t handler_cputemp(httpd_req_t *req)
|
|||||||
/* Respond with an empty chunk to signal HTTP response completion */
|
/* Respond with an empty chunk to signal HTTP response completion */
|
||||||
httpd_resp_send_chunk(req, NULL, 0);
|
httpd_resp_send_chunk(req, NULL, 0);
|
||||||
|
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
LogFile.WriteHeapInfo("handler_cputemp - End");
|
LogFile.WriteHeapInfo("handler_cputemp - End");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
esp_err_t handler_rssi(httpd_req_t *req)
|
esp_err_t handler_rssi(httpd_req_t *req)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
LogFile.WriteHeapInfo("handler_rssi - Start");
|
LogFile.WriteHeapInfo("handler_rssi - Start");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const char* resp_str;
|
if (getWIFIisConnected())
|
||||||
char rssi[20];
|
{
|
||||||
|
const char* resp_str;
|
||||||
|
char rssi[20];
|
||||||
|
|
||||||
sprintf(rssi, "%idBm", get_WIFI_RSSI());
|
sprintf(rssi, "%idBm", get_WIFI_RSSI());
|
||||||
|
|
||||||
resp_str = rssi;
|
resp_str = rssi;
|
||||||
|
|
||||||
httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*");
|
httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*");
|
||||||
httpd_resp_send(req, resp_str, strlen(resp_str));
|
httpd_resp_send(req, resp_str, strlen(resp_str));
|
||||||
/* Respond with an empty chunk to signal HTTP response completion */
|
/* Respond with an empty chunk to signal HTTP response completion */
|
||||||
httpd_resp_send_chunk(req, NULL, 0);
|
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");
|
LogFile.WriteHeapInfo("handler_rssi - End");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
esp_err_t handler_uptime(httpd_req_t *req)
|
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)
|
esp_err_t handler_prevalue(httpd_req_t *req)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
LogFile.WriteHeapInfo("handler_prevalue - Start");
|
LogFile.WriteHeapInfo("handler_prevalue - Start");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const char* resp_str;
|
const char* resp_str;
|
||||||
string zw;
|
string zw;
|
||||||
|
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
ESP_LOGD(TAG, "handler_prevalue: %s", req->uri);
|
ESP_LOGD(TAG, "handler_prevalue: %s", req->uri);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
char _query[100];
|
char _query[100];
|
||||||
char _size[10] = "";
|
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)
|
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);
|
ESP_LOGD(TAG, "Query: %s", _query);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (httpd_query_key_value(_query, "value", _size, 10) == ESP_OK)
|
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);
|
ESP_LOGD(TAG, "Value: %s", _size);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
httpd_query_key_value(_query, "numbers", _numbers, 50);
|
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 */
|
/* Respond with an empty chunk to signal HTTP response completion */
|
||||||
httpd_resp_send_chunk(req, NULL, 0);
|
httpd_resp_send_chunk(req, NULL, 0);
|
||||||
|
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
LogFile.WriteHeapInfo("handler_prevalue - End");
|
LogFile.WriteHeapInfo("handler_prevalue - End");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
void task_autodoFlow(void *pvParameter)
|
void task_autodoFlow(void *pvParameter)
|
||||||
{
|
{
|
||||||
@@ -768,20 +801,20 @@ void task_autodoFlow(void *pvParameter)
|
|||||||
|
|
||||||
if (flowisrunning)
|
if (flowisrunning)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
ESP_LOGD(TAG, "Autoflow: doFlow is already running!");
|
ESP_LOGD(TAG, "Autoflow: doFlow is already running!");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
ESP_LOGD(TAG, "Autoflow: doFlow is started");
|
ESP_LOGD(TAG, "Autoflow: doFlow is started");
|
||||||
#endif
|
#endif
|
||||||
flowisrunning = true;
|
flowisrunning = true;
|
||||||
doflow();
|
doflow();
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
ESP_LOGD(TAG, "Remove older log files");
|
ESP_LOGD(TAG, "Remove older log files");
|
||||||
#endif
|
#endif
|
||||||
LogFile.RemoveOldLogFile();
|
LogFile.RemoveOldLogFile();
|
||||||
LogFile.RemoveOldDataLog();
|
LogFile.RemoveOldDataLog();
|
||||||
}
|
}
|
||||||
@@ -808,6 +841,7 @@ void task_autodoFlow(void *pvParameter)
|
|||||||
ESP_LOGD(TAG, "task_autodoFlow: end");
|
ESP_LOGD(TAG, "task_autodoFlow: end");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TFliteDoAutoStart()
|
void TFliteDoAutoStart()
|
||||||
{
|
{
|
||||||
BaseType_t xReturned;
|
BaseType_t xReturned;
|
||||||
@@ -825,10 +859,9 @@ void TFliteDoAutoStart()
|
|||||||
ESP_LOGD(TAG, "ERROR task_autodoFlow konnte nicht erzeugt werden!");
|
ESP_LOGD(TAG, "ERROR task_autodoFlow konnte nicht erzeugt werden!");
|
||||||
}
|
}
|
||||||
ESP_LOGD(TAG, "getESPHeapInfo: %s", getESPHeapInfo().c_str());
|
ESP_LOGD(TAG, "getESPHeapInfo: %s", getESPHeapInfo().c_str());
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef ENABLE_MQTT
|
#ifdef ENABLE_MQTT
|
||||||
std::string GetMQTTMainTopic()
|
std::string GetMQTTMainTopic()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user