Skip to content

Commit 3fbff0a

Browse files
committed
Merge branch 'rolling'
2 parents cbd14a2 + 28cabea commit 3fbff0a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+4189
-2672
lines changed

Changelog.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
## [15.3.0] - 2023-07-22
2+
3+
### Changes
4+
5+
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)
6+
7+
#### Changed
8+
9+
- Updated PlatformIO to `6.3.2`
10+
- Updated analog tflite files
11+
- ana-cont_1207_s2_q.tflite
12+
- dig-cont_0620_s3_q.tflite
13+
14+
15+
16+
117
## [15.2.4] - 2023-05-02
218

319
### Changes

code/components/jomjol_fileserver_ota/server_file.cpp

Lines changed: 47 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,8 @@ static esp_err_t upload_post_handler(httpd_req_t *req)
717717

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

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

738739
/* Redirect onto root to see the updated file list */
739-
httpd_resp_set_status(req, "303 See Other");
740-
httpd_resp_set_hdr(req, "Location", directory.c_str());
740+
if (strcmp(filename, "/config/config.ini") == 0 ||
741+
strcmp(filename, "/config/ref0.jpg") == 0 ||
742+
strcmp(filename, "/config/ref0_org.jpg") == 0 ||
743+
strcmp(filename, "/config/ref1.jpg") == 0 ||
744+
strcmp(filename, "/config/ref1_org.jpg") == 0 ||
745+
strcmp(filename, "/config/reference.jpg") == 0 ||
746+
strcmp(filename, "/img_tmp/ref0.jpg") == 0 ||
747+
strcmp(filename, "/img_tmp/ref0_org.jpg") == 0 ||
748+
strcmp(filename, "/img_tmp/ref1.jpg") == 0 ||
749+
strcmp(filename, "/img_tmp/ref1_org.jpg") == 0 ||
750+
strcmp(filename, "/img_tmp/reference.jpg") == 0 )
751+
{
752+
httpd_resp_set_status(req, HTTPD_200); // Avoid reloading of folder content
753+
}
754+
else {
755+
httpd_resp_set_status(req, "303 See Other"); // Reload folder content after upload
756+
}
741757

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

747-
/*
748-
if (strcmp(filepath, CONFIG_FILE) == 0) {
749-
ESP_LOGD(TAG, "New config found. Reload handler.");
750-
gpio_handler_deinit();
751-
MQTTdestroy();
752-
}
753-
*/
754761

755762
return ESP_OK;
756763
}
@@ -837,16 +844,15 @@ static esp_err_t delete_post_handler(httpd_req_t *req)
837844
return ESP_FAIL;
838845
}
839846

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

847-
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Deleting file: " + string(filename));
848852
/* Delete file */
849853
unlink(filepath);
854+
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "File deleted: " + string(filename));
855+
ESP_LOGI(TAG, "File deletion completed");
850856

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

873+
//////////////////////////////////////////////////////////////
868874

875+
/* Redirect onto root to see the updated file list */
876+
if (strcmp(filename, "/config/config.ini") == 0 ||
877+
strcmp(filename, "/config/ref0.jpg") == 0 ||
878+
strcmp(filename, "/config/ref0_org.jpg") == 0 ||
879+
strcmp(filename, "/config/ref1.jpg") == 0 ||
880+
strcmp(filename, "/config/ref1_org.jpg") == 0 ||
881+
strcmp(filename, "/config/reference.jpg") == 0 ||
882+
strcmp(filename, "/img_tmp/ref0.jpg") == 0 ||
883+
strcmp(filename, "/img_tmp/ref0_org.jpg") == 0 ||
884+
strcmp(filename, "/img_tmp/ref1.jpg") == 0 ||
885+
strcmp(filename, "/img_tmp/ref1_org.jpg") == 0 ||
886+
strcmp(filename, "/img_tmp/reference.jpg") == 0 )
887+
{
888+
httpd_resp_set_status(req, HTTPD_200); // Avoid reloading of folder content
889+
}
890+
else {
891+
httpd_resp_set_status(req, "303 See Other"); // Reload folder content after upload
892+
}
893+
}
869894

870895

871-
872-
//////////////////////////////////////////////////////////////
873-
874-
/* Redirect onto root to see the updated file list */
875-
httpd_resp_set_status(req, "303 See Other");
876896
httpd_resp_set_hdr(req, "Location", directory.c_str());
877897
httpd_resp_sendstr(req, "File successfully deleted");
878898
return ESP_OK;
@@ -929,7 +949,7 @@ std::string unzip_new(std::string _in_zip_file, std::string _target_zip, std::st
929949

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

934954
sort_iter = 0;
935955
{
@@ -993,7 +1013,7 @@ std::string unzip_new(std::string _in_zip_file, std::string _target_zip, std::st
9931013

9941014
string filename_zw = zw + SUFFIX_ZW;
9951015

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

9981018
std::string folder = filename_zw.substr(0, filename_zw.find_last_of('/'));
9991019
MakeDir(folder);
@@ -1097,7 +1117,7 @@ void unzip(std::string _in_zip_file, std::string _target_directory){
10971117
// Save to File.
10981118
zw = std::string(archive_filename);
10991119
zw = _target_directory + zw;
1100-
ESP_LOGD(TAG, "Filename to extract: %s", zw.c_str());
1120+
ESP_LOGD(TAG, "File to extract: %s", zw.c_str());
11011121
FILE* fpTargetFile = fopen(zw.c_str(), "wb");
11021122
fwrite(p, 1, (uint)uncomp_size, fpTargetFile);
11031123
fclose(fpTargetFile);

code/components/jomjol_fileserver_ota/server_help.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,13 @@ esp_err_t send_file(httpd_req_t *req, std::string filename)
6161
endsWith(filename, ".jpeg") ||
6262
endsWith(filename, ".ico") ||
6363
endsWith(filename, ".png")) {
64-
httpd_resp_set_hdr(req, "Cache-Control", "max-age=86400");
64+
65+
if (filename == "/sdcard/html/setup.html") {
66+
httpd_resp_set_hdr(req, "Clear-Site-Data", "\"*\"");
67+
}
68+
else {
69+
httpd_resp_set_hdr(req, "Cache-Control", "max-age=86400");
70+
}
6571
}
6672

6773
set_content_type_from_file(req, filename.c_str());

code/components/jomjol_flowcontroll/ClassFlowCNNGeneral.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ string ClassFlowCNNGeneral::getReadout(int _analog = 0, bool _extendedResolution
5555
// 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));
5656
result = std::to_string(prev);
5757

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

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

144144
if (eval_predecessors < 0)
145-
{
146-
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
147-
result = (int) (round(number) + 10) % 10;
148-
else
149-
result = (int) ((int) trunc(number) + 10) % 10;
145+
{
146+
// on first digit is no spezial logic for transition needed
147+
// we use the recognition as given. The result is the int value of the recognition
148+
result = (int) ((int) trunc(number) + 10) % 10;
150149

151150
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "PointerEvalHybridNew - No predecessor - Result = " + std::to_string(result) +
152151
" 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));

code/components/jomjol_flowcontroll/ClassFlowControll.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,14 @@ class ClassFlowControll :
3434

3535
bool AutoStart;
3636
float AutoInterval;
37-
bool SetupModeActive;
3837
void SetInitialParameter(void);
3938
std::string aktstatusWithTime;
4039
std::string aktstatus;
4140
int aktRunNr;
4241

4342
public:
43+
bool SetupModeActive;
44+
4445
void InitFlow(std::string config);
4546
bool doFlow(string time);
4647
void doFlowTakeImageOnly(string time);

code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -866,12 +866,12 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
866866
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "handleAllowNegativeRate for device: " + NUMBERS[j]->name);
867867
if ((NUMBERS[j]->Value < NUMBERS[j]->PreValue))
868868
{
869-
#ifdef SERIAL_DEBUG
870-
ESP_LOGD(TAG, "Neg: value=%f, preValue=%f, preToll%f", NUMBERS[j]->Value, NUMBERS[j]->PreValue,
871-
NUMBERS[j]->PreValue-(2/pow(10, NUMBERS[j]->Nachkomma))
872-
) ;
873-
#endif
874-
869+
// more debug if extended resolution is on, see #2447
870+
if (NUMBERS[j]->isExtendedResolution) {
871+
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "Neg: value=" + std::to_string(NUMBERS[j]->Value)
872+
+ ", preValue=" + std::to_string(NUMBERS[j]->PreValue)
873+
+ ", preToll=" + std::to_string(NUMBERS[j]->PreValue-(2/pow(10, NUMBERS[j]->Nachkomma))));
874+
}
875875
// Include inaccuracy of 0.2 for isExtendedResolution.
876876
if (NUMBERS[j]->Value >= (NUMBERS[j]->PreValue-(2/pow(10, NUMBERS[j]->Nachkomma))) && NUMBERS[j]->isExtendedResolution) {
877877
NUMBERS[j]->Value = NUMBERS[j]->PreValue;

code/components/jomjol_flowcontroll/MainFlowControl.cpp

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ esp_err_t handler_stream(httpd_req_t *req)
230230
if (httpd_query_key_value(_query, "flashlight", _value, 10) == ESP_OK)
231231
{
232232
#ifdef DEBUG_DETAIL_ON
233-
ESP_LOGD(TAG, "flashlight is found%s", _size);
233+
ESP_LOGD(TAG, "flashlight is found%s", _value);
234234
#endif
235235
if (strlen(_value) > 0)
236236
flashlightOn = true;
@@ -453,7 +453,7 @@ esp_err_t handler_wasserzaehler(httpd_req_t *req)
453453
else {
454454
/* Digital ROIs */
455455
txt = "<body style=\"font-family: arial\">";
456-
txt += "<h3>Recognized Digit ROIs (previous round)</h3>\n";
456+
txt += "<hr><h3>Recognized Digit ROIs (previous round)</h3>\n";
457457
txt += "<table style=\"border-spacing: 5px\"><tr style=\"text-align: center; vertical-align: top;\">\n";
458458

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

489489

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

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

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

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

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

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

@@ -897,7 +890,7 @@ esp_err_t handler_prevalue(httpd_req_t *req)
897890

898891
if (httpd_query_key_value(_query, "value", _value, 20) == ESP_OK) {
899892
#ifdef DEBUG_DETAIL_ON
900-
ESP_LOGD(TAG, "Value: %s", _size);
893+
ESP_LOGD(TAG, "Value: %s", _value);
901894
#endif
902895
}
903896
}

code/components/jomjol_influxdb/interface_influxdb.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ static esp_err_t http_event_handler(esp_http_client_event_t *evt)
116116
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "HTTP Client Error encountered");
117117
break;
118118
case HTTP_EVENT_ON_CONNECTED:
119-
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "HTTP Client Error encountered");
119+
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "HTTP Client connected");
120120
ESP_LOGI(TAG, "HTTP Client Connected");
121121
break;
122122
case HTTP_EVENT_HEADERS_SENT:

code/components/jomjol_mqtt/interface_mqtt.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
#include "cJSON.h"
1010
#include "../../include/defines.h"
1111

12+
#if DEBUG_DETAIL_ON
13+
#include "esp_timer.h"
14+
#endif
15+
16+
1217
static const char *TAG = "MQTT IF";
1318

1419
std::map<std::string, std::function<void()>>* connectFunktionMap = NULL;

code/components/jomjol_wlan/read_wlanini.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,12 @@ int LoadWlanFromFile(std::string fn)
174174
}
175175

176176
/* Check if password is empty (mandatory parameter) */
177+
/* Disabled see issue #2393
177178
if (wlan_config.password.empty()) {
178179
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Password empty. Device init aborted!");
179180
return -2;
180181
}
182+
*/
181183

182184
return 0;
183185
}

0 commit comments

Comments
 (0)