Parcourir la source

Migration of PlatformIO 5.2.0 to 6.1.0 (resp. ESP IDF from 4.4.2 to 5.0.1) (#2305)

* Migration to PlatformIO 6.1.0

* Disable RMTMEM usage as it is no longer allowed -> Smart LEDs not functional!

* moved miniz into subfolder of jomjol_fileserver_ota, else it does not build anymore.

* cleanup

* fix leading NaN (#2310)

* Migration to PlatformIO 6.1.0

* Disable RMTMEM usage as it is no longer allowed -> Smart LEDs not functional!

* moved miniz into subfolder of jomjol_fileserver_ota, else it does not build anymore.

* cleanup

* Task watchdog has new config name

* Fix return value check. It must be something else than ESP_FAIL, but it does not need to be ESP_OK!

* add missing strucures to work around new RMTMEM restriction (untested)

---------

Co-authored-by: CaCO3 <caco@ruinelli.ch>
CaCO3 il y a 2 ans
Parent
commit
17ffd28c05
43 fichiers modifiés avec 183 ajouts et 68 suppressions
  1. 27 0
      code/components/jomjol_controlGPIO/SmartLeds.cpp
  2. 35 0
      code/components/jomjol_controlGPIO/SmartLeds.h
  3. 0 1
      code/components/jomjol_controlGPIO/server_GPIO.cpp
  4. 1 1
      code/components/jomjol_controlcamera/CMakeLists.txt
  5. 16 2
      code/components/jomjol_controlcamera/ClassControllCamera.cpp
  6. 2 2
      code/components/jomjol_fileserver_ota/CMakeLists.txt
  7. 0 0
      code/components/jomjol_fileserver_ota/miniz/ChangeLog.md
  8. 0 0
      code/components/jomjol_fileserver_ota/miniz/LICENSE
  9. 0 0
      code/components/jomjol_fileserver_ota/miniz/examples/example1.c
  10. 0 0
      code/components/jomjol_fileserver_ota/miniz/examples/example2.c
  11. 0 0
      code/components/jomjol_fileserver_ota/miniz/examples/example3.c
  12. 0 0
      code/components/jomjol_fileserver_ota/miniz/examples/example4.c
  13. 0 0
      code/components/jomjol_fileserver_ota/miniz/examples/example5.c
  14. 0 0
      code/components/jomjol_fileserver_ota/miniz/examples/example6.c
  15. 0 0
      code/components/jomjol_fileserver_ota/miniz/miniz.c
  16. 0 0
      code/components/jomjol_fileserver_ota/miniz/miniz.h
  17. 0 0
      code/components/jomjol_fileserver_ota/miniz/readme.md
  18. 0 0
      code/components/jomjol_fileserver_ota/miniz/readme2.md
  19. 0 1
      code/components/jomjol_fileserver_ota/server_file.cpp
  20. 14 6
      code/components/jomjol_fileserver_ota/server_ota.cpp
  21. 1 1
      code/components/jomjol_flowcontroll/CMakeLists.txt
  22. 2 2
      code/components/jomjol_flowcontroll/ClassFlowControll.cpp
  23. 5 0
      code/components/jomjol_flowcontroll/MainFlowControl.cpp
  24. 1 1
      code/components/jomjol_helper/CMakeLists.txt
  25. 2 0
      code/components/jomjol_helper/Helper.cpp
  26. 2 1
      code/components/jomjol_helper/esp_sys.cpp
  27. 2 2
      code/components/jomjol_helper/esp_sys.h
  28. 5 0
      code/components/jomjol_helper/statusled.cpp
  29. 3 0
      code/components/jomjol_influxdb/interface_influxdb.cpp
  30. 1 1
      code/components/jomjol_mqtt/CMakeLists.txt
  31. 17 17
      code/components/jomjol_mqtt/interface_mqtt.cpp
  32. 0 1
      code/components/jomjol_time_sntp/time_sntp.cpp
  33. 0 1
      code/components/jomjol_time_sntp/time_sntp.h
  34. 1 1
      code/components/jomjol_wlan/CMakeLists.txt
  35. 20 6
      code/components/jomjol_wlan/connect_wlan.cpp
  36. 0 6
      code/components/miniz/CMakeLists.txt
  37. 1 1
      code/dependencies.lock
  38. 1 2
      code/main/CMakeLists.txt
  39. 10 6
      code/main/main.cpp
  40. 11 4
      code/main/server_main.cpp
  41. 1 1
      code/main/softAP.cpp
  42. 1 1
      code/platformio.ini
  43. 1 0
      code/sdkconfig.defaults

+ 27 - 0
code/components/jomjol_controlGPIO/SmartLeds.cpp

@@ -1,5 +1,32 @@
 #include "SmartLeds.h"
 #include "SmartLeds.h"
 
 
+
+/* PlatformIO 6 (ESP IDF 5) does no longer allow access to RMTMEM,
+   see https://docs.espressif.com/projects/esp-idf/en/latest/esp32/migration-guides/release-5.x/5.0/peripherals.html?highlight=rmtmem#id5 
+   As a dirty workaround, we copy the needed structures from rmt_struct.h
+   In the long run, this should be replaced! */
+typedef struct rmt_item32_s {
+    union {
+        struct {
+            uint32_t duration0 :15;
+            uint32_t level0 :1;
+            uint32_t duration1 :15;
+            uint32_t level1 :1;
+        };
+        uint32_t val;
+    };
+} rmt_item32_t;
+
+//Allow access to RMT memory using RMTMEM.chan[0].data32[8]
+typedef volatile struct rmt_mem_s {
+    struct {
+        rmt_item32_t data32[64];
+    } chan[8];
+} rmt_mem_t;
+extern rmt_mem_t RMTMEM;
+
+
+
 IsrCore SmartLed::_interruptCore = CoreCurrent;
 IsrCore SmartLed::_interruptCore = CoreCurrent;
 intr_handle_t SmartLed::_interruptHandle = NULL;
 intr_handle_t SmartLed::_interruptHandle = NULL;
 
 

+ 35 - 0
code/components/jomjol_controlGPIO/SmartLeds.h

@@ -35,6 +35,20 @@
 #include <cassert>
 #include <cassert>
 #include <cstring>
 #include <cstring>
 
 
+#include "esp_idf_version.h"
+#if (ESP_IDF_VERSION_MAJOR >= 5)
+#include "soc/periph_defs.h"
+#include "esp_private/periph_ctrl.h"
+#include "soc/gpio_sig_map.h"
+#include "soc/gpio_periph.h"
+#include "soc/io_mux_reg.h"
+#include "esp_rom_gpio.h"
+#define gpio_pad_select_gpio esp_rom_gpio_pad_select_gpio
+#define gpio_matrix_in(a,b,c) esp_rom_gpio_connect_in_signal(a,b,c)
+#define gpio_matrix_out(a,b,c,d) esp_rom_gpio_connect_out_signal(a,b,c,d)
+#define ets_delay_us(a) esp_rom_delay_us(a)
+#endif
+
 #if defined ( ARDUINO )
 #if defined ( ARDUINO )
     extern "C" { // ...someone forgot to put in the includes...
     extern "C" { // ...someone forgot to put in the includes...
         #include "esp32-hal.h"
         #include "esp32-hal.h"
@@ -65,6 +79,27 @@
     #include <stdio.h>
     #include <stdio.h>
 #endif
 #endif
 
 
+#if (ESP_IDF_VERSION_MAJOR >= 4) && (ESP_IDF_VERSION_MINOR > 1)
+#include "hal/gpio_ll.h"
+#else
+#include "soc/gpio_periph.h"
+#define esp_rom_delay_us ets_delay_us
+static inline int gpio_ll_get_level(gpio_dev_t *hw, int gpio_num)
+{
+    if (gpio_num < 32) {
+        return (hw->in >> gpio_num) & 0x1;
+    } else {
+        return (hw->in1.data >> (gpio_num - 32)) & 0x1;
+    }
+}
+#endif
+
+#if (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0))
+#if !(configENABLE_BACKWARD_COMPATIBILITY == 1)
+#define xSemaphoreHandle SemaphoreHandle_t
+#endif
+#endif
+
 #include "Color.h"
 #include "Color.h"
 
 
 namespace detail {
 namespace detail {

+ 0 - 1
code/components/jomjol_controlGPIO/server_GPIO.cpp

@@ -6,7 +6,6 @@
 #include "freertos/FreeRTOS.h"
 #include "freertos/FreeRTOS.h"
 #include "freertos/task.h"
 #include "freertos/task.h"
 #include "esp_system.h"
 #include "esp_system.h"
-#include "esp_event.h"
 
 
 #include "esp_log.h"
 #include "esp_log.h"
 
 

+ 1 - 1
code/components/jomjol_controlcamera/CMakeLists.txt

@@ -4,6 +4,6 @@ list(APPEND EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/proto
 
 
 idf_component_register(SRCS ${app_sources}
 idf_component_register(SRCS ${app_sources}
                     INCLUDE_DIRS "."
                     INCLUDE_DIRS "."
-                    REQUIRES esp32-camera esp_http_server jomjol_logfile jomjol_image_proc nvs_flash jomjol_fileserver_ota jomjol_controlGPIO)
+                    REQUIRES esp_timer esp32-camera esp_http_server jomjol_logfile jomjol_image_proc nvs_flash jomjol_fileserver_ota jomjol_controlGPIO)
 
 
 
 

+ 16 - 2
code/components/jomjol_controlcamera/ClassControllCamera.cpp

@@ -21,6 +21,7 @@
 #include <nvs_flash.h>
 #include <nvs_flash.h>
 #include <sys/param.h>
 #include <sys/param.h>
 #include <string.h>
 #include <string.h>
+#include <sys/stat.h>
 
 
 #include "freertos/FreeRTOS.h"
 #include "freertos/FreeRTOS.h"
 #include "freertos/task.h"
 #include "freertos/task.h"
@@ -30,6 +31,19 @@
 #include "driver/ledc.h"
 #include "driver/ledc.h"
 #include "MainFlowControl.h"
 #include "MainFlowControl.h"
 
 
+#if (ESP_IDF_VERSION_MAJOR >= 5)
+#include "soc/periph_defs.h"
+#include "esp_private/periph_ctrl.h"
+#include "soc/gpio_sig_map.h"
+#include "soc/gpio_periph.h"
+#include "soc/io_mux_reg.h"
+#include "esp_rom_gpio.h"
+#define gpio_pad_select_gpio esp_rom_gpio_pad_select_gpio
+#define gpio_matrix_in(a,b,c) esp_rom_gpio_connect_in_signal(a,b,c)
+#define gpio_matrix_out(a,b,c,d) esp_rom_gpio_connect_out_signal(a,b,c,d)
+#define ets_delay_us(a) esp_rom_delay_us(a)
+#endif
+
 static const char *TAG = "CAM"; 
 static const char *TAG = "CAM"; 
 
 
 
 
@@ -520,7 +534,7 @@ esp_err_t CCamera::CaptureToHTTP(httpd_req_t *req, int delay)
     esp_camera_fb_return(fb);
     esp_camera_fb_return(fb);
     int64_t fr_end = esp_timer_get_time();
     int64_t fr_end = esp_timer_get_time();
     
     
-    ESP_LOGI(TAG, "JPG: %uKB %ums", (uint32_t)(fb_len/1024), (uint32_t)((fr_end - fr_start)/1000));
+    ESP_LOGI(TAG, "JPG: %dKB %dms", (int)(fb_len/1024), (int)((fr_end - fr_start)/1000));
 
 
     if (delay > 0) 
     if (delay > 0) 
         LightOnOff(false);
         LightOnOff(false);
@@ -574,7 +588,7 @@ esp_err_t CCamera::CaptureToStream(httpd_req_t *req, bool FlashlightOn)
         esp_camera_fb_return(fb);
         esp_camera_fb_return(fb);
 
 
         int64_t fr_end = esp_timer_get_time();
         int64_t fr_end = esp_timer_get_time();
-        ESP_LOGD(TAG, "JPG: %uKB %ums", (uint32_t)(fb_len/1024), (uint32_t)((fr_end - fr_start)/1000));
+        ESP_LOGD(TAG, "JPG: %dKB %dms", (int)(fb_len/1024), (int)((fr_end - fr_start)/1000));
 
 
         if (res != ESP_OK){ // Exit loop, e.g. also when closing the webpage
         if (res != ESP_OK){ // Exit loop, e.g. also when closing the webpage
             break;
             break;

+ 2 - 2
code/components/jomjol_fileserver_ota/CMakeLists.txt

@@ -1,7 +1,7 @@
 FILE(GLOB_RECURSE app_sources ${CMAKE_CURRENT_SOURCE_DIR}/*.*)
 FILE(GLOB_RECURSE app_sources ${CMAKE_CURRENT_SOURCE_DIR}/*.*)
 
 
 idf_component_register(SRCS ${app_sources}
 idf_component_register(SRCS ${app_sources}
-                    INCLUDE_DIRS "." "../../include"
-                    REQUIRES tflite-lib esp_http_server app_update esp_http_client nvs_flash jomjol_tfliteclass jomjol_flowcontroll spiffs jomjol_helper jomjol_controlGPIO miniz)
+                    INCLUDE_DIRS "." "../../include" "miniz"
+                    REQUIRES vfs tflite-lib esp_http_server app_update esp_http_client nvs_flash jomjol_tfliteclass jomjol_flowcontroll spiffs jomjol_helper jomjol_controlGPIO)
 
 
 
 

+ 0 - 0
code/components/miniz/ChangeLog.md → code/components/jomjol_fileserver_ota/miniz/ChangeLog.md


+ 0 - 0
code/components/miniz/LICENSE → code/components/jomjol_fileserver_ota/miniz/LICENSE


+ 0 - 0
code/components/miniz/examples/example1.c → code/components/jomjol_fileserver_ota/miniz/examples/example1.c


+ 0 - 0
code/components/miniz/examples/example2.c → code/components/jomjol_fileserver_ota/miniz/examples/example2.c


+ 0 - 0
code/components/miniz/examples/example3.c → code/components/jomjol_fileserver_ota/miniz/examples/example3.c


+ 0 - 0
code/components/miniz/examples/example4.c → code/components/jomjol_fileserver_ota/miniz/examples/example4.c


+ 0 - 0
code/components/miniz/examples/example5.c → code/components/jomjol_fileserver_ota/miniz/examples/example5.c


+ 0 - 0
code/components/miniz/examples/example6.c → code/components/jomjol_fileserver_ota/miniz/examples/example6.c


+ 0 - 0
code/components/miniz/miniz.c → code/components/jomjol_fileserver_ota/miniz/miniz.c


+ 0 - 0
code/components/miniz/miniz.h → code/components/jomjol_fileserver_ota/miniz/miniz.h


+ 0 - 0
code/components/miniz/readme.md → code/components/jomjol_fileserver_ota/miniz/readme.md


+ 0 - 0
code/components/miniz/readme2.md → code/components/jomjol_fileserver_ota/miniz/readme2.md


+ 0 - 1
code/components/jomjol_fileserver_ota/server_file.cpp

@@ -47,7 +47,6 @@ extern "C" {
 #include "Helper.h"
 #include "Helper.h"
 #include "miniz.h"
 #include "miniz.h"
 
 
-
 static const char *TAG = "OTA FILE";
 static const char *TAG = "OTA FILE";
 
 
 struct file_server_data {
 struct file_server_data {

+ 14 - 6
code/components/jomjol_fileserver_ota/server_ota.cpp

@@ -3,7 +3,10 @@
 #include <string>
 #include <string>
 #include "string.h"
 #include "string.h"
 
 
-#include <esp_int_wdt.h>
+/* TODO Rethink the usage of the int watchdog. It is no longer to be used, see
+https://docs.espressif.com/projects/esp-idf/en/latest/esp32/migration-guides/release-5.x/5.0/system.html?highlight=esp_int_wdt */
+#include "esp_private/esp_int_wdt.h"
+
 #include <esp_task_wdt.h>
 #include <esp_task_wdt.h>
 
 
 
 
@@ -11,14 +14,13 @@
 #include "freertos/FreeRTOS.h"
 #include "freertos/FreeRTOS.h"
 #include "freertos/task.h"
 #include "freertos/task.h"
 #include "esp_system.h"
 #include "esp_system.h"
-#include "esp_event.h"
-#include "esp_event.h"
 #include "esp_log.h"
 #include "esp_log.h"
 #include <esp_ota_ops.h>
 #include <esp_ota_ops.h>
 #include "esp_http_client.h"
 #include "esp_http_client.h"
 #include "esp_flash_partitions.h"
 #include "esp_flash_partitions.h"
 #include "esp_partition.h"
 #include "esp_partition.h"
 #include <nvs.h>
 #include <nvs.h>
+#include "esp_app_format.h"
 #include "nvs_flash.h"
 #include "nvs_flash.h"
 #include "driver/gpio.h"
 #include "driver/gpio.h"
 // #include "protocol_examples_common.h"
 // #include "protocol_examples_common.h"
@@ -157,12 +159,12 @@ static bool ota_update_task(std::string fn)
         LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "(This can happen if either the OTA boot data or preferred boot image become somehow corrupted.)");
         LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "(This can happen if either the OTA boot data or preferred boot image become somehow corrupted.)");
     }
     }
     ESP_LOGI(TAG, "Running partition type %d subtype %d (offset 0x%08x)",
     ESP_LOGI(TAG, "Running partition type %d subtype %d (offset 0x%08x)",
-             running->type, running->subtype, running->address);
+             running->type, running->subtype, (unsigned int)running->address);
 
 
 
 
     update_partition = esp_ota_get_next_update_partition(NULL);
     update_partition = esp_ota_get_next_update_partition(NULL);
     ESP_LOGI(TAG, "Writing to partition subtype %d at offset 0x%x",
     ESP_LOGI(TAG, "Writing to partition subtype %d at offset 0x%x",
-             update_partition->subtype, update_partition->address);
+             update_partition->subtype, (unsigned int)update_partition->address);
 //    assert(update_partition != NULL);
 //    assert(update_partition != NULL);
 
 
     int binary_file_length = 0;
     int binary_file_length = 0;
@@ -570,7 +572,13 @@ esp_err_t handler_ota_update(httpd_req_t *req)
 
 
 void hard_restart() 
 void hard_restart() 
 {
 {
-  esp_task_wdt_init(1,true);
+  esp_task_wdt_config_t twdt_config = {
+    .timeout_ms = 1,
+    .idle_core_mask = (1 << portNUM_PROCESSORS) - 1,    // Bitmask of all cores
+    .trigger_panic = true,
+  };
+  ESP_ERROR_CHECK(esp_task_wdt_init(&twdt_config));
+
   esp_task_wdt_add(NULL);
   esp_task_wdt_add(NULL);
   while(true);
   while(true);
 }
 }

+ 1 - 1
code/components/jomjol_flowcontroll/CMakeLists.txt

@@ -2,6 +2,6 @@ FILE(GLOB_RECURSE app_sources ${CMAKE_CURRENT_SOURCE_DIR}/*.*)
 
 
 idf_component_register(SRCS ${app_sources}
 idf_component_register(SRCS ${app_sources}
                     INCLUDE_DIRS "."
                     INCLUDE_DIRS "."
-                    REQUIRES jomjol_tfliteclass jomjol_helper jomjol_controlcamera jomjol_mqtt jomjol_influxdb jomjol_fileserver_ota jomjol_image_proc jomjol_wlan)
+                    REQUIRES esp_timer esp_wifi jomjol_tfliteclass jomjol_helper jomjol_controlcamera jomjol_mqtt jomjol_influxdb jomjol_fileserver_ota jomjol_image_proc jomjol_wlan)
 
 
 
 

+ 2 - 2
code/components/jomjol_flowcontroll/ClassFlowControll.cpp

@@ -728,7 +728,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 *)fileBuffer, fileSize); 
                 result = httpd_resp_send(req, (const char *)fileBuffer, fileSize); 
-                delete fileBuffer;
+                free(fileBuffer);
             }
             }
             else if (aktstatus.find("Initialization") != -1) {
             else if (aktstatus.find("Initialization") != -1) {
                 FILE* file = fopen("/sdcard/html/Flowstate_initialization.jpg", "rb"); 
                 FILE* file = fopen("/sdcard/html/Flowstate_initialization.jpg", "rb"); 
@@ -755,7 +755,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 *)fileBuffer, fileSize); 
                 result = httpd_resp_send(req, (const char *)fileBuffer, fileSize); 
-                delete 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) {

+ 5 - 0
code/components/jomjol_flowcontroll/MainFlowControl.cpp

@@ -4,6 +4,7 @@
 #include <vector>
 #include <vector>
 #include "string.h"
 #include "string.h"
 #include "esp_log.h"
 #include "esp_log.h"
+#include <esp_timer.h>
 
 
 #include <iomanip>
 #include <iomanip>
 #include <sstream>
 #include <sstream>
@@ -27,6 +28,10 @@
 #include "connect_wlan.h"
 #include "connect_wlan.h"
 #include "psram.h"
 #include "psram.h"
 
 
+// support IDF 5.x
+#ifndef portTICK_RATE_MS
+#define portTICK_RATE_MS portTICK_PERIOD_MS
+#endif
 
 
 ClassFlowControll flowctrl;
 ClassFlowControll flowctrl;
 
 

+ 1 - 1
code/components/jomjol_helper/CMakeLists.txt

@@ -2,6 +2,6 @@ FILE(GLOB_RECURSE app_sources ${CMAKE_CURRENT_SOURCE_DIR}/*.*)
 
 
 idf_component_register(SRCS ${app_sources}
 idf_component_register(SRCS ${app_sources}
                     INCLUDE_DIRS "."
                     INCLUDE_DIRS "."
-                    REQUIRES tflite-lib jomjol_logfile fatfs sdmmc)
+                    REQUIRES esp_timer tflite-lib jomjol_logfile fatfs sdmmc)
 
 
 
 

+ 2 - 0
code/components/jomjol_helper/Helper.cpp

@@ -23,6 +23,8 @@ extern "C" {
 
 
 #include <string.h>
 #include <string.h>
 #include <esp_log.h>
 #include <esp_log.h>
+#include <esp_mac.h>
+#include <esp_timer.h>
 #include "../../include/defines.h"
 #include "../../include/defines.h"
 
 
 
 

+ 2 - 1
code/components/jomjol_helper/esp_sys.cpp

@@ -3,6 +3,7 @@
 #ifdef DEBUG_ENABLE_SYSINFO
 #ifdef DEBUG_ENABLE_SYSINFO
 
 
 #include "esp_sys.h"
 #include "esp_sys.h"
+#include "esp_chip_info.h"
 
 
 #include <string>
 #include <string>
 
 
@@ -121,7 +122,7 @@ std::string get_device_info()
     }
     }
 
 
     #ifdef USE_HIMEM_IF_AVAILABLE
     #ifdef USE_HIMEM_IF_AVAILABLE
-        sprintf(aMsgBuf,"spiram size %u\n", esp_spiram_get_size());
+        sprintf(aMsgBuf,"spiram size %u\n", esp_psram_get_size());
         espInfoResultStr += std::string(aMsgBuf);
         espInfoResultStr += std::string(aMsgBuf);
         sprintf(aMsgBuf,"himem free %u\n", esp_himem_get_free_size());
         sprintf(aMsgBuf,"himem free %u\n", esp_himem_get_free_size());
         espInfoResultStr += std::string(aMsgBuf);
         espInfoResultStr += std::string(aMsgBuf);

+ 2 - 2
code/components/jomjol_helper/esp_sys.h

@@ -16,9 +16,9 @@
 #include <esp_spi_flash.h>
 #include <esp_spi_flash.h>
 #include <esp_heap_caps.h>
 #include <esp_heap_caps.h>
 
 
-// for esp_spiram_get_size
+// for esp_psram_get_size
 extern "C" {
 extern "C" {
-    #include <esp32/spiram.h>
+    #include "esp_psram.h"
     #ifdef USE_HIMEM_IF_AVAILABLE
     #ifdef USE_HIMEM_IF_AVAILABLE
         #include <esp32/himem.h>
         #include <esp32/himem.h>
     #endif
     #endif

+ 5 - 0
code/components/jomjol_helper/statusled.cpp

@@ -7,6 +7,11 @@
 #include "ClassLogFile.h"
 #include "ClassLogFile.h"
 #include "../../include/defines.h"
 #include "../../include/defines.h"
 
 
+// define `gpio_pad_select_gpip` for newer versions of IDF
+#if (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 3, 0))
+#include "esp_rom_gpio.h"
+#define gpio_pad_select_gpio esp_rom_gpio_pad_select_gpio
+#endif
 
 
 static const char* TAG = "STATUSLED";
 static const char* TAG = "STATUSLED";
 
 

+ 3 - 0
code/components/jomjol_influxdb/interface_influxdb.cpp

@@ -137,6 +137,9 @@ static esp_err_t http_event_handler(esp_http_client_event_t *evt)
          case HTTP_EVENT_DISCONNECTED:
          case HTTP_EVENT_DISCONNECTED:
             LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "HTTP Client Disconnected");
             LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "HTTP Client Disconnected");
             break;
             break;
+        case HTTP_EVENT_REDIRECT:
+            LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "HTTP Redirect");
+            break;
     }
     }
     return ESP_OK;
     return ESP_OK;
 }
 }

+ 1 - 1
code/components/jomjol_mqtt/CMakeLists.txt

@@ -2,4 +2,4 @@ FILE(GLOB_RECURSE app_sources ${CMAKE_CURRENT_SOURCE_DIR}/*.*)
 
 
 idf_component_register(SRCS ${app_sources}
 idf_component_register(SRCS ${app_sources}
                     INCLUDE_DIRS "."
                     INCLUDE_DIRS "."
-                    REQUIRES tflite-lib mqtt jomjol_tfliteclass jomjol_helper jomjol_mqtt jomjol_wlan json)
+                    REQUIRES esp_timer tflite-lib mqtt jomjol_tfliteclass jomjol_helper jomjol_mqtt jomjol_wlan json)

+ 17 - 17
code/components/jomjol_mqtt/interface_mqtt.cpp

@@ -186,7 +186,7 @@ static esp_err_t mqtt_event_handler_cb(esp_mqtt_event_handle_t event) {
 
 
 
 
 static void mqtt_event_handler(void *handler_args, esp_event_base_t base, int32_t event_id, void *event_data) {
 static void mqtt_event_handler(void *handler_args, esp_event_base_t base, int32_t event_id, void *event_data) {
-    ESP_LOGD(TAG, "Event dispatched from event loop base=%s, event_id=%d", base, event_id);
+    ESP_LOGD(TAG, "Event dispatched from event loop base=%s, event_id=%d", base, (int)event_id);
     mqtt_event_handler_cb((esp_mqtt_event_handle_t) event_data);
     mqtt_event_handler_cb((esp_mqtt_event_handle_t) event_data);
 }
 }
 
 
@@ -248,24 +248,24 @@ int MQTT_Init() {
     LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Init");
     LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Init");
     MQTTdestroy_client(false);
     MQTTdestroy_client(false);
 
 
-    esp_mqtt_client_config_t mqtt_cfg = {
-        .uri = uri.c_str(),
-        .client_id = client_id.c_str(),
-        .lwt_topic = lwt_topic.c_str(),
-        .lwt_msg = lwt_disconnected.c_str(),
-        .lwt_retain = 1,
-        .lwt_msg_len = (int)(lwt_disconnected.length()),
-        .keepalive = keepalive,
-        .disable_auto_reconnect = false,        // Reconnection routine active (Default: false)
-        .buffer_size = 1536,                    // size of MQTT send/receive buffer (Default: 1024)
-        .reconnect_timeout_ms = 15000,          // Try to reconnect to broker (Default: 10000ms)
-        .network_timeout_ms = 20000,            // Network Timeout (Default: 10000ms)
-        .message_retransmit_timeout = 3000      // Time after message resent when broker not acknowledged (QoS1, QoS2)
-    };
+    esp_mqtt_client_config_t mqtt_cfg = { };
+
+    mqtt_cfg.broker.address.uri = uri.c_str();
+    mqtt_cfg.credentials.client_id = client_id.c_str();
+    mqtt_cfg.network.disable_auto_reconnect = false;     // Reconnection routine active (Default: false)
+    mqtt_cfg.network.reconnect_timeout_ms = 15000;       // Try to reconnect to broker (Default: 10000ms)
+    mqtt_cfg.network.timeout_ms = 20000;                 // Network Timeout (Default: 10000ms)
+    mqtt_cfg.session.message_retransmit_timeout = 3000;  // Time after message resent when broker not acknowledged (QoS1, QoS2)
+    mqtt_cfg.session.last_will.topic = lwt_topic.c_str();
+    mqtt_cfg.session.last_will.retain = 1;
+    mqtt_cfg.session.last_will.msg = lwt_disconnected.c_str();
+    mqtt_cfg.session.last_will.msg_len = (int)(lwt_disconnected.length());
+    mqtt_cfg.session.keepalive = keepalive;
+    mqtt_cfg.buffer.size = 1536;                         // size of MQTT send/receive buffer (Default: 1024)
 
 
     if (user.length() && password.length()){
     if (user.length() && password.length()){
-        mqtt_cfg.username = user.c_str();
-        mqtt_cfg.password = password.c_str();
+        mqtt_cfg.credentials.username = user.c_str();
+        mqtt_cfg.credentials.authentication.password = password.c_str();
     }
     }
 
 
     #ifdef DEBUG_DETAIL_ON  
     #ifdef DEBUG_DETAIL_ON  

+ 0 - 1
code/components/jomjol_time_sntp/time_sntp.cpp

@@ -7,7 +7,6 @@
 #include "freertos/task.h"
 #include "freertos/task.h"
 #include "freertos/event_groups.h"
 #include "freertos/event_groups.h"
 #include "esp_system.h"
 #include "esp_system.h"
-#include "esp_event.h"
 #include "esp_log.h"
 #include "esp_log.h"
 #include "esp_attr.h"
 #include "esp_attr.h"
 #include "esp_sleep.h"
 #include "esp_sleep.h"

+ 0 - 1
code/components/jomjol_time_sntp/time_sntp.h

@@ -11,7 +11,6 @@
 #include "freertos/task.h"
 #include "freertos/task.h"
 #include "freertos/event_groups.h"
 #include "freertos/event_groups.h"
 #include "esp_system.h"
 #include "esp_system.h"
-#include "esp_event.h"
 #include "esp_log.h"
 #include "esp_log.h"
 #include "esp_attr.h"
 #include "esp_attr.h"
 #include "esp_sleep.h"
 #include "esp_sleep.h"

+ 1 - 1
code/components/jomjol_wlan/CMakeLists.txt

@@ -2,6 +2,6 @@ FILE(GLOB_RECURSE app_sources ${CMAKE_CURRENT_SOURCE_DIR}/*.*)
 
 
 idf_component_register(SRCS ${app_sources}
 idf_component_register(SRCS ${app_sources}
                     INCLUDE_DIRS "."
                     INCLUDE_DIRS "."
-                    REQUIRES nvs_flash jomjol_helper jomjol_mqtt wpa_supplicant)
+                    REQUIRES esp_wifi nvs_flash jomjol_helper jomjol_mqtt wpa_supplicant)
 
 
 
 

+ 20 - 6
code/components/jomjol_wlan/connect_wlan.cpp

@@ -19,7 +19,7 @@
 #include "esp_mbo.h"
 #include "esp_mbo.h"
 #include "esp_mac.h"
 #include "esp_mac.h"
 #include "esp_netif.h"
 #include "esp_netif.h"
-#include "esp_event.h"
+#include <netdb.h>
 #include "esp_log.h"
 #include "esp_log.h"
 #include "nvs_flash.h"
 #include "nvs_flash.h"
 
 
@@ -36,6 +36,20 @@
 
 
 #include "../../include/defines.h"
 #include "../../include/defines.h"
 
 
+#if (ESP_IDF_VERSION_MAJOR >= 5)
+#include "soc/periph_defs.h"
+#include "esp_private/periph_ctrl.h"
+#include "soc/gpio_sig_map.h"
+#include "soc/gpio_periph.h"
+#include "soc/io_mux_reg.h"
+#include "esp_rom_gpio.h"
+#define gpio_pad_select_gpio esp_rom_gpio_pad_select_gpio
+#define gpio_matrix_in(a,b,c) esp_rom_gpio_connect_in_signal(a,b,c)
+#define gpio_matrix_out(a,b,c,d) esp_rom_gpio_connect_out_signal(a,b,c,d)
+#define ets_delay_us(a) esp_rom_delay_us(a)
+#endif
+
+esp_netif_t *sta_netif = NULL;
 
 
 static const char *TAG = "WIFI";
 static const char *TAG = "WIFI";
 
 
@@ -173,7 +187,7 @@ static char * get_btm_neighbor_list(uint8_t *report, size_t report_len)
 			pos += s_len;
 			pos += s_len;
 		}
 		}
 				
 				
-		ESP_LOGI(TAG, "Roaming: RMM neigbor report bssid=" MACSTR
+		ESP_LOGI(TAG, "Roaming: RMM neighbor report bssid=" MACSTR
 				" info=0x%x op_class=%u chan=%u phy_type=%u%s%s%s%s",
 				" info=0x%x op_class=%u chan=%u phy_type=%u%s%s%s%s",
 				MAC2STR(nr), WPA_GET_LE32(nr + ETH_ALEN),
 				MAC2STR(nr), WPA_GET_LE32(nr + ETH_ALEN),
 				nr[ETH_ALEN + 4], nr[ETH_ALEN + 5],
 				nr[ETH_ALEN + 4], nr[ETH_ALEN + 5],
@@ -182,7 +196,7 @@ static char * get_btm_neighbor_list(uint8_t *report, size_t report_len)
 				civic[0] ? " civic=" : "", civic);
 				civic[0] ? " civic=" : "", civic);
 
 
 		
 		
-		LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "Roaming: RMM neigbor report BSSID: " + BssidToString((char*)nr) + 
+		LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "Roaming: RMM neighbor report BSSID: " + BssidToString((char*)nr) + 
 		                                        ", Channel: " + std::to_string(nr[ETH_ALEN + 5]));
 		                                        ", Channel: " + std::to_string(nr[ETH_ALEN + 5]));
 
 
 		/* neighbor start */
 		/* neighbor start */
@@ -365,7 +379,7 @@ void wifi_scan(void)
 	else {
 	else {
     	if (esp_wifi_scan_get_ap_records(&max_number_of_ap_found, wifi_ap_records) != ESP_OK) { // Retrieve results (and free internal heap)
     	if (esp_wifi_scan_get_ap_records(&max_number_of_ap_found, wifi_ap_records) != ESP_OK) { // Retrieve results (and free internal heap)
 			LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "wifi_scan: esp_wifi_scan_get_ap_records: Error retrieving datasets");
 			LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "wifi_scan: esp_wifi_scan_get_ap_records: Error retrieving datasets");
-			free(wifi_ap_records);
+			delete wifi_ap_records;
 			return;
 			return;
 		}
 		}
 	}
 	}
@@ -388,7 +402,7 @@ void wifi_scan(void)
 			APWithBetterRSSI = true;
 			APWithBetterRSSI = true;
         }
         }
 	}
 	}
-    free(wifi_ap_records);
+	delete wifi_ap_records;
 }
 }
 
 
 
 
@@ -636,7 +650,7 @@ esp_err_t wifi_init_sta(void)
 
 
     if (!wlan_config.hostname.empty())
     if (!wlan_config.hostname.empty())
     {
     {
-        retval = tcpip_adapter_set_hostname(TCPIP_ADAPTER_IF_STA , wlan_config.hostname.c_str());
+        retval = esp_netif_set_hostname(my_sta, wlan_config.hostname.c_str());
         if(retval != ESP_OK ) {
         if(retval != ESP_OK ) {
 			LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Failed to set hostname! Error: " + std::to_string(retval));
 			LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Failed to set hostname! Error: " + std::to_string(retval));
         }
         }

+ 0 - 6
code/components/miniz/CMakeLists.txt

@@ -1,6 +0,0 @@
-FILE(GLOB_RECURSE app_sources ${CMAKE_CURRENT_SOURCE_DIR}/*.*)
-
-idf_component_register(SRCS ${app_sources}
-                    INCLUDE_DIRS "." "../../include")
-
-

+ 1 - 1
code/dependencies.lock

@@ -1,3 +1,3 @@
-manifest_hash: 4e37bb0f9273c4de05f38688720fe32aa6e5b892452694a4f7a2ca1659f02cf6
+manifest_hash: 63f5c6c9f0bcebc7b9ca12d2aa8b26b2c5f5218d377dc4b2375d9b9ca1df7815
 target: esp32
 target: esp32
 version: 1.0.0
 version: 1.0.0

+ 1 - 2
code/main/CMakeLists.txt

@@ -66,5 +66,4 @@ FILE(GLOB_RECURSE app_sources ${CMAKE_SOURCE_DIR}/main/*.*)
 
 
 idf_component_register(SRCS ${app_sources}
 idf_component_register(SRCS ${app_sources}
                     INCLUDE_DIRS "."
                     INCLUDE_DIRS "."
-                   # REQUIRES esp_psram) # comming in IDF 5.0
-                    )
+                    REQUIRES esp_psram)

+ 10 - 6
code/main/main.cpp

@@ -9,10 +9,9 @@
 
 
 //#include "driver/gpio.h"
 //#include "driver/gpio.h"
 //#include "sdkconfig.h"
 //#include "sdkconfig.h"
-//#include "esp_psram.h" // Comming in IDF 5.0, see https://docs.espressif.com/projects/esp-idf/en/v5.0-beta1/esp32/migration-guides/release-5.x/system.html?highlight=esp_psram_get_size
-//#include "spiram.h"
-#include "esp32/spiram.h"
+#include "esp_psram.h"
 #include "esp_pm.h"
 #include "esp_pm.h"
+#include "esp_chip_info.h"
 
 
 
 
 // SD-Card ////////////////////
 // SD-Card ////////////////////
@@ -63,6 +62,11 @@
 #endif
 #endif
 #endif //DEBUG_ENABLE_SYSINFO
 #endif //DEBUG_ENABLE_SYSINFO
 
 
+// define `gpio_pad_select_gpip` for newer versions of IDF
+#if (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 3, 0))
+#include "esp_rom_gpio.h"
+#define gpio_pad_select_gpio esp_rom_gpio_pad_select_gpio
+#endif
 
 
 #ifdef USE_HIMEM_IF_AVAILABLE
 #ifdef USE_HIMEM_IF_AVAILABLE
     #include "esp32/himem.h"
     #include "esp32/himem.h"
@@ -372,14 +376,14 @@ extern "C" void app_main(void)
    
    
     // Init external PSRAM
     // Init external PSRAM
     // ********************************************
     // ********************************************
-    esp_err_t PSRAMStatus = esp_spiram_init();
-    if (PSRAMStatus != ESP_OK) {  // ESP_FAIL -> Failed to init PSRAM
+    esp_err_t PSRAMStatus = esp_psram_init();
+    if (PSRAMStatus == ESP_FAIL) {  // ESP_FAIL -> Failed to init PSRAM
         LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "PSRAM init failed (" + std::to_string(PSRAMStatus) + ")! PSRAM not found or defective");
         LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "PSRAM init failed (" + std::to_string(PSRAMStatus) + ")! PSRAM not found or defective");
         setSystemStatusFlag(SYSTEM_STATUS_PSRAM_BAD);
         setSystemStatusFlag(SYSTEM_STATUS_PSRAM_BAD);
         StatusLED(PSRAM_INIT, 1, true);
         StatusLED(PSRAM_INIT, 1, true);
     }
     }
     else { // ESP_OK -> PSRAM init OK --> continue to check PSRAM size
     else { // ESP_OK -> PSRAM init OK --> continue to check PSRAM size
-        size_t psram_size = esp_spiram_get_size(); // size_t psram_size = esp_psram_get_size(); // comming in IDF 5.0
+        size_t psram_size = esp_psram_get_size(); // size_t psram_size = esp_psram_get_size(); // comming in IDF 5.0
         LogFile.WriteToFile(ESP_LOG_INFO, TAG, "PSRAM size: " + std::to_string(psram_size) + " byte (" + std::to_string(psram_size/1024/1024) + 
         LogFile.WriteToFile(ESP_LOG_INFO, TAG, "PSRAM size: " + std::to_string(psram_size) + " byte (" + std::to_string(psram_size/1024/1024) + 
                                                "MB / " + std::to_string(psram_size/1024/1024*8) + "MBit)");
                                                "MB / " + std::to_string(psram_size/1024/1024*8) + "MBit)");
 
 

+ 11 - 4
code/main/server_main.cpp

@@ -13,6 +13,7 @@
 #include "version.h"
 #include "version.h"
 
 
 #include "esp_wifi.h"
 #include "esp_wifi.h"
+#include <netdb.h>
 
 
 #include "MainFlowControl.h"
 #include "MainFlowControl.h"
 #include "esp_log.h"
 #include "esp_log.h"
@@ -24,6 +25,8 @@
 httpd_handle_t server = NULL;   
 httpd_handle_t server = NULL;   
 std::string starttime = "";
 std::string starttime = "";
 
 
+extern esp_netif_t *sta_netif;
+
 static const char *TAG = "MAIN SERVER";
 static const char *TAG = "MAIN SERVER";
 
 
 /* An HTTP GET handler */
 /* An HTTP GET handler */
@@ -350,11 +353,15 @@ esp_err_t sysinfo_handler(httpd_req_t *req)
     char freeheapmem[11];
     char freeheapmem[11];
     sprintf(freeheapmem, "%lu", (long) getESPHeapSize());
     sprintf(freeheapmem, "%lu", (long) getESPHeapSize());
     
     
-    tcpip_adapter_ip_info_t ip_info;
-    ESP_ERROR_CHECK(tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_STA, &ip_info));
+    esp_netif_ip_info_t ip_info;
+    ESP_ERROR_CHECK(esp_netif_get_ip_info(sta_netif, &ip_info));
     const char *hostname;
     const char *hostname;
-    ESP_ERROR_CHECK(tcpip_adapter_get_hostname(TCPIP_ADAPTER_IF_STA, &hostname));
+    ESP_ERROR_CHECK(esp_netif_get_hostname(sta_netif, &hostname));
     
     
+    char ipFormated[4*3+3+1];
+
+    sprintf(ipFormated, IPSTR, IP2STR(&ip_info.ip));
+
     zw = string("[{") + 
     zw = string("[{") + 
         "\"firmware\": \"" + gitversion + "\"," +
         "\"firmware\": \"" + gitversion + "\"," +
         "\"buildtime\": \"" + buildtime + "\"," +
         "\"buildtime\": \"" + buildtime + "\"," +
@@ -364,7 +371,7 @@ esp_err_t sysinfo_handler(httpd_req_t *req)
         "\"html\": \"" + htmlversion + "\"," +
         "\"html\": \"" + htmlversion + "\"," +
         "\"cputemp\": \"" + cputemp + "\"," +
         "\"cputemp\": \"" + cputemp + "\"," +
         "\"hostname\": \"" + hostname + "\"," +
         "\"hostname\": \"" + hostname + "\"," +
-        "\"IPv4\": \"" + ip4addr_ntoa(&ip_info.ip) + "\"," +
+        "\"IPv4\": \"" + string(ipFormated) + "\"," +
         "\"freeHeapMem\": \"" + freeheapmem + "\"" +
         "\"freeHeapMem\": \"" + freeheapmem + "\"" +
         "}]";
         "}]";
 
 

+ 1 - 1
code/main/softAP.cpp

@@ -17,7 +17,7 @@
 #include "freertos/task.h"
 #include "freertos/task.h"
 #include "esp_mac.h"
 #include "esp_mac.h"
 #include "esp_wifi.h"
 #include "esp_wifi.h"
-#include "esp_event.h"
+
 #include "esp_log.h"
 #include "esp_log.h"
 #include "nvs_flash.h"
 #include "nvs_flash.h"
 
 

+ 1 - 1
code/platformio.ini

@@ -19,7 +19,7 @@
 
 
 [common:esp32-idf]
 [common:esp32-idf]
     extends = common:idf
     extends = common:idf
-    platform = platformio/espressif32 @ 5.2.0
+    platform = platformio/espressif32 @ 6.1.0
     framework = espidf
     framework = espidf
     lib_deps = 
     lib_deps = 
         ${common:idf.lib_deps}
         ${common:idf.lib_deps}

+ 1 - 0
code/sdkconfig.defaults

@@ -9,6 +9,7 @@
 #CONFIG_ESP_WIFI_SOFTAP_SUPPORT=n 
 #CONFIG_ESP_WIFI_SOFTAP_SUPPORT=n 
 #to save 28k of flash
 #to save 28k of flash
 
 
+CONFIG_ESP_TASK_WDT=n
 CONFIG_TASK_WDT=n
 CONFIG_TASK_WDT=n
 CONFIG_TASK_WDT_CHECK_IDLE_TASK=n
 CONFIG_TASK_WDT_CHECK_IDLE_TASK=n