George Ruinelli 3 anos atrás
pai
commit
a512d82793

+ 4 - 3
code/components/jomjol_configfile/configFile.cpp

@@ -4,8 +4,9 @@
 
 #include "Helper.h"
 #include "configFile.h"
+#include <esp_log.h>
 
-//static const char *TAGCONFIGFILE = "configFile";
+static const char *TAG = "configFile";
 
 ConfigFile::ConfigFile(std::string filePath)
 {
@@ -48,7 +49,7 @@ bool ConfigFile::getNextLine(std::string *rt, bool &disabled, bool &eof)
 
 	if (fgets(zw, 1024, pFile))
 	{
-		printf("%s", zw);
+		ESP_LOGD(TAG, "%s", zw);
 		if ((strlen(zw) == 0) && feof(pFile))
 		{
 			*rt = "";
@@ -67,7 +68,7 @@ bool ConfigFile::getNextLine(std::string *rt, bool &disabled, bool &eof)
 	while ((zw[0] == ';' || zw[0] == '#' || (rt->size() == 0)) && !(zw[1] == '['))			// Kommentarzeilen (; oder #) und Leerzeilen überspringen, es sei denn es ist ein neuer auskommentierter Paragraph
 	{
 		fgets(zw, 1024, pFile);
-		printf("%s", zw);		
+		ESP_LOGD(TAG, "%s", zw);
 		if (feof(pFile))
 		{
 			*rt = "";

+ 7 - 7
code/components/jomjol_controlGPIO/server_GPIO.cpp

@@ -210,10 +210,10 @@ GpioHandler::~GpioHandler()  {
 void GpioHandler::init()
 {
     // TickType_t xDelay = 60000 / portTICK_PERIOD_MS;
-    // printf("wait before start %ldms\r\n", (long) xDelay);
+    // ESP_LOGD(TAG_SERVERGPIO, "wait before start %ldms", (long) xDelay);
     // vTaskDelay( xDelay );
 
-    printf("*************** Start GPIOHandler_Init *****************\n");
+    ESP_LOGD(TAG_SERVERGPIO, "*************** Start GPIOHandler_Init *****************");
 
     if (gpioMap == NULL) {
         gpioMap = new std::map<gpio_num_t, GpioPin*>();
@@ -300,13 +300,13 @@ bool GpioHandler::readConfig()
     bool eof = false;
     gpio_num_t gpioExtLED = (gpio_num_t) 0;
     
-//    printf("readConfig - Start 1\n");
+//    ESP_LOGD(TAG_SERVERGPIO, "readConfig - Start 1");
         
     while ((!configFile.GetNextParagraph(line, disabledLine, eof) || (line.compare("[GPIO]") != 0)) && !eof) {}
     if (eof)
         return false;
 
-//    printf("readConfig - Start 2 line: %s, disabbledLine: %d\n", line.c_str(), (int) disabledLine);
+//    ESP_LOGD(TAG_SERVERGPIO, "readConfig - Start 2 line: %s, disabbledLine: %d", line.c_str(), (int) disabledLine);
 
 
     _isEnabled = !disabledLine;
@@ -314,7 +314,7 @@ bool GpioHandler::readConfig()
     if (!_isEnabled)
         return false;
 
-//    printf("readConfig - Start 3\n");
+//    ESP_LOGD(TAG_SERVERGPIO, "readConfig - Start 3");
 
 //    std::string mainTopicMQTT = "";
     std::string mainTopicMQTT = GetMQTTMainTopic();
@@ -359,7 +359,7 @@ bool GpioHandler::readConfig()
 
             if (pinMode == GPIO_PIN_MODE_EXTERNAL_FLASH_WS281X)
             {
-                printf("Set WS2812 to GPIO %d\n", gpioNr);
+                ESP_LOGD(TAG_SERVERGPIO, "Set WS2812 to GPIO %d", gpioNr);
                 gpioExtLED = gpioNr;
             }
 
@@ -403,7 +403,7 @@ bool GpioHandler::readConfig()
     //     LogFile.WriteToFile("Startsequence 06");      // Nremove
 //        vTaskDelay( xDelay );   
 //        xDelay = 5000 / portTICK_PERIOD_MS;
-//        printf("main: sleep for : %ldms\n", (long) xDelay);
+//        ESP_LOGD(TAG_SERVERGPIO, "main: sleep for: %ldms", (long) xDelay);
 
 //        SmartLed leds( LED_WS2812, 2, GPIO_NUM_12, 0, DoubleBuffer );
 

+ 49 - 47
code/components/jomjol_fileserver_ota/server_file.cpp

@@ -43,6 +43,8 @@ extern "C" {
 #include "Helper.h"
 #include "miniz.h"
 
+static const char *TAG = "server_file";
+
 /* Max length a file path can have on storage */
 // #define FILE_PATH_MAX (ESP_VFS_PATH_MAX + CONFIG_SPIFFS_OBJ_NAME_LEN)
 #define FILE_PATH_MAX (255)
@@ -88,7 +90,7 @@ esp_err_t get_tflite_file_handler(httpd_req_t *req)
     size_t pos = 0;
     
     const char verz_name[] = "/sdcard/config";
-    printf("Suche TFLITE in /sdcard/config/\n");
+    ESP_LOGD(TAG, "Suche TFLITE in /sdcard/config/");
 
     httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*");
     httpd_resp_set_type(req, "text/plain");
@@ -97,7 +99,7 @@ esp_err_t get_tflite_file_handler(httpd_req_t *req)
     while ((entry = readdir(dir)) != NULL) 
     {
         _filename = std::string(entry->d_name);
-        printf("File: %s\t", _filename.c_str());
+        ESP_LOGD(TAG, "File: %s", _filename.c_str());
 
         // ignore all files with starting dot (hidden files)
         if (_filename.rfind(".", 0) == 0) {
@@ -109,7 +111,7 @@ esp_err_t get_tflite_file_handler(httpd_req_t *req)
         if (pos != std::string::npos)
             _fileext = _fileext.erase(0, pos + 1);
 
-        printf(" Extension: %s\n", _fileext.c_str());
+        ESP_LOGD(TAG, " Extension: %s", _fileext.c_str());
 
         if ((_fileext == "tfl") || (_fileext == "tflite"))
         {
@@ -147,11 +149,11 @@ static esp_err_t http_resp_dir_html(httpd_req_t *req, const char *dirpath, const
     DIR *dir = opendir(dirpath_corrected);
 
     const size_t dirpath_len = strlen(dirpath);
-    printf("Dirpath: <%s>, Pathlength: %d\n", dirpath, dirpath_len);    
+    ESP_LOGD(TAG, "Dirpath: <%s>, Pathlength: %d", dirpath, dirpath_len);
 
     /* Retrieve the base path of file storage to construct the full path */
     strlcpy(entrypath, dirpath, sizeof(entrypath));
-    printf("entrypath: <%s>\n", entrypath);    
+    ESP_LOGD(TAG, "entrypath: <%s>", entrypath);
 
     if (!dir) {
         ESP_LOGE(TAG_FILESERVER, "Failed to stat dir : %s", dirpath);
@@ -170,7 +172,7 @@ static esp_err_t http_resp_dir_html(httpd_req_t *req, const char *dirpath, const
         size_t chunksize;
         do {
             chunksize = fread(chunk, 1, SCRATCH_BUFSIZE, fd);
-            //        printf("Chunksize %d\n", chunksize);
+            //        ESP_LOGD(TAG, "Chunksize %d", chunksize);
             if (chunksize > 0){
                 if (httpd_resp_send_chunk(req, chunk, chunksize) != ESP_OK) {
                 fclose(fd);
@@ -211,7 +213,7 @@ static esp_err_t http_resp_dir_html(httpd_req_t *req, const char *dirpath, const
             entrytype = (entry->d_type == DT_DIR ? "directory" : "file");
 
             strlcpy(entrypath + dirpath_len, entry->d_name, sizeof(entrypath) - dirpath_len);
-            printf("Entrypath: %s\n", entrypath);
+            ESP_LOGD(TAG, "Entrypath: %s", entrypath);
             if (stat(entrypath, &entry_stat) == -1) {
                 ESP_LOGE(TAG_FILESERVER, "Failed to stat %s : %s", entrytype, entry->d_name);
                 continue;
@@ -266,11 +268,11 @@ static esp_err_t logfileact_get_handler(httpd_req_t *req)
     char filepath[FILE_PATH_MAX];
     FILE *fd = NULL;
     //struct stat file_stat;
-    printf("uri: %s\n", req->uri);
+    ESP_LOGD(TAG, "uri: %s", req->uri);
 
     const char* filename = "log_current.txt"; 
 
-    printf("uri: %s, filename: %s, filepath: %s\n", req->uri, filename, filepath);
+    ESP_LOGD(TAG, "uri: %s, filename: %s, filepath: %s", req->uri, filename, filepath);
 
     std::string currentfilename = LogFile.GetCurrentFileName();
 
@@ -331,12 +333,12 @@ static esp_err_t download_get_handler(httpd_req_t *req)
     char filepath[FILE_PATH_MAX];
     FILE *fd = NULL;
     struct stat file_stat;
-    printf("uri: %s\n", req->uri);
+    ESP_LOGD(TAG, "uri: %s", req->uri);
 
     const char *filename = get_path_from_uri(filepath, ((struct file_server_data *)req->user_ctx)->base_path,
                                              req->uri  + sizeof("/fileserver") - 1, sizeof(filepath));    
 
-    printf("uri: %s, filename: %s, filepath: %s\n", req->uri, filename, filepath);
+    ESP_LOGD(TAG, "uri: %s, filename: %s, filepath: %s", req->uri, filename, filepath);
 
 //    filename = get_path_from_uri(filepath, ((struct file_server_data *)req->user_ctx)->base_path,
 //                                             req->uri, sizeof(filepath));
@@ -366,7 +368,7 @@ static esp_err_t download_get_handler(httpd_req_t *req)
             }
         }
 
-        printf("uri: %s, filename: %s, filepath: %s\n", req->uri, filename, filepath);
+        ESP_LOGD(TAG, "uri: %s, filename: %s, filepath: %s", req->uri, filename, filepath);
         return http_resp_dir_html(req, filepath, filename, readonly);
     }
 
@@ -541,12 +543,12 @@ static esp_err_t upload_post_handler(httpd_req_t *req)
 	}
 
     int start_fn = strlen(((struct file_server_data *)req->user_ctx)->base_path);
-    printf("Directory: %s, start_fn: %d, found: %d\n", directory.c_str(), start_fn, found);
+    ESP_LOGD(TAG, "Directory: %s, start_fn: %d, found: %d", directory.c_str(), start_fn, found);
 	directory = directory.substr(start_fn, found - start_fn + 1);
-    printf("Directory danach 1: %s\n", directory.c_str());    
+    ESP_LOGD(TAG, "Directory danach 1: %s", directory.c_str());
 
     directory = "/fileserver" + directory;
-    printf("Directory danach 2: %s\n", directory.c_str());   
+    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");
@@ -559,7 +561,7 @@ static esp_err_t upload_post_handler(httpd_req_t *req)
 
 /*
     if (strcmp(filepath, CONFIG_FILE) == 0) {
-        printf("New config found. Reload handler.");
+        ESP_LOGD(TAG, "New config found. Reload handler.");
         gpio_handler_deinit();
         MQTTdestroy();
     }
@@ -586,11 +588,11 @@ static esp_err_t delete_post_handler(httpd_req_t *req)
 
     if (httpd_req_get_url_query_str(req, _query, 200) == ESP_OK)
     {
-        printf("Query: "); printf(_query); printf("\n");
+        ESP_LOGD(TAG, "Query: %s", _query);
         
         if (httpd_query_key_value(_query, "task", _valuechar, 30) == ESP_OK)
         {
-            printf("task is found: "); printf(_valuechar); printf("\n"); 
+            ESP_LOGD(TAG, "task is found: %s", _valuechar);
             _task = std::string(_valuechar);
         }
     }
@@ -610,12 +612,12 @@ static esp_err_t delete_post_handler(httpd_req_t *req)
         zw = zw.substr(0, zw.length()-1);
         directory = "/fileserver" + zw + "/";
         zw = "/sdcard" + zw;
-        printf("Directory to delete: %s\n", zw.c_str());
+        ESP_LOGD(TAG, "Directory to delete: %s", zw.c_str());
 
         delete_all_in_directory(zw);
 //        directory = std::string(filepath);
 //        directory = "/fileserver" + directory;
-        printf("Location after delete directory content: %s\n", directory.c_str());
+        ESP_LOGD(TAG, "Location after delete directory content: %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());
@@ -663,12 +665,12 @@ static esp_err_t delete_post_handler(httpd_req_t *req)
         }
 
         int start_fn = strlen(((struct file_server_data *)req->user_ctx)->base_path);
-        printf("Directory: %s, start_fn: %d, found: %d\n", directory.c_str(), start_fn, found);
+        ESP_LOGD(TAG, "Directory: %s, start_fn: %d, found: %d", directory.c_str(), start_fn, found);
         directory = directory.substr(start_fn, found - start_fn + 1);
-        printf("Directory danach 3: %s\n", directory.c_str());    
+        ESP_LOGD(TAG, "Directory danach 3: %s", directory.c_str());
 
         directory = "/fileserver" + directory;
-        printf("Directory danach 4: %s\n", directory.c_str());   
+        ESP_LOGD(TAG, "Directory danach 4: %s", directory.c_str());
     }
     
 
@@ -722,18 +724,18 @@ std::string unzip_new(std::string _in_zip_file, std::string _target_zip, std::st
     std::string directory = "";
 //    static const char* s_Test_archive_filename = "testhtml.zip";
 
-    printf("miniz.c version: %s\n", MZ_VERSION);
-    printf("Zipfile: %s\n", _in_zip_file.c_str());
-    printf("Target Dir ZIP: %s\n", _target_zip.c_str());
-    printf("Target Dir BIN: %s\n", _target_bin.c_str());
-    printf("Target Dir main: %s\n", _main.c_str());
+    ESP_LOGD(TAG, "miniz.c version: %s", MZ_VERSION);
+    ESP_LOGD(TAG, "Zipfile: %s", _in_zip_file.c_str());
+    ESP_LOGD(TAG, "Target Dir ZIP: %s", _target_zip.c_str());
+    ESP_LOGD(TAG, "Target Dir BIN: %s", _target_bin.c_str());
+    ESP_LOGD(TAG, "Target Dir main: %s", _main.c_str());
 
     // Now try to open the archive.
     memset(&zip_archive, 0, sizeof(zip_archive));
     status = mz_zip_reader_init_file(&zip_archive, _in_zip_file.c_str(), 0);
     if (!status)
     {
-        printf("mz_zip_reader_init_file() failed!\n");
+        ESP_LOGD(TAG, "mz_zip_reader_init_file() failed!");
         return ret;
     }
 
@@ -745,7 +747,7 @@ std::string unzip_new(std::string _in_zip_file, std::string _target_zip, std::st
         status = mz_zip_reader_init_file(&zip_archive, _in_zip_file.c_str(), sort_iter ? MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY : 0);
         if (!status)
         {
-            printf("mz_zip_reader_init_file() failed!\n");
+            ESP_LOGD(TAG, "mz_zip_reader_init_file() failed!");
             return ret;
         }
 
@@ -760,14 +762,14 @@ std::string unzip_new(std::string _in_zip_file, std::string _target_zip, std::st
             p = mz_zip_reader_extract_file_to_heap(&zip_archive, archive_filename, &uncomp_size, 0);
                 if (!p)
                 {
-                    printf("mz_zip_reader_extract_file_to_heap() failed on file %s\n", archive_filename);
+                    ESP_LOGD(TAG, "mz_zip_reader_extract_file_to_heap() failed on file %s", archive_filename);
                     mz_zip_reader_end(&zip_archive);
                     return ret;
                 }
             
                 // Save to File.
                 zw = std::string(archive_filename);
-                printf("Rohfilename: %s\n", zw.c_str());
+                ESP_LOGD(TAG, "Rohfilename: %s", zw.c_str());
 
                 if (getFileType(zw) == "BIN")
                 {
@@ -791,7 +793,7 @@ std::string unzip_new(std::string _in_zip_file, std::string _target_zip, std::st
             
                 string filename_zw = zw + SUFFIX_ZW;
 
-                printf("Filename to extract: %s, Zwischenfilename: %s", zw.c_str(), filename_zw.c_str());
+                ESP_LOGD(TAG, "Filename to extract: %s, Zwischenfilename: %s", zw.c_str(), filename_zw.c_str());
 
                 // extrahieren in zwischendatei
                 DeleteFile(filename_zw);
@@ -803,8 +805,8 @@ std::string unzip_new(std::string _in_zip_file, std::string _target_zip, std::st
                 RenameFile(filename_zw, zw);
                 DeleteFile(filename_zw);
 
-                printf("Successfully extracted file \"%s\", size %u\n", archive_filename, (uint)uncomp_size);
-                //            printf("File data: \"%s\"\n", (const char*)p);
+                ESP_LOGD(TAG, "Successfully extracted file \"%s\", size %u", archive_filename, (uint)uncomp_size);
+                //            ESP_LOGD(TAG, "File data: \"%s\"", (const char*)p);
 
                 // We're done.
                 mz_free(p);
@@ -815,7 +817,7 @@ std::string unzip_new(std::string _in_zip_file, std::string _target_zip, std::st
         mz_zip_reader_end(&zip_archive);
     }
 
-    printf("Success.\n");
+    ESP_LOGD(TAG, "Success.");
     return ret;
 }
 
@@ -829,16 +831,16 @@ void unzip(std::string _in_zip_file, std::string _target_directory){
     std::string zw;
 //    static const char* s_Test_archive_filename = "testhtml.zip";
 
-    printf("miniz.c version: %s\n", MZ_VERSION);
-    printf("Zipfile: %s\n", _in_zip_file.c_str());
-    printf("Target Dir: %s\n", _target_directory.c_str());
+    ESP_LOGD(TAG, "miniz.c version: %s", MZ_VERSION);
+    ESP_LOGD(TAG, "Zipfile: %s", _in_zip_file.c_str());
+    ESP_LOGD(TAG, "Target Dir: %s", _target_directory.c_str());
 
     // Now try to open the archive.
     memset(&zip_archive, 0, sizeof(zip_archive));
     status = mz_zip_reader_init_file(&zip_archive, _in_zip_file.c_str(), 0);
     if (!status)
     {
-        printf("mz_zip_reader_init_file() failed!\n");
+        ESP_LOGD(TAG, "mz_zip_reader_init_file() failed!");
         return;
     }
 
@@ -850,7 +852,7 @@ void unzip(std::string _in_zip_file, std::string _target_directory){
         status = mz_zip_reader_init_file(&zip_archive, _in_zip_file.c_str(), sort_iter ? MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY : 0);
         if (!status)
         {
-            printf("mz_zip_reader_init_file() failed!\n");
+            ESP_LOGD(TAG, "mz_zip_reader_init_file() failed!");
             return;
         }
 
@@ -864,7 +866,7 @@ void unzip(std::string _in_zip_file, std::string _target_directory){
             p = mz_zip_reader_extract_file_to_heap(&zip_archive, archive_filename, &uncomp_size, 0);
             if (!p)
             {
-                printf("mz_zip_reader_extract_file_to_heap() failed!\n");
+                ESP_LOGD(TAG, "mz_zip_reader_extract_file_to_heap() failed!");
                 mz_zip_reader_end(&zip_archive);
                 return;
             }
@@ -872,13 +874,13 @@ void unzip(std::string _in_zip_file, std::string _target_directory){
             // Save to File.
             zw = std::string(archive_filename);
             zw = _target_directory + zw;
-            printf("Filename to extract: %s", zw.c_str());
+            ESP_LOGD(TAG, "Filename to extract: %s", zw.c_str());
             FILE* fpTargetFile = OpenFileAndWait(zw.c_str(), "wb");
             fwrite(p, 1, (uint)uncomp_size, fpTargetFile);
             fclose(fpTargetFile);
 
-            printf("Successfully extracted file \"%s\", size %u\n", archive_filename, (uint)uncomp_size);
-            //            printf("File data: \"%s\"\n", (const char*)p);
+            ESP_LOGD(TAG, "Successfully extracted file \"%s\", size %u", archive_filename, (uint)uncomp_size);
+            //            ESP_LOGD(TAG, "File data: \"%s\"", (const char*)p);
 
             // We're done.
             mz_free(p);
@@ -888,7 +890,7 @@ void unzip(std::string _in_zip_file, std::string _target_directory){
         mz_zip_reader_end(&zip_archive);
     }
 
-    printf("Success.\n");
+    ESP_LOGD(TAG, "Success.");
 }
 
 
@@ -925,7 +927,7 @@ void register_server_file_uri(httpd_handle_t server, const char *base_path)
 //    strcpy(zw, serverprefix);
 //    zw[strlen(serverprefix)] = '*';
 //    zw[strlen(serverprefix)+1] = '\0';    
-//    printf("zw: %s\n", zw);
+//    ESP_LOGD(TAG, "zw: %s", zw);
     httpd_uri_t file_download = {
         .uri       = "/fileserver*",  // Match all URIs of type /path/to/file
         .method    = HTTP_GET,

+ 21 - 26
code/components/jomjol_fileserver_ota/server_ota.cpp

@@ -58,7 +58,7 @@ static void infinite_loop(void)
     int i = 0;
     ESP_LOGI(TAGPARTOTA, "When a new firmware is available on the server, press the reset button to download it");
     while(1) {
-        ESP_LOGI(TAGPARTOTA, "Waiting for a new firmware ... %d", ++i);
+        ESP_LOGI(TAGPARTOTA, "Waiting for a new firmware... %d", ++i);
         vTaskDelay(2000 / portTICK_PERIOD_MS);
     }
 }
@@ -219,8 +219,7 @@ static bool diagnostic(void)
 
 void CheckOTAUpdate(void)
 {
-    ESP_LOGI(TAGPARTOTA, "Start CheckOTAUpdateCheck ...");
-    printf("Start CheckOTAUpdateCheck ...\n");
+    ESP_LOGI(TAGPARTOTA, "Start CheckOTAUpdateCheck...");
 
     uint8_t sha_256[HASH_LEN] = { 0 };
     esp_partition_t partition;
@@ -249,31 +248,29 @@ void CheckOTAUpdate(void)
     switch (res_stat_partition)
     {
         case ESP_OK:
-            printf("CheckOTAUpdate Partition: ESP_OK\n");
+            ESP_LOGD(TAGPARTOTA, "CheckOTAUpdate Partition: ESP_OK");
             if (esp_ota_get_state_partition(running, &ota_state) == ESP_OK) {
                 if (ota_state == ESP_OTA_IMG_PENDING_VERIFY) {
                     // run diagnostic function ...
                     bool diagnostic_is_ok = diagnostic();
                     if (diagnostic_is_ok) {
-                        ESP_LOGI(TAGPARTOTA, "Diagnostics completed successfully! Continuing execution ...");
-                        printf("Diagnostics completed successfully! Continuing execution ...\n");
+                        ESP_LOGI(TAGPARTOTA, "Diagnostics completed successfully! Continuing execution...");
                         esp_ota_mark_app_valid_cancel_rollback();
                     } else {
-                        ESP_LOGE(TAGPARTOTA, "Diagnostics failed! Start rollback to the previous version ...");
-                        printf("Diagnostics failed! Start rollback to the previous version ...\n");
+                        ESP_LOGE(TAGPARTOTA, "Diagnostics failed! Start rollback to the previous version...");
                         esp_ota_mark_app_invalid_rollback_and_reboot();
                     }
                 }
             }            
             break;
         case ESP_ERR_INVALID_ARG:
-            printf("CheckOTAUpdate Partition: ESP_ERR_INVALID_ARG\n");
+            ESP_LOGD(TAGPARTOTA, "CheckOTAUpdate Partition: ESP_ERR_INVALID_ARG");
             break;
         case ESP_ERR_NOT_SUPPORTED:
-            printf("CheckOTAUpdate Partition: ESP_ERR_NOT_SUPPORTED\n");
+            ESP_LOGD(TAGPARTOTA, "CheckOTAUpdate Partition: ESP_ERR_NOT_SUPPORTED");
             break;
         case ESP_ERR_NOT_FOUND:
-            printf("CheckOTAUpdate Partition: ESP_ERR_NOT_FOUND\n");
+            ESP_LOGD(TAGPARTOTA, "CheckOTAUpdate Partition: ESP_ERR_NOT_FOUND");
             break;
     }
     if (esp_ota_get_state_partition(running, &ota_state) == ESP_OK) {
@@ -281,12 +278,10 @@ void CheckOTAUpdate(void)
             // run diagnostic function ...
             bool diagnostic_is_ok = diagnostic();
             if (diagnostic_is_ok) {
-                ESP_LOGI(TAGPARTOTA, "Diagnostics completed successfully! Continuing execution ...");
-                printf("Diagnostics completed successfully! Continuing execution ...\n");
+                ESP_LOGI(TAGPARTOTA, "Diagnostics completed successfully! Continuing execution...");
                 esp_ota_mark_app_valid_cancel_rollback();
             } else {
-                ESP_LOGE(TAGPARTOTA, "Diagnostics failed! Start rollback to the previous version ...");
-                printf("Diagnostics failed! Start rollback to the previous version ...\n");
+                ESP_LOGE(TAGPARTOTA, "Diagnostics failed! Start rollback to the previous version...");
                 esp_ota_mark_app_invalid_rollback_and_reboot();
             }
         }
@@ -311,24 +306,24 @@ esp_err_t handler_ota_update(httpd_req_t *req)
 
     if (httpd_req_get_url_query_str(req, _query, 200) == ESP_OK)
     {
-        printf("Query: "); printf(_query); printf("\n");
+        ESP_LOGD(TAGPARTOTA, "Query: %s", _query);
         
         if (httpd_query_key_value(_query, "task", _valuechar, 30) == ESP_OK)
         {
-            printf("task is found: "); printf(_valuechar); printf("\n"); 
+            ESP_LOGD(TAGPARTOTA, "task is found: %s", _valuechar);
             _task = std::string(_valuechar);
         }
 
         if (httpd_query_key_value(_query, "file", _filename, 100) == ESP_OK)
         {
             fn.append(_filename);
-            printf("File: "); printf(fn.c_str()); printf("\n");            
+            ESP_LOGD(TAGPARTOTA, "File: %s", fn.c_str());
         }
         if (httpd_query_key_value(_query, "delete", _filename, 100) == ESP_OK)
         {
             fn.append(_filename);
             _file_del = true;
-            printf("Delete Default File: "); printf(fn.c_str()); printf("\n");            
+            ESP_LOGD(TAGPARTOTA, "Delete Default File: %s", fn.c_str());
         }
 
     };
@@ -394,7 +389,7 @@ esp_err_t handler_ota_update(httpd_req_t *req)
                 std::string zw = "reboot\n";
                 httpd_resp_sendstr_chunk(req, zw.c_str());
                 httpd_resp_sendstr_chunk(req, NULL);  
-                printf("Send reboot\n");
+                ESP_LOGD(TAGPARTOTA, "Send reboot");
                 return ESP_OK;                
             }
 
@@ -418,7 +413,7 @@ esp_err_t handler_ota_update(httpd_req_t *req)
 
     if (_task.compare("unziphtml") == 0)
     {
-        printf("Task unziphmtl\n");
+        ESP_LOGD(TAGPARTOTA, "Task unziphtml");
         std::string in, out, zw;
 
         in = "/sdcard/firmware/html.zip";
@@ -435,22 +430,22 @@ esp_err_t handler_ota_update(httpd_req_t *req)
 
     if (_file_del)
     {
-        printf("Delete !! _file_del: %s\n", fn.c_str());
+        ESP_LOGD(TAGPARTOTA, "Delete !! _file_del: %s", fn.c_str());
         struct stat file_stat;
         int _result = stat(fn.c_str(), &file_stat);
-        printf("Ergebnis %d\n", _result);
+        ESP_LOGD(TAGPARTOTA, "Ergebnis %d\n", _result);
         if (_result == 0) {
-            printf("Deleting file : %s\n", fn.c_str());
+            ESP_LOGD(TAGPARTOTA, "Deleting file : %s", fn.c_str());
             /* Delete file */
             unlink(fn.c_str());
         }
         else
         {
-            printf("File does not exist: %s\n", fn.c_str());
+            ESP_LOGD(TAGPARTOTA, "File does not exist: %s", fn.c_str());
         }
         /* Respond with an empty chunk to signal HTTP response completion */
         std::string zw = "file deleted\n";
-        printf((zw + "\n").c_str());
+        ESP_LOGD(TAGPARTOTA, "%s", zw.c_str());
         httpd_resp_send(req, zw.c_str(), strlen(zw.c_str()));
         httpd_resp_send_chunk(req, NULL, 0);
         return ESP_OK;

+ 6 - 4
code/components/jomjol_flowcontroll/ClassFlow.cpp

@@ -3,7 +3,9 @@
 #include <string>
 #include <iostream>
 #include <string.h>
+#include "esp_log.h"
 
+static const char *TAG = "class_flow";
 
 
 void ClassFlow::SetInitialParameter(void)
@@ -105,7 +107,7 @@ std::string ClassFlow::GetParameterName(std::string _input)
     {
         _param = _input;
     }
-//    printf("Parameter: %s, Pospunkt: %d\n", _param.c_str(), _pospunkt);
+//    ESP_LOGD(TAG, "Parameter: %s, Pospunkt: %d", _param.c_str(), _pospunkt);
 	return _param;
 }
 
@@ -121,10 +123,10 @@ bool ClassFlow::getNextLine(FILE* pfile, string *rt)
 	if (!fgets(zw, 1024, pfile))
 	{
 		*rt = "";
-		printf("END OF FILE\n");
+		ESP_LOGD(TAG, "END OF FILE");
 		return false;
 	}
-	printf("%s", zw);
+	ESP_LOGD(TAG, "%s", zw);
 	*rt = zw;
 	*rt = trim(*rt);
 	while ((zw[0] == ';' || zw[0] == '#' || (rt->size() == 0)) && !(zw[1] == '['))			// Kommentarzeilen (; oder #) und Leerzeilen überspringen, es sei denn es ist ein neuer auskommentierter Paragraph
@@ -132,7 +134,7 @@ bool ClassFlow::getNextLine(FILE* pfile, string *rt)
 		*rt = "";
 		if (!fgets(zw, 1024, pfile))
 			return false;
-		printf("%s", zw);		
+		ESP_LOGD(TAG, "%s", zw);
 		*rt = zw;
 		*rt = trim(*rt);
 	}

+ 1 - 1
code/components/jomjol_image_proc/CImageBasis.cpp

@@ -29,7 +29,7 @@ uint8_t * CImageBasis::RGBImageLock(int _waitmaxsec)
     if (islocked)
     {
 #ifdef DEBUG_DETAIL_ON   
-        printf("Image is locked: sleep for : %ds\n", _waitmaxsec);
+        ESP_LOGD(TAG, "Image is locked: sleep for: %ds", _waitmaxsec);
 #endif
         TickType_t xDelay;
         xDelay = 1000 / portTICK_PERIOD_MS;

+ 19 - 15
code/components/jomjol_tfliteclass/CTfLiteClass.cpp

@@ -1,11 +1,15 @@
 #include "CTfLiteClass.h"
 #include "ClassLogFile.h"
 #include "Helper.h"
+#include "esp_log.h"
 
 #include <sys/stat.h>
 
 // #define DEBUG_DETAIL_ON
 
+
+static const char *TAG = "ctflite_class";
+
 float CTfLiteClass::GetOutputValue(int nr)
 {
     TfLiteTensor* output2 = this->interpreter->output(0);
@@ -41,7 +45,7 @@ int CTfLiteClass::GetOutClassification(int _von, int _bis)
     return -1;
 
   int numeroutput = output2->dims->data[1];
-  //printf("\n number output neurons: %d\n\n", numeroutput);
+  //ESP_LOGD(TAG, "number output neurons: %d", numeroutput);
 
   if (_bis == -1)
     _bis = numeroutput -1;
@@ -51,7 +55,7 @@ int CTfLiteClass::GetOutClassification(int _von, int _bis)
 
   if (_bis >= numeroutput)
   {
-    printf("ANZAHL OUTPUT NEURONS passt nicht zu geforderter Classifizierung!");
+    ESP_LOGD(TAG, "ANZAHL OUTPUT NEURONS passt nicht zu geforderter Classifizierung!");
     return -1;
   }
 
@@ -74,13 +78,13 @@ void CTfLiteClass::GetInputDimension(bool silent = false)
   TfLiteTensor* input2 = this->interpreter->input(0);
 
   int numdim = input2->dims->size;
-  if (!silent)  printf("NumDimension: %d\n", numdim);  
+  if (!silent)  ESP_LOGD(TAG, "NumDimension: %d", numdim);
 
   int sizeofdim;
   for (int j = 0; j < numdim; ++j)
   {
     sizeofdim = input2->dims->data[j];
-    if (!silent) printf("SizeOfDimension %d: %d\n", j, sizeofdim);  
+    if (!silent) ESP_LOGD(TAG, "SizeOfDimension %d: %d", j, sizeofdim);
     if (j == 1) im_height = sizeofdim;
     if (j == 2) im_width = sizeofdim;
     if (j == 3) im_channel = sizeofdim;
@@ -106,13 +110,13 @@ int CTfLiteClass::GetAnzOutPut(bool silent)
   TfLiteTensor* output2 = this->interpreter->output(0);
 
   int numdim = output2->dims->size;
-  if (!silent) printf("NumDimension: %d\n", numdim);  
+  if (!silent) ESP_LOGD(TAG, "NumDimension: %d", numdim);
 
   int sizeofdim;
   for (int j = 0; j < numdim; ++j)
   {
     sizeofdim = output2->dims->data[j];
-    if (!silent) printf("SizeOfDimension %d: %d\n", j, sizeofdim);  
+    if (!silent) ESP_LOGD(TAG, "SizeOfDimension %d: %d", j, sizeofdim);
   }
 
 
@@ -123,7 +127,7 @@ int CTfLiteClass::GetAnzOutPut(bool silent)
   for (int i = 0; i < numeroutput; ++i)
   {
    fo = output2->data.f[i];
-    if (!silent) printf("Result %d: %f\n", i, fo);  
+    if (!silent) ESP_LOGD(TAG, "Result %d: %f", i, fo);
   }
   return numeroutput;
 }
@@ -143,7 +147,7 @@ bool CTfLiteClass::LoadInputImageBasis(CImageBasis *rs)
     unsigned int w = rs->width;
     unsigned int h = rs->height;
     unsigned char red, green, blue;
-//    printf("Image: %s size: %d x %d\n", _fn.c_str(), w, h);
+//    ESP_LOGD(TAG, "Image: %s size: %d x %d\n", _fn.c_str(), w, h);
 
     input_i = 0;
     float* input_data_ptr = (interpreter->input(0))->data.f;
@@ -174,9 +178,9 @@ void CTfLiteClass::MakeAllocate()
 {
     static tflite::AllOpsResolver resolver;
 
-//    printf(LogFile.getESPHeapInfo().c_str()); printf("\n");
+//    ESP_LOGD(TAG, "%s", LogFile.getESPHeapInfo().c_str());
     this->interpreter = new tflite::MicroInterpreter(this->model, resolver, this->tensor_arena, this->kTensorArenaSize, this->error_reporter);
-//    printf(LogFile.getESPHeapInfo().c_str()); printf("\n");
+//    ESP_LOGD(TAG, "%s", LogFile.getESPHeapInfo().c_str());
 
     TfLiteStatus allocate_status = this->interpreter->AllocateTensors();
     if (allocate_status != kTfLiteOk) {
@@ -186,14 +190,14 @@ void CTfLiteClass::MakeAllocate()
     this->GetInputDimension();   
     return;
   }
-//    printf("Allocate Done.\n");
+//    ESP_LOGD(TAG, "Allocate Done");
 }
 
 void CTfLiteClass::GetInputTensorSize(){
 #ifdef DEBUG_DETAIL_ON    
     float *zw = this->input;
     int test = sizeof(zw);
-    printf("Input Tensor Dimension: %d\n", test);       
+    ESP_LOGD(TAG, "Input Tensor Dimension: %d", test);
 #endif
 }
 
@@ -213,7 +217,7 @@ unsigned char* CTfLiteClass::ReadFileToCharArray(std::string _fn)
 
     if (size == -1)
     {
-  		printf("\nFile doesn't exist.\n");
+      ESP_LOGD(TAG, "File doesn't exist");
       return NULL;
     }
 
@@ -222,7 +226,7 @@ unsigned char* CTfLiteClass::ReadFileToCharArray(std::string _fn)
     while (!result && (anz < 6))    // maximal 5x versuchen (= 5s)
     {
 #ifdef DEBUG_DETAIL_ON      
-		    printf("Speicher ist voll - Versuche es erneut: %d.\n", anz);
+		    ESP_LOGD(TAG, "Speicher ist voll - Versuche es erneut: %d", anz);
 #endif
         result = (unsigned char*) malloc(size);
         anz++;
@@ -234,7 +238,7 @@ unsigned char* CTfLiteClass::ReadFileToCharArray(std::string _fn)
         fread(result, 1, size, f);
         fclose(f);        
 	  }else {
-		  printf("\nNo free memory available.\n");
+		  ESP_LOGD(TAG, "No free memory available");
 	}    
 
 

+ 1 - 1
code/components/jomjol_tfliteclass/server_tflite.cpp

@@ -752,7 +752,7 @@ void task_autodoFlow(void *pvParameter)
         if (auto_intervall > fr_delta_ms)
         {
             const TickType_t xDelay = (auto_intervall - fr_delta_ms)  / portTICK_PERIOD_MS;
-            ESP_LOGD(TAGTFLITE, "Autoflow: sleep for : %ldms", (long) xDelay);
+            ESP_LOGD(TAGTFLITE, "Autoflow: sleep for: %ldms", (long) xDelay);
             vTaskDelay( xDelay );        
         }
     }

+ 3 - 3
code/main/main.cpp

@@ -154,7 +154,7 @@ extern "C" void app_main(void)
     esp_err_t cam = Camera.InitCam();
     Camera.LightOnOff(false);
     xDelay = 2000 / portTICK_PERIOD_MS;
-    ESP_LOGD(TAGMAIN, "After camera initialization: sleep for : %ldms", (long) xDelay);
+    ESP_LOGD(TAGMAIN, "After camera initialization: sleep for: %ldms", (long) xDelay);
     vTaskDelay( xDelay );   
 
 
@@ -194,7 +194,7 @@ extern "C" void app_main(void)
 
 
     xDelay = 2000 / portTICK_PERIOD_MS;
-    ESP_LOGD(TAGMAIN, "main: sleep for : %ldms", (long) xDelay);
+    ESP_LOGD(TAGMAIN, "main: sleep for: %ldms", (long) xDelay);
     vTaskDelay( xDelay );   
     setup_time();
     setBootTime();
@@ -243,7 +243,7 @@ extern "C" void app_main(void)
 
 
     xDelay = 2000 / portTICK_PERIOD_MS;
-    ESP_LOGD(TAGMAIN, "main: sleep for : %ldms", (long) xDelay*10);
+    ESP_LOGD(TAGMAIN, "main: sleep for: %ldms", (long) xDelay*10);
     vTaskDelay( xDelay ); 
 
     ESP_LOGD(TAGMAIN, "starting server");