Skip to content

Commit

Permalink
Merge branch 'rolling'
Browse files Browse the repository at this point in the history
  • Loading branch information
jomjol committed Jul 22, 2023
2 parents cbd14a2 + 28cabea commit 3fbff0a
Show file tree
Hide file tree
Showing 69 changed files with 4,189 additions and 2,672 deletions.
16 changes: 16 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
## [15.3.0] - 2023-07-22

### Changes

For a full list of changes see [Full list of changes](https://github.com/jomjol/AI-on-the-edge-device/compare/v15.2.1...v15.2.4)

#### Changed

- Updated PlatformIO to `6.3.2`
- Updated analog tflite files
- ana-cont_1207_s2_q.tflite
- dig-cont_0620_s3_q.tflite




## [15.2.4] - 2023-05-02

### Changes
Expand Down
74 changes: 47 additions & 27 deletions code/components/jomjol_fileserver_ota/server_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,8 @@ static esp_err_t upload_post_handler(httpd_req_t *req)

/* Close file upon upload completion */
fclose(fd);
ESP_LOGI(TAG, "File reception complete");
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "File saved: " + string(filename));
ESP_LOGI(TAG, "File reception completed");

std::string directory = std::string(filepath);
size_t zw = directory.find("/");
Expand All @@ -736,21 +737,27 @@ static esp_err_t upload_post_handler(httpd_req_t *req)
// ESP_LOGD(TAG, "Directory danach 2: %s", directory.c_str());

/* Redirect onto root to see the updated file list */
httpd_resp_set_status(req, "303 See Other");
httpd_resp_set_hdr(req, "Location", directory.c_str());
if (strcmp(filename, "/config/config.ini") == 0 ||
strcmp(filename, "/config/ref0.jpg") == 0 ||
strcmp(filename, "/config/ref0_org.jpg") == 0 ||
strcmp(filename, "/config/ref1.jpg") == 0 ||
strcmp(filename, "/config/ref1_org.jpg") == 0 ||
strcmp(filename, "/config/reference.jpg") == 0 ||
strcmp(filename, "/img_tmp/ref0.jpg") == 0 ||
strcmp(filename, "/img_tmp/ref0_org.jpg") == 0 ||
strcmp(filename, "/img_tmp/ref1.jpg") == 0 ||
strcmp(filename, "/img_tmp/ref1_org.jpg") == 0 ||
strcmp(filename, "/img_tmp/reference.jpg") == 0 )
{
httpd_resp_set_status(req, HTTPD_200); // Avoid reloading of folder content
}
else {
httpd_resp_set_status(req, "303 See Other"); // Reload folder content after upload
}

/* Redirect onto root to see the updated file list */
httpd_resp_set_status(req, "303 See Other");
httpd_resp_set_hdr(req, "Location", directory.c_str());
httpd_resp_sendstr(req, "File uploaded successfully");

/*
if (strcmp(filepath, CONFIG_FILE) == 0) {
ESP_LOGD(TAG, "New config found. Reload handler.");
gpio_handler_deinit();
MQTTdestroy();
}
*/

return ESP_OK;
}
Expand Down Expand Up @@ -837,16 +844,15 @@ static esp_err_t delete_post_handler(httpd_req_t *req)
return ESP_FAIL;
}

if (stat(filepath, &file_stat) == -1) {
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "File does not exist: " + string(filename));
/* Respond with 400 Bad Request */
httpd_resp_send_err(req, HTTPD_400_BAD_REQUEST, "File does not exist");
return ESP_FAIL;
if (stat(filepath, &file_stat) == -1) { // File does not exist
/* This is ok, we would delete it anyway */
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "File does not exist: " + string(filename));
}

LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Deleting file: " + string(filename));
/* Delete file */
unlink(filepath);
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "File deleted: " + string(filename));
ESP_LOGI(TAG, "File deletion completed");

directory = std::string(filepath);
size_t zw = directory.find("/");
Expand All @@ -863,16 +869,30 @@ static esp_err_t delete_post_handler(httpd_req_t *req)
directory = directory.substr(start_fn, found - start_fn + 1);
directory = "/fileserver" + directory;
ESP_LOGD(TAG, "Directory danach 4: %s", directory.c_str());
}

//////////////////////////////////////////////////////////////

/* Redirect onto root to see the updated file list */
if (strcmp(filename, "/config/config.ini") == 0 ||
strcmp(filename, "/config/ref0.jpg") == 0 ||
strcmp(filename, "/config/ref0_org.jpg") == 0 ||
strcmp(filename, "/config/ref1.jpg") == 0 ||
strcmp(filename, "/config/ref1_org.jpg") == 0 ||
strcmp(filename, "/config/reference.jpg") == 0 ||
strcmp(filename, "/img_tmp/ref0.jpg") == 0 ||
strcmp(filename, "/img_tmp/ref0_org.jpg") == 0 ||
strcmp(filename, "/img_tmp/ref1.jpg") == 0 ||
strcmp(filename, "/img_tmp/ref1_org.jpg") == 0 ||
strcmp(filename, "/img_tmp/reference.jpg") == 0 )
{
httpd_resp_set_status(req, HTTPD_200); // Avoid reloading of folder content
}
else {
httpd_resp_set_status(req, "303 See Other"); // Reload folder content after upload
}
}



//////////////////////////////////////////////////////////////

/* Redirect onto root to see the updated file list */
httpd_resp_set_status(req, "303 See Other");
httpd_resp_set_hdr(req, "Location", directory.c_str());
httpd_resp_sendstr(req, "File successfully deleted");
return ESP_OK;
Expand Down Expand Up @@ -929,7 +949,7 @@ std::string unzip_new(std::string _in_zip_file, std::string _target_zip, std::st

// Get and print information about each file in the archive.
int numberoffiles = (int)mz_zip_reader_get_num_files(&zip_archive);
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Numbers of files to be extracted: " + to_string(numberoffiles));
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Files to be extracted: " + to_string(numberoffiles));

sort_iter = 0;
{
Expand Down Expand Up @@ -993,7 +1013,7 @@ std::string unzip_new(std::string _in_zip_file, std::string _target_zip, std::st

string filename_zw = zw + SUFFIX_ZW;

ESP_LOGI(TAG, "Filename to extract: %s, Zwischenfilename: %s", zw.c_str(), filename_zw.c_str());
ESP_LOGI(TAG, "File to extract: %s, Temp. Filename: %s", zw.c_str(), filename_zw.c_str());

std::string folder = filename_zw.substr(0, filename_zw.find_last_of('/'));
MakeDir(folder);
Expand Down Expand Up @@ -1097,7 +1117,7 @@ void unzip(std::string _in_zip_file, std::string _target_directory){
// Save to File.
zw = std::string(archive_filename);
zw = _target_directory + zw;
ESP_LOGD(TAG, "Filename to extract: %s", zw.c_str());
ESP_LOGD(TAG, "File to extract: %s", zw.c_str());
FILE* fpTargetFile = fopen(zw.c_str(), "wb");
fwrite(p, 1, (uint)uncomp_size, fpTargetFile);
fclose(fpTargetFile);
Expand Down
8 changes: 7 additions & 1 deletion code/components/jomjol_fileserver_ota/server_help.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,13 @@ esp_err_t send_file(httpd_req_t *req, std::string filename)
endsWith(filename, ".jpeg") ||
endsWith(filename, ".ico") ||
endsWith(filename, ".png")) {
httpd_resp_set_hdr(req, "Cache-Control", "max-age=86400");

if (filename == "/sdcard/html/setup.html") {
httpd_resp_set_hdr(req, "Clear-Site-Data", "\"*\"");
}
else {
httpd_resp_set_hdr(req, "Cache-Control", "max-age=86400");
}
}

set_content_type_from_file(req, filename.c_str());
Expand Down
11 changes: 5 additions & 6 deletions code/components/jomjol_flowcontroll/ClassFlowCNNGeneral.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ string ClassFlowCNNGeneral::getReadout(int _analog = 0, bool _extendedResolution
// LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "getReadout(analog) number=" + std::to_string(number) + ", result_after_decimal_point=" + std::to_string(result_after_decimal_point) + ", prev=" + std::to_string(prev));
result = std::to_string(prev);

if (_extendedResolution && (CNNType != Digital))
if (_extendedResolution)
result = result + std::to_string(result_after_decimal_point);

for (int i = GENERAL[_analog]->ROI.size() - 2; i >= 0; --i)
Expand Down Expand Up @@ -142,11 +142,10 @@ int ClassFlowCNNGeneral::PointerEvalHybridNew(float number, float number_of_pred
int result_before_decimal_point = ((int) floor(number) + 10) % 10;

if (eval_predecessors < 0)
{
if ((result_after_decimal_point <= Digital_Uncertainty * 10) || (result_after_decimal_point >= Digital_Uncertainty * 10)) // Band around the digit --> Rounding, as digit reaches inaccuracy in the frame
result = (int) (round(number) + 10) % 10;
else
result = (int) ((int) trunc(number) + 10) % 10;
{
// on first digit is no spezial logic for transition needed
// we use the recognition as given. The result is the int value of the recognition
result = (int) ((int) trunc(number) + 10) % 10;

LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "PointerEvalHybridNew - No predecessor - Result = " + std::to_string(result) +
" number: " + std::to_string(number) + " number_of_predecessors = " + std::to_string(number_of_predecessors)+ " eval_predecessors = " + std::to_string(eval_predecessors) + " Digital_Uncertainty = " + std::to_string(Digital_Uncertainty));
Expand Down
3 changes: 2 additions & 1 deletion code/components/jomjol_flowcontroll/ClassFlowControll.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,14 @@ class ClassFlowControll :

bool AutoStart;
float AutoInterval;
bool SetupModeActive;
void SetInitialParameter(void);
std::string aktstatusWithTime;
std::string aktstatus;
int aktRunNr;

public:
bool SetupModeActive;

void InitFlow(std::string config);
bool doFlow(string time);
void doFlowTakeImageOnly(string time);
Expand Down
12 changes: 6 additions & 6 deletions code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -866,12 +866,12 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "handleAllowNegativeRate for device: " + NUMBERS[j]->name);
if ((NUMBERS[j]->Value < NUMBERS[j]->PreValue))
{
#ifdef SERIAL_DEBUG
ESP_LOGD(TAG, "Neg: value=%f, preValue=%f, preToll%f", NUMBERS[j]->Value, NUMBERS[j]->PreValue,
NUMBERS[j]->PreValue-(2/pow(10, NUMBERS[j]->Nachkomma))
) ;
#endif

// more debug if extended resolution is on, see #2447
if (NUMBERS[j]->isExtendedResolution) {
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "Neg: value=" + std::to_string(NUMBERS[j]->Value)
+ ", preValue=" + std::to_string(NUMBERS[j]->PreValue)
+ ", preToll=" + std::to_string(NUMBERS[j]->PreValue-(2/pow(10, NUMBERS[j]->Nachkomma))));
}
// Include inaccuracy of 0.2 for isExtendedResolution.
if (NUMBERS[j]->Value >= (NUMBERS[j]->PreValue-(2/pow(10, NUMBERS[j]->Nachkomma))) && NUMBERS[j]->isExtendedResolution) {
NUMBERS[j]->Value = NUMBERS[j]->PreValue;
Expand Down
21 changes: 7 additions & 14 deletions code/components/jomjol_flowcontroll/MainFlowControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ esp_err_t handler_stream(httpd_req_t *req)
if (httpd_query_key_value(_query, "flashlight", _value, 10) == ESP_OK)
{
#ifdef DEBUG_DETAIL_ON
ESP_LOGD(TAG, "flashlight is found%s", _size);
ESP_LOGD(TAG, "flashlight is found%s", _value);
#endif
if (strlen(_value) > 0)
flashlightOn = true;
Expand Down Expand Up @@ -453,7 +453,7 @@ esp_err_t handler_wasserzaehler(httpd_req_t *req)
else {
/* Digital ROIs */
txt = "<body style=\"font-family: arial\">";
txt += "<h3>Recognized Digit ROIs (previous round)</h3>\n";
txt += "<hr><h3>Recognized Digit ROIs (previous round)</h3>\n";
txt += "<table style=\"border-spacing: 5px\"><tr style=\"text-align: center; vertical-align: top;\">\n";

std::vector<HTMLInfo*> htmlinfodig;
Expand Down Expand Up @@ -488,7 +488,7 @@ esp_err_t handler_wasserzaehler(httpd_req_t *req)


/* Analog ROIs */
txt = "<h3>Recognized Analog ROIs (previous round)</h3>\n";
txt = "<hr><h3>Recognized Analog ROIs (previous round)</h3>\n";
txt += "<table style=\"border-spacing: 5px\"><tr style=\"text-align: center; vertical-align: top;\">\n";

std::vector<HTMLInfo*> htmlinfoana;
Expand All @@ -510,7 +510,7 @@ esp_err_t handler_wasserzaehler(httpd_req_t *req)

/* Full Image
* Only show it after the image got taken and aligned */
txt = "<h3>Aligned Image (current round)</h3>\n";
txt = "<hr><h3>Aligned Image (current round)</h3>\n";
if ((*status == std::string("Initialization")) ||
(*status == std::string("Initialization (delayed)")) ||
(*status == std::string("Take Image"))) {
Expand Down Expand Up @@ -657,14 +657,7 @@ esp_err_t handler_editflow(httpd_req_t *req)

string out2 = out.substr(0, out.length() - 4) + "_org.jpg";

std::string state = *flowctrl.getActStatus();

/* To be able to provide the image, several conditions must be met due to the shared PSRAM usage:
- Ether the round most be completed or not started yet
- Or we must be in Setup Mode
- Additionally, the initialization of the shared PSRAM must be successful */
if (((state == "Flow finished") || (state == "Initialization") || (state == "Initialization (delayed)") || isSetupModusActive()) &&
psram_init_shared_memory_for_take_image_step()) {
if ((flowctrl.SetupModeActive || (*flowctrl.getActStatus() == "Flow finished")) && psram_init_shared_memory_for_take_image_step()) {
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Taking image for Alignment Mark Update...");

CAlignAndCutImage *caic = new CAlignAndCutImage("cutref", in);
Expand All @@ -687,7 +680,7 @@ esp_err_t handler_editflow(httpd_req_t *req)
}
else {
LogFile.WriteToFile(ESP_LOG_WARN, TAG, std::string("Taking image for Alignment Mark not possible while device") +
" is busy with a round (Current State: '" + state + "')!");
" is busy with a round (Current State: '" + *flowctrl.getActStatus() + "')!");
zw = "Device Busy";
}

Expand Down Expand Up @@ -897,7 +890,7 @@ esp_err_t handler_prevalue(httpd_req_t *req)

if (httpd_query_key_value(_query, "value", _value, 20) == ESP_OK) {
#ifdef DEBUG_DETAIL_ON
ESP_LOGD(TAG, "Value: %s", _size);
ESP_LOGD(TAG, "Value: %s", _value);
#endif
}
}
Expand Down
2 changes: 1 addition & 1 deletion code/components/jomjol_influxdb/interface_influxdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ static esp_err_t http_event_handler(esp_http_client_event_t *evt)
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "HTTP Client Error encountered");
break;
case HTTP_EVENT_ON_CONNECTED:
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "HTTP Client Error encountered");
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "HTTP Client connected");
ESP_LOGI(TAG, "HTTP Client Connected");
break;
case HTTP_EVENT_HEADERS_SENT:
Expand Down
5 changes: 5 additions & 0 deletions code/components/jomjol_mqtt/interface_mqtt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
#include "cJSON.h"
#include "../../include/defines.h"

#if DEBUG_DETAIL_ON
#include "esp_timer.h"
#endif


static const char *TAG = "MQTT IF";

std::map<std::string, std::function<void()>>* connectFunktionMap = NULL;
Expand Down
2 changes: 2 additions & 0 deletions code/components/jomjol_wlan/read_wlanini.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,12 @@ int LoadWlanFromFile(std::string fn)
}

/* Check if password is empty (mandatory parameter) */
/* Disabled see issue #2393
if (wlan_config.password.empty()) {
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Password empty. Device init aborted!");
return -2;
}
*/

return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion code/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

[common:esp32-idf]
extends = common:idf
platform = platformio/espressif32 @ 6.2.0
platform = platformio/espressif32 @ 6.3.2
framework = espidf
lib_deps =
${common:idf.lib_deps}
Expand Down
5 changes: 5 additions & 0 deletions code/sdkconfig.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ CONFIG_ESP_INT_WDT_TIMEOUT_MS=300

CONFIG_HTTPD_MAX_REQ_HDR_LEN=1024
CONFIG_HTTPD_PURGE_BUF_LEN=16
<<<<<<< Updated upstream
=======
CONFIG_HTTPD_WS_SUPPORT=y
CONFIG_LWIP_MAX_SOCKETS=12
>>>>>>> Stashed changes

CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=16
CONFIG_ESP32_WIFI_CACHE_TX_BUFFER_NUM=16
Expand Down
Binary file modified images/Flowstate_initialization.xcf
Binary file not shown.
Binary file modified images/Flowstate_initialization_delayed.xcf
Binary file not shown.
Binary file modified images/Flowstate_take_image.xcf
Binary file not shown.
Binary file added images/icon/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed sd-card/config/ana-class100_0157_s1_q.tflite
Binary file not shown.
Binary file added sd-card/config/ana-class100_0169_s1_q.tflite
Binary file not shown.
Binary file added sd-card/config/ana-class100_0170_s1_q.tflite
Binary file not shown.
Binary file removed sd-card/config/ana-cont_1105_s2_q.tflite
Binary file not shown.
Binary file added sd-card/config/ana-cont_1206_s2_q.tflite
Binary file not shown.
Binary file added sd-card/config/ana-cont_1207_s2_q.tflite
Binary file not shown.
8 changes: 4 additions & 4 deletions sd-card/config/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ FixedExposure = false
Demo = false

[Alignment]
InitialRotate = 179
InitialRotate = 0.0
InitialMirror = false
SearchFieldX = 20
SearchFieldY = 20
Expand All @@ -22,7 +22,7 @@ FlipImageSize = false
/config/ref1.jpg 442 142

[Digits]
Model = /config/dig-cont_0611_s3_q.tflite
Model = /config/dig-cont_0620_s3_q.tflite
CNNGoodThreshold = 0.5
;ROIImagesLocation = /log/digit
;ROIImagesRetention = 3
Expand All @@ -31,7 +31,7 @@ main.dig2 343 126 30 54 false
main.dig3 391 126 30 54 false

[Analog]
Model = /config/ana-cont_1105_s2_q.tflite
Model = /config/ana-cont_1207_s2_q.tflite
CNNGoodThreshold = 0.5
;ROIImagesLocation = /log/analog
;ROIImagesRetention = 3
Expand Down Expand Up @@ -106,6 +106,6 @@ LogfilesRetention = 3
TimeZone = CET-1CEST,M3.5.0,M10.5.0/3
;TimeServer = pool.ntp.org
;Hostname = undefined
;RSSIThreshold = 0
RSSIThreshold = -75
CPUFrequency = 160
SetupMode = true
Binary file added sd-card/config/dig-class100-0165_s2_q.tflite
Binary file not shown.
Binary file removed sd-card/config/dig-class100_0160_s2_q.tflite
Binary file not shown.
Binary file removed sd-card/config/dig-cont_0611_s3.tflite
Binary file not shown.
Binary file added sd-card/config/dig-cont_0620_s3_q.tflite
Binary file not shown.
Binary file modified sd-card/html/Flowstate_initialization.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified sd-card/html/Flowstate_initialization_delayed.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified sd-card/html/Flowstate_take_image.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 3fbff0a

Please sign in to comment.