3535#include "nvs_flash.h"
3636#include "settings.h"
3737
38+ #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL (5 , 3 , 0 )
39+ #include "driver/uart_vfs.h"
40+ #endif
41+
3842// Conditionally enable the logging tag variable only when it's used
3943#if defined(CONFIG_STORE_HISTORY ) || defined(CONFIG_HEAP_USE_HOOKS )
4044static const char * TAG = "main" ;
@@ -86,7 +90,13 @@ static void initialize_console() {
8690 setvbuf (stdin , NULL , _IONBF , 0 );
8791 setvbuf (stdout , NULL , _IONBF , 0 );
8892
89- #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL (4 , 3 , 0 )
93+ // These APIs vary depending on ESP-IDF version.
94+ #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL (5 , 3 , 0 )
95+ /* Minicom, screen, idf_monitor send CR when ENTER key is pressed */
96+ uart_vfs_dev_port_set_rx_line_endings (CONFIG_ESP_CONSOLE_UART_NUM , ESP_LINE_ENDINGS_CR );
97+ /* Move the caret to the beginning of the next line on '\n' */
98+ uart_vfs_dev_port_set_tx_line_endings (CONFIG_ESP_CONSOLE_UART_NUM , ESP_LINE_ENDINGS_CRLF );
99+ #elif ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL (4 , 3 , 0 )
90100 /* Minicom, screen, idf_monitor send CR when ENTER key is pressed */
91101 esp_vfs_dev_uart_port_set_rx_line_endings (CONFIG_ESP_CONSOLE_UART_NUM , ESP_LINE_ENDINGS_CR );
92102 /* Move the caret to the beginning of the next line on '\n' */
@@ -102,7 +112,11 @@ static void initialize_console() {
102112 ESP_ERROR_CHECK (uart_driver_install (CONFIG_CONSOLE_UART_NUM , 256 , 0 , 0 , NULL , 0 ));
103113
104114 /* Tell VFS to use UART driver */
115+ #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL (5 , 3 , 0 )
116+ uart_vfs_dev_use_driver (CONFIG_CONSOLE_UART_NUM );
117+ #else
105118 esp_vfs_dev_uart_use_driver (CONFIG_CONSOLE_UART_NUM );
119+ #endif
106120
107121 /* Initialize the console */
108122 esp_console_config_t console_config = {
@@ -173,7 +187,7 @@ static void prv_memfault_ota(void) {
173187
174188 int rv = memfault_esp_port_ota_update (& handler );
175189
176- #if MEMFAULT_METRICS_SYNC_SUCCESS
190+ #if defined( CONFIG_MEMFAULT_METRICS_SYNC_SUCCESS )
177191 // Record the OTA check result using the built-in sync success metric
178192 if (rv == 0 || rv == 1 ) {
179193 memfault_metrics_connectivity_record_sync_success ();
0 commit comments