diff --git a/code/components/jomjol_controlGPIO/SmartLeds.cpp b/code/components/jomjol_controlGPIO/SmartLeds.cpp index a2ba7b29..58fb74c6 100644 --- a/code/components/jomjol_controlGPIO/SmartLeds.cpp +++ b/code/components/jomjol_controlGPIO/SmartLeds.cpp @@ -1,5 +1,32 @@ #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; intr_handle_t SmartLed::_interruptHandle = NULL; diff --git a/code/components/jomjol_controlGPIO/SmartLeds.h b/code/components/jomjol_controlGPIO/SmartLeds.h index 4a95d41b..b779ac68 100644 --- a/code/components/jomjol_controlGPIO/SmartLeds.h +++ b/code/components/jomjol_controlGPIO/SmartLeds.h @@ -35,6 +35,20 @@ #include #include +#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 ) extern "C" { // ...someone forgot to put in the includes... #include "esp32-hal.h" @@ -65,6 +79,27 @@ #include #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" namespace detail { diff --git a/code/components/jomjol_controlGPIO/server_GPIO.cpp b/code/components/jomjol_controlGPIO/server_GPIO.cpp index 64a8e17c..3d6f8659 100644 --- a/code/components/jomjol_controlGPIO/server_GPIO.cpp +++ b/code/components/jomjol_controlGPIO/server_GPIO.cpp @@ -6,7 +6,6 @@ #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "esp_system.h" -#include "esp_event.h" #include "esp_log.h" diff --git a/code/components/jomjol_controlcamera/CMakeLists.txt b/code/components/jomjol_controlcamera/CMakeLists.txt index 9f1a3927..1959dd55 100644 --- a/code/components/jomjol_controlcamera/CMakeLists.txt +++ b/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} 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) diff --git a/code/components/jomjol_controlcamera/ClassControllCamera.cpp b/code/components/jomjol_controlcamera/ClassControllCamera.cpp index be6324b3..65bba6cc 100644 --- a/code/components/jomjol_controlcamera/ClassControllCamera.cpp +++ b/code/components/jomjol_controlcamera/ClassControllCamera.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include "freertos/FreeRTOS.h" #include "freertos/task.h" @@ -30,6 +31,19 @@ #include "driver/ledc.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"; @@ -520,7 +534,7 @@ esp_err_t CCamera::CaptureToHTTP(httpd_req_t *req, int delay) esp_camera_fb_return(fb); 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) LightOnOff(false); @@ -574,7 +588,7 @@ esp_err_t CCamera::CaptureToStream(httpd_req_t *req, bool FlashlightOn) esp_camera_fb_return(fb); 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 break; diff --git a/code/components/jomjol_fileserver_ota/CMakeLists.txt b/code/components/jomjol_fileserver_ota/CMakeLists.txt index d054d2a4..15fe07b1 100644 --- a/code/components/jomjol_fileserver_ota/CMakeLists.txt +++ b/code/components/jomjol_fileserver_ota/CMakeLists.txt @@ -1,7 +1,7 @@ FILE(GLOB_RECURSE app_sources ${CMAKE_CURRENT_SOURCE_DIR}/*.*) 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) diff --git a/code/components/miniz/ChangeLog.md b/code/components/jomjol_fileserver_ota/miniz/ChangeLog.md similarity index 100% rename from code/components/miniz/ChangeLog.md rename to code/components/jomjol_fileserver_ota/miniz/ChangeLog.md diff --git a/code/components/miniz/LICENSE b/code/components/jomjol_fileserver_ota/miniz/LICENSE similarity index 100% rename from code/components/miniz/LICENSE rename to code/components/jomjol_fileserver_ota/miniz/LICENSE diff --git a/code/components/miniz/examples/example1.c b/code/components/jomjol_fileserver_ota/miniz/examples/example1.c similarity index 100% rename from code/components/miniz/examples/example1.c rename to code/components/jomjol_fileserver_ota/miniz/examples/example1.c diff --git a/code/components/miniz/examples/example2.c b/code/components/jomjol_fileserver_ota/miniz/examples/example2.c similarity index 100% rename from code/components/miniz/examples/example2.c rename to code/components/jomjol_fileserver_ota/miniz/examples/example2.c diff --git a/code/components/miniz/examples/example3.c b/code/components/jomjol_fileserver_ota/miniz/examples/example3.c similarity index 100% rename from code/components/miniz/examples/example3.c rename to code/components/jomjol_fileserver_ota/miniz/examples/example3.c diff --git a/code/components/miniz/examples/example4.c b/code/components/jomjol_fileserver_ota/miniz/examples/example4.c similarity index 100% rename from code/components/miniz/examples/example4.c rename to code/components/jomjol_fileserver_ota/miniz/examples/example4.c diff --git a/code/components/miniz/examples/example5.c b/code/components/jomjol_fileserver_ota/miniz/examples/example5.c similarity index 100% rename from code/components/miniz/examples/example5.c rename to code/components/jomjol_fileserver_ota/miniz/examples/example5.c diff --git a/code/components/miniz/examples/example6.c b/code/components/jomjol_fileserver_ota/miniz/examples/example6.c similarity index 100% rename from code/components/miniz/examples/example6.c rename to code/components/jomjol_fileserver_ota/miniz/examples/example6.c diff --git a/code/components/miniz/miniz.c b/code/components/jomjol_fileserver_ota/miniz/miniz.c similarity index 100% rename from code/components/miniz/miniz.c rename to code/components/jomjol_fileserver_ota/miniz/miniz.c diff --git a/code/components/miniz/miniz.h b/code/components/jomjol_fileserver_ota/miniz/miniz.h similarity index 100% rename from code/components/miniz/miniz.h rename to code/components/jomjol_fileserver_ota/miniz/miniz.h diff --git a/code/components/miniz/readme.md b/code/components/jomjol_fileserver_ota/miniz/readme.md similarity index 100% rename from code/components/miniz/readme.md rename to code/components/jomjol_fileserver_ota/miniz/readme.md diff --git a/code/components/miniz/readme2.md b/code/components/jomjol_fileserver_ota/miniz/readme2.md similarity index 100% rename from code/components/miniz/readme2.md rename to code/components/jomjol_fileserver_ota/miniz/readme2.md diff --git a/code/components/jomjol_fileserver_ota/server_file.cpp b/code/components/jomjol_fileserver_ota/server_file.cpp index 86d34df1..1bb65e35 100644 --- a/code/components/jomjol_fileserver_ota/server_file.cpp +++ b/code/components/jomjol_fileserver_ota/server_file.cpp @@ -47,7 +47,6 @@ extern "C" { #include "Helper.h" #include "miniz.h" - static const char *TAG = "OTA FILE"; struct file_server_data { diff --git a/code/components/jomjol_fileserver_ota/server_ota.cpp b/code/components/jomjol_fileserver_ota/server_ota.cpp index ebab26ff..ad7b1b59 100644 --- a/code/components/jomjol_fileserver_ota/server_ota.cpp +++ b/code/components/jomjol_fileserver_ota/server_ota.cpp @@ -3,7 +3,10 @@ #include #include "string.h" -#include +/* 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 @@ -11,14 +14,13 @@ #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "esp_system.h" -#include "esp_event.h" -#include "esp_event.h" #include "esp_log.h" #include #include "esp_http_client.h" #include "esp_flash_partitions.h" #include "esp_partition.h" #include +#include "esp_app_format.h" #include "nvs_flash.h" #include "driver/gpio.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.)"); } 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); 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); int binary_file_length = 0; @@ -570,7 +572,13 @@ esp_err_t handler_ota_update(httpd_req_t *req) 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); while(true); } diff --git a/code/components/jomjol_flowcontroll/CMakeLists.txt b/code/components/jomjol_flowcontroll/CMakeLists.txt index 6ee66829..2b58ada9 100644 --- a/code/components/jomjol_flowcontroll/CMakeLists.txt +++ b/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} 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) diff --git a/code/components/jomjol_flowcontroll/ClassFlowControll.cpp b/code/components/jomjol_flowcontroll/ClassFlowControll.cpp index f0d75c58..9e3ebebd 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowControll.cpp +++ b/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"); result = httpd_resp_send(req, (const char *)fileBuffer, fileSize); - delete fileBuffer; + free(fileBuffer); } else if (aktstatus.find("Initialization") != -1) { 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"); result = httpd_resp_send(req, (const char *)fileBuffer, fileSize); - delete fileBuffer; + free(fileBuffer); } else if (aktstatus.find("Take Image") != -1) { if (flowalignment && flowalignment->AlgROI) { diff --git a/code/components/jomjol_flowcontroll/MainFlowControl.cpp b/code/components/jomjol_flowcontroll/MainFlowControl.cpp index c532896a..ff5b590d 100644 --- a/code/components/jomjol_flowcontroll/MainFlowControl.cpp +++ b/code/components/jomjol_flowcontroll/MainFlowControl.cpp @@ -4,6 +4,7 @@ #include #include "string.h" #include "esp_log.h" +#include #include #include @@ -27,6 +28,10 @@ #include "connect_wlan.h" #include "psram.h" +// support IDF 5.x +#ifndef portTICK_RATE_MS +#define portTICK_RATE_MS portTICK_PERIOD_MS +#endif ClassFlowControll flowctrl; diff --git a/code/components/jomjol_helper/CMakeLists.txt b/code/components/jomjol_helper/CMakeLists.txt index 8d9580d5..2bca3ade 100644 --- a/code/components/jomjol_helper/CMakeLists.txt +++ b/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} INCLUDE_DIRS "." - REQUIRES tflite-lib jomjol_logfile fatfs sdmmc) + REQUIRES esp_timer tflite-lib jomjol_logfile fatfs sdmmc) diff --git a/code/components/jomjol_helper/Helper.cpp b/code/components/jomjol_helper/Helper.cpp index ae3ab683..e68e6873 100644 --- a/code/components/jomjol_helper/Helper.cpp +++ b/code/components/jomjol_helper/Helper.cpp @@ -23,6 +23,8 @@ extern "C" { #include #include +#include +#include #include "../../include/defines.h" diff --git a/code/components/jomjol_helper/esp_sys.cpp b/code/components/jomjol_helper/esp_sys.cpp index 2a222552..8df251cb 100644 --- a/code/components/jomjol_helper/esp_sys.cpp +++ b/code/components/jomjol_helper/esp_sys.cpp @@ -3,6 +3,7 @@ #ifdef DEBUG_ENABLE_SYSINFO #include "esp_sys.h" +#include "esp_chip_info.h" #include @@ -121,7 +122,7 @@ std::string get_device_info() } #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); sprintf(aMsgBuf,"himem free %u\n", esp_himem_get_free_size()); espInfoResultStr += std::string(aMsgBuf); diff --git a/code/components/jomjol_helper/esp_sys.h b/code/components/jomjol_helper/esp_sys.h index b07ee00f..addd5920 100644 --- a/code/components/jomjol_helper/esp_sys.h +++ b/code/components/jomjol_helper/esp_sys.h @@ -16,9 +16,9 @@ #include #include -// for esp_spiram_get_size +// for esp_psram_get_size extern "C" { - #include + #include "esp_psram.h" #ifdef USE_HIMEM_IF_AVAILABLE #include #endif diff --git a/code/components/jomjol_helper/statusled.cpp b/code/components/jomjol_helper/statusled.cpp index 770eb20f..d2f5650a 100644 --- a/code/components/jomjol_helper/statusled.cpp +++ b/code/components/jomjol_helper/statusled.cpp @@ -7,6 +7,11 @@ #include "ClassLogFile.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"; diff --git a/code/components/jomjol_influxdb/interface_influxdb.cpp b/code/components/jomjol_influxdb/interface_influxdb.cpp index d5e4b2b2..028616d0 100644 --- a/code/components/jomjol_influxdb/interface_influxdb.cpp +++ b/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: LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "HTTP Client Disconnected"); break; + case HTTP_EVENT_REDIRECT: + LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "HTTP Redirect"); + break; } return ESP_OK; } diff --git a/code/components/jomjol_mqtt/CMakeLists.txt b/code/components/jomjol_mqtt/CMakeLists.txt index 4b3f3b0e..cb31861d 100644 --- a/code/components/jomjol_mqtt/CMakeLists.txt +++ b/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} 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) diff --git a/code/components/jomjol_mqtt/interface_mqtt.cpp b/code/components/jomjol_mqtt/interface_mqtt.cpp index dc0809c5..1ab8f03f 100644 --- a/code/components/jomjol_mqtt/interface_mqtt.cpp +++ b/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) { - 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); } @@ -248,24 +248,24 @@ int MQTT_Init() { LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Init"); 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()){ - 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 diff --git a/code/components/jomjol_time_sntp/time_sntp.cpp b/code/components/jomjol_time_sntp/time_sntp.cpp index 7af1c6d6..3c620f16 100644 --- a/code/components/jomjol_time_sntp/time_sntp.cpp +++ b/code/components/jomjol_time_sntp/time_sntp.cpp @@ -7,7 +7,6 @@ #include "freertos/task.h" #include "freertos/event_groups.h" #include "esp_system.h" -#include "esp_event.h" #include "esp_log.h" #include "esp_attr.h" #include "esp_sleep.h" diff --git a/code/components/jomjol_time_sntp/time_sntp.h b/code/components/jomjol_time_sntp/time_sntp.h index c3dab062..a5df8bf1 100644 --- a/code/components/jomjol_time_sntp/time_sntp.h +++ b/code/components/jomjol_time_sntp/time_sntp.h @@ -11,7 +11,6 @@ #include "freertos/task.h" #include "freertos/event_groups.h" #include "esp_system.h" -#include "esp_event.h" #include "esp_log.h" #include "esp_attr.h" #include "esp_sleep.h" diff --git a/code/components/jomjol_wlan/CMakeLists.txt b/code/components/jomjol_wlan/CMakeLists.txt index f6a5c551..53953cb5 100644 --- a/code/components/jomjol_wlan/CMakeLists.txt +++ b/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} INCLUDE_DIRS "." - REQUIRES nvs_flash jomjol_helper jomjol_mqtt wpa_supplicant) + REQUIRES esp_wifi nvs_flash jomjol_helper jomjol_mqtt wpa_supplicant) diff --git a/code/components/jomjol_wlan/connect_wlan.cpp b/code/components/jomjol_wlan/connect_wlan.cpp index 1a618236..fa454840 100644 --- a/code/components/jomjol_wlan/connect_wlan.cpp +++ b/code/components/jomjol_wlan/connect_wlan.cpp @@ -19,7 +19,7 @@ #include "esp_mbo.h" #include "esp_mac.h" #include "esp_netif.h" -#include "esp_event.h" +#include #include "esp_log.h" #include "nvs_flash.h" @@ -36,6 +36,20 @@ #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"; @@ -173,7 +187,7 @@ static char * get_btm_neighbor_list(uint8_t *report, size_t report_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", MAC2STR(nr), WPA_GET_LE32(nr + ETH_ALEN), 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); - 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])); /* neighbor start */ @@ -365,7 +379,7 @@ void wifi_scan(void) else { 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"); - free(wifi_ap_records); + delete wifi_ap_records; return; } } @@ -388,7 +402,7 @@ void wifi_scan(void) 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()) { - 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 ) { LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Failed to set hostname! Error: " + std::to_string(retval)); } diff --git a/code/components/miniz/CMakeLists.txt b/code/components/miniz/CMakeLists.txt deleted file mode 100644 index dea3ca6f..00000000 --- a/code/components/miniz/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -FILE(GLOB_RECURSE app_sources ${CMAKE_CURRENT_SOURCE_DIR}/*.*) - -idf_component_register(SRCS ${app_sources} - INCLUDE_DIRS "." "../../include") - - diff --git a/code/dependencies.lock b/code/dependencies.lock index 6e6120b5..6d9f7a29 100644 --- a/code/dependencies.lock +++ b/code/dependencies.lock @@ -1,3 +1,3 @@ -manifest_hash: 4e37bb0f9273c4de05f38688720fe32aa6e5b892452694a4f7a2ca1659f02cf6 +manifest_hash: 63f5c6c9f0bcebc7b9ca12d2aa8b26b2c5f5218d377dc4b2375d9b9ca1df7815 target: esp32 version: 1.0.0 diff --git a/code/main/CMakeLists.txt b/code/main/CMakeLists.txt index e2572d5a..98f1088a 100644 --- a/code/main/CMakeLists.txt +++ b/code/main/CMakeLists.txt @@ -66,5 +66,4 @@ FILE(GLOB_RECURSE app_sources ${CMAKE_SOURCE_DIR}/main/*.*) idf_component_register(SRCS ${app_sources} INCLUDE_DIRS "." - # REQUIRES esp_psram) # comming in IDF 5.0 - ) \ No newline at end of file + REQUIRES esp_psram) \ No newline at end of file diff --git a/code/main/main.cpp b/code/main/main.cpp index 2889e34d..8b77d446 100644 --- a/code/main/main.cpp +++ b/code/main/main.cpp @@ -9,10 +9,9 @@ //#include "driver/gpio.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_chip_info.h" // SD-Card //////////////////// @@ -63,6 +62,11 @@ #endif #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 #include "esp32/himem.h" @@ -372,14 +376,14 @@ extern "C" void app_main(void) // 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"); setSystemStatusFlag(SYSTEM_STATUS_PSRAM_BAD); StatusLED(PSRAM_INIT, 1, true); } 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) + "MB / " + std::to_string(psram_size/1024/1024*8) + "MBit)"); diff --git a/code/main/server_main.cpp b/code/main/server_main.cpp index 1738f810..e69854c5 100644 --- a/code/main/server_main.cpp +++ b/code/main/server_main.cpp @@ -13,6 +13,7 @@ #include "version.h" #include "esp_wifi.h" +#include #include "MainFlowControl.h" #include "esp_log.h" @@ -24,6 +25,8 @@ httpd_handle_t server = NULL; std::string starttime = ""; +extern esp_netif_t *sta_netif; + static const char *TAG = "MAIN SERVER"; /* An HTTP GET handler */ @@ -350,11 +353,15 @@ esp_err_t sysinfo_handler(httpd_req_t *req) char freeheapmem[11]; 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; - 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("[{") + "\"firmware\": \"" + gitversion + "\"," + "\"buildtime\": \"" + buildtime + "\"," + @@ -364,7 +371,7 @@ esp_err_t sysinfo_handler(httpd_req_t *req) "\"html\": \"" + htmlversion + "\"," + "\"cputemp\": \"" + cputemp + "\"," + "\"hostname\": \"" + hostname + "\"," + - "\"IPv4\": \"" + ip4addr_ntoa(&ip_info.ip) + "\"," + + "\"IPv4\": \"" + string(ipFormated) + "\"," + "\"freeHeapMem\": \"" + freeheapmem + "\"" + "}]"; diff --git a/code/main/softAP.cpp b/code/main/softAP.cpp index 191bccf4..07a4506d 100644 --- a/code/main/softAP.cpp +++ b/code/main/softAP.cpp @@ -17,7 +17,7 @@ #include "freertos/task.h" #include "esp_mac.h" #include "esp_wifi.h" -#include "esp_event.h" + #include "esp_log.h" #include "nvs_flash.h" diff --git a/code/platformio.ini b/code/platformio.ini index ba172fe2..d26f4e10 100644 --- a/code/platformio.ini +++ b/code/platformio.ini @@ -19,7 +19,7 @@ [common:esp32-idf] extends = common:idf - platform = platformio/espressif32 @ 5.2.0 + platform = platformio/espressif32 @ 6.1.0 framework = espidf lib_deps = ${common:idf.lib_deps} diff --git a/code/sdkconfig.defaults b/code/sdkconfig.defaults index 9d15610f..1c8bec49 100644 --- a/code/sdkconfig.defaults +++ b/code/sdkconfig.defaults @@ -9,6 +9,7 @@ #CONFIG_ESP_WIFI_SOFTAP_SUPPORT=n #to save 28k of flash +CONFIG_ESP_TASK_WDT=n CONFIG_TASK_WDT=n CONFIG_TASK_WDT_CHECK_IDLE_TASK=n