mirror of
https://github.com/jomjol/AI-on-the-edge-device.git
synced 2025-12-08 12:36:52 +03:00
Update ClassFlowControll.cpp
fix .gz in GetJPGStream(std::string _fn, httpd_req_t *req)
This commit is contained in:
@@ -33,46 +33,52 @@ static const char* TAG = "FLOWCTRL";
|
|||||||
|
|
||||||
//#define DEBUG_DETAIL_ON
|
//#define DEBUG_DETAIL_ON
|
||||||
|
|
||||||
std::string ClassFlowControll::doSingleStep(std::string _stepname, std::string _host){
|
std::string ClassFlowControll::doSingleStep(std::string _stepname, std::string _host)
|
||||||
|
{
|
||||||
std::string _classname = "";
|
std::string _classname = "";
|
||||||
std::string result = "";
|
std::string result = "";
|
||||||
|
|
||||||
ESP_LOGD(TAG, "Step %s start", _stepname.c_str());
|
ESP_LOGD(TAG, "Step %s start", _stepname.c_str());
|
||||||
|
|
||||||
if ((_stepname.compare("[TakeImage]") == 0) || (_stepname.compare(";[TakeImage]") == 0)){
|
if ((_stepname.compare("[TakeImage]") == 0) || (_stepname.compare(";[TakeImage]") == 0)) {
|
||||||
_classname = "ClassFlowTakeImage";
|
_classname = "ClassFlowTakeImage";
|
||||||
}
|
}
|
||||||
if ((_stepname.compare("[Alignment]") == 0) || (_stepname.compare(";[Alignment]") == 0)){
|
|
||||||
|
if ((_stepname.compare("[Alignment]") == 0) || (_stepname.compare(";[Alignment]") == 0)) {
|
||||||
_classname = "ClassFlowAlignment";
|
_classname = "ClassFlowAlignment";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((_stepname.compare(0, 7, "[Digits") == 0) || (_stepname.compare(0, 8, ";[Digits") == 0)) {
|
if ((_stepname.compare(0, 7, "[Digits") == 0) || (_stepname.compare(0, 8, ";[Digits") == 0)) {
|
||||||
_classname = "ClassFlowCNNGeneral";
|
_classname = "ClassFlowCNNGeneral";
|
||||||
}
|
}
|
||||||
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
|
#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
|
#endif //ENABLE_MQTT
|
||||||
|
|
||||||
#ifdef ENABLE_INFLUXDB
|
#ifdef ENABLE_INFLUXDB
|
||||||
if ((_stepname.compare("[InfluxDB]") == 0) || (_stepname.compare(";[InfluxDB]") == 0)){
|
if ((_stepname.compare("[InfluxDB]") == 0) || (_stepname.compare(";[InfluxDB]") == 0)) {
|
||||||
_classname = "ClassFlowInfluxDB";
|
_classname = "ClassFlowInfluxDB";
|
||||||
}
|
}
|
||||||
if ((_stepname.compare("[InfluxDBv2]") == 0) || (_stepname.compare(";[InfluxDBv2]") == 0)){
|
if ((_stepname.compare("[InfluxDBv2]") == 0) || (_stepname.compare(";[InfluxDBv2]") == 0)) {
|
||||||
_classname = "ClassFlowInfluxDBv2";
|
_classname = "ClassFlowInfluxDBv2";
|
||||||
}
|
}
|
||||||
#endif //ENABLE_INFLUXDB
|
#endif //ENABLE_INFLUXDB
|
||||||
|
|
||||||
#ifdef ENABLE_WEBHOOK
|
#ifdef ENABLE_WEBHOOK
|
||||||
if ((_stepname.compare("[Webhook]") == 0) || (_stepname.compare(";[Webhook]") == 0)){
|
if ((_stepname.compare("[Webhook]") == 0) || (_stepname.compare(";[Webhook]") == 0)) {
|
||||||
_classname = "ClassFlowWebhook";
|
_classname = "ClassFlowWebhook";
|
||||||
}
|
}
|
||||||
#endif //ENABLE_WEBHOOK
|
#endif //ENABLE_WEBHOOK
|
||||||
|
|
||||||
for (int i = 0; i < FlowControll.size(); ++i)
|
for (int i = 0; i < FlowControll.size(); ++i) {
|
||||||
if (FlowControll[i]->name().compare(_classname) == 0){
|
if (FlowControll[i]->name().compare(_classname) == 0) {
|
||||||
if (!(FlowControll[i]->name().compare("ClassFlowTakeImage") == 0)) {
|
if (!(FlowControll[i]->name().compare("ClassFlowTakeImage") == 0)) {
|
||||||
// if it is a TakeImage, the image does not need to be included, this happens automatically with the html query.
|
// if it is a TakeImage, the image does not need to be included, this happens automatically with the html query.
|
||||||
FlowControll[i]->doFlow("");
|
FlowControll[i]->doFlow("");
|
||||||
@@ -80,6 +86,7 @@ std::string ClassFlowControll::doSingleStep(std::string _stepname, std::string _
|
|||||||
|
|
||||||
result = FlowControll[i]->getHTMLSingleStep(_host);
|
result = FlowControll[i]->getHTMLSingleStep(_host);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ESP_LOGD(TAG, "Step %s end", _stepname.c_str());
|
ESP_LOGD(TAG, "Step %s end", _stepname.c_str());
|
||||||
|
|
||||||
@@ -115,11 +122,13 @@ std::string ClassFlowControll::TranslateAktstatus(std::string _input)
|
|||||||
return ("Sending InfluxDBv2");
|
return ("Sending InfluxDBv2");
|
||||||
}
|
}
|
||||||
#endif //ENABLE_INFLUXDB
|
#endif //ENABLE_INFLUXDB
|
||||||
|
|
||||||
#ifdef ENABLE_WEBHOOK
|
#ifdef ENABLE_WEBHOOK
|
||||||
if (_input.compare("ClassFlowWebhook") == 0) {
|
if (_input.compare("ClassFlowWebhook") == 0) {
|
||||||
return ("Sending Webhook");
|
return ("Sending Webhook");
|
||||||
}
|
}
|
||||||
#endif //ENABLE_WEBHOOK
|
#endif //ENABLE_WEBHOOK
|
||||||
|
|
||||||
if (_input.compare("ClassFlowPostProcessing") == 0) {
|
if (_input.compare("ClassFlowPostProcessing") == 0) {
|
||||||
return ("Post-Processing");
|
return ("Post-Processing");
|
||||||
}
|
}
|
||||||
@@ -224,7 +233,6 @@ void ClassFlowControll::setAutoStartInterval(long &_interval)
|
|||||||
ClassFlow* ClassFlowControll::CreateClassFlow(std::string _type)
|
ClassFlow* ClassFlowControll::CreateClassFlow(std::string _type)
|
||||||
{
|
{
|
||||||
ClassFlow* cfc = NULL;
|
ClassFlow* cfc = NULL;
|
||||||
|
|
||||||
_type = trim(_type);
|
_type = trim(_type);
|
||||||
|
|
||||||
if (toUpper(_type).compare("[TAKEIMAGE]") == 0) {
|
if (toUpper(_type).compare("[TAKEIMAGE]") == 0) {
|
||||||
@@ -262,9 +270,11 @@ ClassFlow* ClassFlowControll::CreateClassFlow(std::string _type)
|
|||||||
cfc = new ClassFlowInfluxDBv2(&FlowControll);
|
cfc = new ClassFlowInfluxDBv2(&FlowControll);
|
||||||
}
|
}
|
||||||
#endif //ENABLE_INFLUXDB
|
#endif //ENABLE_INFLUXDB
|
||||||
|
|
||||||
#ifdef ENABLE_WEBHOOK
|
#ifdef ENABLE_WEBHOOK
|
||||||
if (toUpper(_type).compare("[WEBHOOK]") == 0)
|
if (toUpper(_type).compare("[WEBHOOK]") == 0) {
|
||||||
cfc = new ClassFlowWebhook(&FlowControll);
|
cfc = new ClassFlowWebhook(&FlowControll);
|
||||||
|
}
|
||||||
#endif //ENABLE_WEBHOOK
|
#endif //ENABLE_WEBHOOK
|
||||||
|
|
||||||
if (toUpper(_type).compare("[POSTPROCESSING]") == 0) {
|
if (toUpper(_type).compare("[POSTPROCESSING]") == 0) {
|
||||||
@@ -411,7 +421,7 @@ bool ClassFlowControll::doFlow(string time)
|
|||||||
LogFile.WriteHeapInfo(zw);
|
LogFile.WriteHeapInfo(zw);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!FlowControll[i]->doFlow(time)){
|
if (!FlowControll[i]->doFlow(time)) {
|
||||||
repeat++;
|
repeat++;
|
||||||
LogFile.WriteToFile(ESP_LOG_WARN, TAG, "Fehler im vorheriger Schritt - wird zum " + to_string(repeat) + ". Mal wiederholt");
|
LogFile.WriteToFile(ESP_LOG_WARN, TAG, "Fehler im vorheriger Schritt - wird zum " + to_string(repeat) + ". Mal wiederholt");
|
||||||
if (i) { i -= 1; } // vPrevious step must be repeated (probably take pictures)
|
if (i) { i -= 1; } // vPrevious step must be repeated (probably take pictures)
|
||||||
@@ -512,7 +522,7 @@ bool ClassFlowControll::UpdatePrevalue(std::string _newvalue, std::string _numbe
|
|||||||
char* p;
|
char* p;
|
||||||
|
|
||||||
_newvalue = trim(_newvalue);
|
_newvalue = trim(_newvalue);
|
||||||
//ESP_LOGD(TAG, "Input UpdatePreValue: %s", _newvalue.c_str());
|
// ESP_LOGD(TAG, "Input UpdatePreValue: %s", _newvalue.c_str());
|
||||||
|
|
||||||
if (_newvalue.substr(0,8).compare("0.000000") == 0 || _newvalue.compare("0.0") == 0 || _newvalue.compare("0") == 0) {
|
if (_newvalue.substr(0,8).compare("0.000000") == 0 || _newvalue.compare("0.0") == 0 || _newvalue.compare("0") == 0) {
|
||||||
newvalueAsDouble = 0; // preset to value = 0
|
newvalueAsDouble = 0; // preset to value = 0
|
||||||
@@ -542,7 +552,6 @@ bool ClassFlowControll::UpdatePrevalue(std::string _newvalue, std::string _numbe
|
|||||||
bool ClassFlowControll::ReadParameter(FILE* pfile, string& aktparamgraph)
|
bool ClassFlowControll::ReadParameter(FILE* pfile, string& aktparamgraph)
|
||||||
{
|
{
|
||||||
std::vector<string> splitted;
|
std::vector<string> splitted;
|
||||||
|
|
||||||
aktparamgraph = trim(aktparamgraph);
|
aktparamgraph = trim(aktparamgraph);
|
||||||
|
|
||||||
if (aktparamgraph.size() == 0) {
|
if (aktparamgraph.size() == 0) {
|
||||||
@@ -561,8 +570,7 @@ bool ClassFlowControll::ReadParameter(FILE* pfile, string& aktparamgraph)
|
|||||||
splitted = ZerlegeZeile(aktparamgraph, " =");
|
splitted = ZerlegeZeile(aktparamgraph, " =");
|
||||||
|
|
||||||
if ((toUpper(splitted[0]) == "INTERVAL") && (splitted.size() > 1)) {
|
if ((toUpper(splitted[0]) == "INTERVAL") && (splitted.size() > 1)) {
|
||||||
if (isStringNumeric(splitted[1]))
|
if (isStringNumeric(splitted[1])) {
|
||||||
{
|
|
||||||
AutoInterval = std::stof(splitted[1]);
|
AutoInterval = std::stof(splitted[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -572,8 +580,7 @@ bool ClassFlowControll::ReadParameter(FILE* pfile, string& aktparamgraph)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((toUpper(splitted[0]) == "DATAFILESRETENTION") && (splitted.size() > 1)) {
|
if ((toUpper(splitted[0]) == "DATAFILESRETENTION") && (splitted.size() > 1)) {
|
||||||
if (isStringNumeric(splitted[1]))
|
if (isStringNumeric(splitted[1])) {
|
||||||
{
|
|
||||||
LogFile.SetDataLogRetention(std::stoi(splitted[1]));
|
LogFile.SetDataLogRetention(std::stoi(splitted[1]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -600,8 +607,7 @@ bool ClassFlowControll::ReadParameter(FILE* pfile, string& aktparamgraph)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((toUpper(splitted[0]) == "LOGFILESRETENTION") && (splitted.size() > 1)) {
|
if ((toUpper(splitted[0]) == "LOGFILESRETENTION") && (splitted.size() > 1)) {
|
||||||
if (isStringNumeric(splitted[1]))
|
if (isStringNumeric(splitted[1])) {
|
||||||
{
|
|
||||||
LogFile.SetLogFileRetention(std::stoi(splitted[1]));
|
LogFile.SetLogFileRetention(std::stoi(splitted[1]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -702,6 +708,9 @@ esp_err_t ClassFlowControll::GetJPGStream(std::string _fn, httpd_req_t *req)
|
|||||||
else if (_fn == "alg_roi.jpg") {
|
else if (_fn == "alg_roi.jpg") {
|
||||||
#ifdef ALGROI_LOAD_FROM_MEM_AS_JPG // no CImageBasis needed to create alg_roi.jpg (ca. 790kB less RAM)
|
#ifdef ALGROI_LOAD_FROM_MEM_AS_JPG // no CImageBasis needed to create alg_roi.jpg (ca. 790kB less RAM)
|
||||||
if (aktstatus.find("Initialization (delayed)") != -1) {
|
if (aktstatus.find("Initialization (delayed)") != -1) {
|
||||||
|
std::string filename = "/sdcard/html/Flowstate_initialization_delayed.jpg";
|
||||||
|
result = send_file(req, filename);
|
||||||
|
/*
|
||||||
FILE* file = fopen("/sdcard/html/Flowstate_initialization_delayed.jpg", "rb");
|
FILE* file = fopen("/sdcard/html/Flowstate_initialization_delayed.jpg", "rb");
|
||||||
|
|
||||||
if (!file) {
|
if (!file) {
|
||||||
@@ -710,8 +719,8 @@ esp_err_t ClassFlowControll::GetJPGStream(std::string _fn, httpd_req_t *req)
|
|||||||
}
|
}
|
||||||
|
|
||||||
fseek(file, 0, SEEK_END);
|
fseek(file, 0, SEEK_END);
|
||||||
long fileSize = ftell(file); /* how long is the file ? */
|
long fileSize = ftell(file); // how long is the file ?
|
||||||
fseek(file, 0, SEEK_SET); /* reset */
|
fseek(file, 0, SEEK_SET); // reset
|
||||||
|
|
||||||
unsigned char* fileBuffer = (unsigned char*) malloc(fileSize);
|
unsigned char* fileBuffer = (unsigned char*) malloc(fileSize);
|
||||||
|
|
||||||
@@ -727,8 +736,12 @@ esp_err_t ClassFlowControll::GetJPGStream(std::string _fn, httpd_req_t *req)
|
|||||||
httpd_resp_set_type(req, "image/jpeg");
|
httpd_resp_set_type(req, "image/jpeg");
|
||||||
result = httpd_resp_send(req, (const char *)fileBuffer, fileSize);
|
result = httpd_resp_send(req, (const char *)fileBuffer, fileSize);
|
||||||
free(fileBuffer);
|
free(fileBuffer);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
else if (aktstatus.find("Initialization") != -1) {
|
else if (aktstatus.find("Initialization") != -1) {
|
||||||
|
std::string filename = "/sdcard/html/Flowstate_initialization.jpg";
|
||||||
|
result = send_file(req, filename);
|
||||||
|
/*
|
||||||
FILE* file = fopen("/sdcard/html/Flowstate_initialization.jpg", "rb");
|
FILE* file = fopen("/sdcard/html/Flowstate_initialization.jpg", "rb");
|
||||||
|
|
||||||
if (!file) {
|
if (!file) {
|
||||||
@@ -737,8 +750,8 @@ esp_err_t ClassFlowControll::GetJPGStream(std::string _fn, httpd_req_t *req)
|
|||||||
}
|
}
|
||||||
|
|
||||||
fseek(file, 0, SEEK_END);
|
fseek(file, 0, SEEK_END);
|
||||||
long fileSize = ftell(file); /* how long is the file ? */
|
long fileSize = ftell(file); // how long is the file ?
|
||||||
fseek(file, 0, SEEK_SET); /* reset */
|
fseek(file, 0, SEEK_SET); // reset
|
||||||
|
|
||||||
unsigned char* fileBuffer = (unsigned char*) malloc(fileSize);
|
unsigned char* fileBuffer = (unsigned char*) malloc(fileSize);
|
||||||
|
|
||||||
@@ -754,9 +767,13 @@ esp_err_t ClassFlowControll::GetJPGStream(std::string _fn, httpd_req_t *req)
|
|||||||
httpd_resp_set_type(req, "image/jpeg");
|
httpd_resp_set_type(req, "image/jpeg");
|
||||||
result = httpd_resp_send(req, (const char *)fileBuffer, fileSize);
|
result = httpd_resp_send(req, (const char *)fileBuffer, fileSize);
|
||||||
free(fileBuffer);
|
free(fileBuffer);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
else if (aktstatus.find("Take Image") != -1) {
|
else if (aktstatus.find("Take Image") != -1) {
|
||||||
if (flowalignment && flowalignment->AlgROI) {
|
if (flowalignment && flowalignment->AlgROI) {
|
||||||
|
std::string filename = "/sdcard/html/Flowstate_take_image.jpg";
|
||||||
|
result = send_file(req, filename);
|
||||||
|
/*
|
||||||
FILE* file = fopen("/sdcard/html/Flowstate_take_image.jpg", "rb");
|
FILE* file = fopen("/sdcard/html/Flowstate_take_image.jpg", "rb");
|
||||||
|
|
||||||
if (!file) {
|
if (!file) {
|
||||||
@@ -765,8 +782,8 @@ esp_err_t ClassFlowControll::GetJPGStream(std::string _fn, httpd_req_t *req)
|
|||||||
}
|
}
|
||||||
|
|
||||||
fseek(file, 0, SEEK_END);
|
fseek(file, 0, SEEK_END);
|
||||||
flowalignment->AlgROI->size = ftell(file); /* how long is the file ? */
|
flowalignment->AlgROI->size = ftell(file); // how long is the file ?
|
||||||
fseek(file, 0, SEEK_SET); /* reset */
|
fseek(file, 0, SEEK_SET); // reset
|
||||||
|
|
||||||
if (flowalignment->AlgROI->size > MAX_JPG_SIZE) {
|
if (flowalignment->AlgROI->size > MAX_JPG_SIZE) {
|
||||||
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "File /sdcard/html/Flowstate_take_image.jpg (" + std::to_string(flowalignment->AlgROI->size) +
|
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "File /sdcard/html/Flowstate_take_image.jpg (" + std::to_string(flowalignment->AlgROI->size) +
|
||||||
@@ -780,6 +797,7 @@ esp_err_t ClassFlowControll::GetJPGStream(std::string _fn, httpd_req_t *req)
|
|||||||
|
|
||||||
httpd_resp_set_type(req, "image/jpeg");
|
httpd_resp_set_type(req, "image/jpeg");
|
||||||
result = httpd_resp_send(req, (const char *)flowalignment->AlgROI->data, flowalignment->AlgROI->size);
|
result = httpd_resp_send(req, (const char *)flowalignment->AlgROI->data, flowalignment->AlgROI->size);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "ClassFlowControll::GetJPGStream: alg_roi.jpg cannot be served -> alg.jpg is going to be served!");
|
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "ClassFlowControll::GetJPGStream: alg_roi.jpg cannot be served -> alg.jpg is going to be served!");
|
||||||
@@ -818,9 +836,9 @@ esp_err_t ClassFlowControll::GetJPGStream(std::string _fn, httpd_req_t *req)
|
|||||||
_send = new CImageBasis("alg_roi", flowalignment->ImageBasis);
|
_send = new CImageBasis("alg_roi", flowalignment->ImageBasis);
|
||||||
|
|
||||||
if (_send->ImageOkay()) {
|
if (_send->ImageOkay()) {
|
||||||
if (flowalignment) flowalignment->DrawRef(_send);
|
if (flowalignment) { flowalignment->DrawRef(_send); }
|
||||||
if (flowdigit) flowdigit->DrawROI(_send);
|
if (flowdigit) { flowdigit->DrawROI(_send); }
|
||||||
if (flowanalog) flowanalog->DrawROI(_send);
|
if (flowanalog) { flowanalog->DrawROI(_send); }
|
||||||
_sendDelete = true; // delete temporary _send element after sending
|
_sendDelete = true; // delete temporary _send element after sending
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -842,41 +860,38 @@ esp_err_t ClassFlowControll::GetJPGStream(std::string _fn, httpd_req_t *req)
|
|||||||
htmlinfo = GetAllDigit();
|
htmlinfo = GetAllDigit();
|
||||||
ESP_LOGD(TAG, "After getClassFlowControll::GetAllDigit");
|
ESP_LOGD(TAG, "After getClassFlowControll::GetAllDigit");
|
||||||
|
|
||||||
for (int i = 0; i < htmlinfo.size(); ++i)
|
for (int i = 0; i < htmlinfo.size(); ++i) {
|
||||||
{
|
if (_fn == htmlinfo[i]->filename) {
|
||||||
if (_fn == htmlinfo[i]->filename)
|
if (htmlinfo[i]->image) {
|
||||||
{
|
|
||||||
if (htmlinfo[i]->image)
|
|
||||||
_send = htmlinfo[i]->image;
|
_send = htmlinfo[i]->image;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (_fn == htmlinfo[i]->filename_org)
|
if (_fn == htmlinfo[i]->filename_org) {
|
||||||
{
|
if (htmlinfo[i]->image_org) {
|
||||||
if (htmlinfo[i]->image_org)
|
|
||||||
_send = htmlinfo[i]->image_org;
|
_send = htmlinfo[i]->image_org;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
delete htmlinfo[i];
|
delete htmlinfo[i];
|
||||||
}
|
}
|
||||||
htmlinfo.clear();
|
htmlinfo.clear();
|
||||||
|
|
||||||
if (!_send)
|
if (!_send) {
|
||||||
{
|
|
||||||
htmlinfo = GetAllAnalog();
|
htmlinfo = GetAllAnalog();
|
||||||
ESP_LOGD(TAG, "After getClassFlowControll::GetAllAnalog");
|
ESP_LOGD(TAG, "After getClassFlowControll::GetAllAnalog");
|
||||||
|
|
||||||
for (int i = 0; i < htmlinfo.size(); ++i)
|
for (int i = 0; i < htmlinfo.size(); ++i) {
|
||||||
{
|
if (_fn == htmlinfo[i]->filename) {
|
||||||
if (_fn == htmlinfo[i]->filename)
|
if (htmlinfo[i]->image) {
|
||||||
{
|
|
||||||
if (htmlinfo[i]->image)
|
|
||||||
_send = htmlinfo[i]->image;
|
_send = htmlinfo[i]->image;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (_fn == htmlinfo[i]->filename_org)
|
if (_fn == htmlinfo[i]->filename_org) {
|
||||||
{
|
if (htmlinfo[i]->image_org) {
|
||||||
if (htmlinfo[i]->image_org)
|
|
||||||
_send = htmlinfo[i]->image_org;
|
_send = htmlinfo[i]->image_org;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
delete htmlinfo[i];
|
delete htmlinfo[i];
|
||||||
}
|
}
|
||||||
htmlinfo.clear();
|
htmlinfo.clear();
|
||||||
@@ -887,17 +902,18 @@ esp_err_t ClassFlowControll::GetJPGStream(std::string _fn, httpd_req_t *req)
|
|||||||
LogFile.WriteHeapInfo("ClassFlowControll::GetJPGStream - before send");
|
LogFile.WriteHeapInfo("ClassFlowControll::GetJPGStream - before send");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (_send)
|
if (_send) {
|
||||||
{
|
|
||||||
ESP_LOGD(TAG, "Sending file: %s ...", _fn.c_str());
|
ESP_LOGD(TAG, "Sending file: %s ...", _fn.c_str());
|
||||||
set_content_type_from_file(req, _fn.c_str());
|
set_content_type_from_file(req, _fn.c_str());
|
||||||
result = _send->SendJPGtoHTTP(req);
|
result = _send->SendJPGtoHTTP(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);
|
||||||
ESP_LOGD(TAG, "File sending complete");
|
ESP_LOGD(TAG, "File sending complete");
|
||||||
|
|
||||||
if (_sendDelete)
|
if (_sendDelete) {
|
||||||
delete _send;
|
delete _send;
|
||||||
|
}
|
||||||
|
|
||||||
_send = NULL;
|
_send = NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user