From 2c21a0b322f9f9bc9823134734fd8b2c33944454 Mon Sep 17 00:00:00 2001 From: YuXifeng <2860280851@qq.com> Date: Sat, 15 Mar 2025 22:17:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=BD=91=E9=A1=B5=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main/CMakeLists.txt | 12 +- main/main.c | 253 +--------------------- main/wifi/wifi_ap.c | 70 ++++++ main/wifi/wifi_html.c | 296 ++++++++++++++++++++++++++ main/wifi/wifi_sta.c | 116 ++++++++++ main/wifi/wifi_task.c | 142 ++++++++++++ main/wifi/wifi_task.h | 34 +++ main/wifi/www/file_server.html | 80 +++++++ main/wifi/www/home.html | 96 +++++++++ main/wifi/www/upload_script.html | 129 +++++++++++ main/wifi/www/upload_script_copy.html | 82 +++++++ main/wifi/www/wifi.html | 47 ++++ main/wifi/www/wifi_config.html | 84 ++++++++ sdkconfig | 30 +-- sdkconfig.old | 23 +- 15 files changed, 1227 insertions(+), 267 deletions(-) create mode 100644 main/wifi/wifi_ap.c create mode 100644 main/wifi/wifi_html.c create mode 100644 main/wifi/wifi_sta.c create mode 100644 main/wifi/wifi_task.c create mode 100644 main/wifi/wifi_task.h create mode 100644 main/wifi/www/file_server.html create mode 100644 main/wifi/www/home.html create mode 100644 main/wifi/www/upload_script.html create mode 100644 main/wifi/www/upload_script_copy.html create mode 100644 main/wifi/www/wifi.html create mode 100644 main/wifi/www/wifi_config.html diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt index 5134a91..cecdbf6 100755 --- a/main/CMakeLists.txt +++ b/main/CMakeLists.txt @@ -1,2 +1,10 @@ -idf_component_register(SRCS "usb_serial_echo_main.c" - INCLUDE_DIRS ".") + +file(GLOB PORT_SRCS "wifi/*.c" ) + +file(GLOB HTML_SRCS "wifi/www/*.html" ) + + +idf_component_register(SRCS "main.c" ${PORT_SRCS} + EMBED_FILES ${HTML_SRCS} + INCLUDE_DIRS "." + INCLUDE_DIRS "wifi/") diff --git a/main/main.c b/main/main.c index cf6383c..158d0ef 100755 --- a/main/main.c +++ b/main/main.c @@ -31,11 +31,8 @@ #include "driver/uart.h" #include "driver/gpio.h" -static const char *TAG = "uart_events"; +#include "wifi_task.h" -#define EXAMPLE_ESP_WIFI_SSID "RONGTA" -#define EXAMPLE_ESP_WIFI_PASS "rongta305" -#define EXAMPLE_ESP_MAXIMUM_RETRY 5 #define EX_UART_NUM UART_NUM_0 #define PATTERN_CHR_NUM (3) /*!< Set the number of consecutive and identical characters received by receiver which defines a UART pattern*/ @@ -45,239 +42,8 @@ static const char *TAG = "uart_events"; #define RD_BUF_SIZE (BUF_SIZE) static QueueHandle_t uart0_queue; -/* FreeRTOS event group to signal when we are connected*/ -static EventGroupHandle_t s_wifi_event_group; -static int s_retry_num = 0; - -#define WIFI_CONNECTED_BIT BIT0 -#define WIFI_FAIL_BIT BIT1 - - -static void event_handler(void* arg, esp_event_base_t event_base, - int32_t event_id, void* event_data) -{ - if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_START) { - esp_wifi_connect(); - } else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_DISCONNECTED) { - if (s_retry_num < EXAMPLE_ESP_MAXIMUM_RETRY) { - esp_wifi_connect(); - s_retry_num++; - ESP_LOGI(TAG, "retry to connect to the AP"); - } else { - xEventGroupSetBits(s_wifi_event_group, WIFI_FAIL_BIT); - } - ESP_LOGI(TAG,"connect to the AP fail"); - } else if (event_base == IP_EVENT && event_id == IP_EVENT_STA_GOT_IP) { - ip_event_got_ip_t* event = (ip_event_got_ip_t*) event_data; - ESP_LOGI(TAG, "got ip:" IPSTR, IP2STR(&event->ip_info.ip)); - s_retry_num = 0; - xEventGroupSetBits(s_wifi_event_group, WIFI_CONNECTED_BIT); - } -} - -void wifi_init_sta(void) -{ - s_wifi_event_group = xEventGroupCreate(); - - esp_netif_create_default_wifi_sta(); - - wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); - ESP_ERROR_CHECK(esp_wifi_init(&cfg)); - - esp_event_handler_instance_t instance_any_id; - esp_event_handler_instance_t instance_got_ip; - ESP_ERROR_CHECK(esp_event_handler_instance_register(WIFI_EVENT, - ESP_EVENT_ANY_ID, - &event_handler, - NULL, - &instance_any_id)); - ESP_ERROR_CHECK(esp_event_handler_instance_register(IP_EVENT, - IP_EVENT_STA_GOT_IP, - &event_handler, - NULL, - &instance_got_ip)); - - wifi_config_t wifi_config = { - .sta = { - .ssid = EXAMPLE_ESP_WIFI_SSID, - .password = EXAMPLE_ESP_WIFI_PASS, - /* Authmode threshold resets to WPA2 as default if password matches WPA2 standards (password len => 8). - * If you want to connect the device to deprecated WEP/WPA networks, Please set the threshold value - * to WIFI_AUTH_WEP/WIFI_AUTH_WPA_PSK and set the password with length and format matching to - * WIFI_AUTH_WEP/WIFI_AUTH_WPA_PSK standards. - */ - .threshold.authmode = WIFI_AUTH_WPA2_PSK, - .sae_pwe_h2e = WPA3_SAE_PWE_BOTH, - .sae_h2e_identifier = "", - }, - }; - ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA) ); - ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, &wifi_config) ); - ESP_ERROR_CHECK(esp_wifi_start() ); - - ESP_LOGI(TAG, "wifi_init_sta finished."); - - /* Waiting until either the connection is established (WIFI_CONNECTED_BIT) or connection failed for the maximum - * number of re-tries (WIFI_FAIL_BIT). The bits are set by event_handler() (see above) */ - EventBits_t bits = xEventGroupWaitBits(s_wifi_event_group, - WIFI_CONNECTED_BIT | WIFI_FAIL_BIT, - pdFALSE, - pdFALSE, - portMAX_DELAY); - - /* xEventGroupWaitBits() returns the bits before the call returned, hence we can test which event actually - * happened. */ - if (bits & WIFI_CONNECTED_BIT) { - ESP_LOGI(TAG, "connected to ap SSID:%s password:%s", - EXAMPLE_ESP_WIFI_SSID, EXAMPLE_ESP_WIFI_PASS); - } else if (bits & WIFI_FAIL_BIT) { - ESP_LOGI(TAG, "Failed to connect to SSID:%s, password:%s", - EXAMPLE_ESP_WIFI_SSID, EXAMPLE_ESP_WIFI_PASS); - } else { - ESP_LOGE(TAG, "UNEXPECTED EVENT"); - } -} - - -#define PORT 23 -#define KEEPALIVE_IDLE 5 -#define KEEPALIVE_INTERVAL 5 -#define KEEPALIVE_COUNT 3 - - -static void do_retransmit(const int sock) -{ - int len; - char rx_buffer[128]; - - do { - len = recv(sock, rx_buffer, sizeof(rx_buffer) - 1, 0); - if (len < 0) { - ESP_LOGE(TAG, "Error occurred during receiving: errno %d", errno); - } else if (len == 0) { - ESP_LOGW(TAG, "Connection closed"); - } else { - rx_buffer[len] = 0; // Null-terminate whatever is received and treat it like a string - ESP_LOGI(TAG, "Received %d bytes: %s", len, rx_buffer); - // uart_write_bytes(EX_UART_NUM, (const char *) rx_buffer, len); - // send() can return less bytes than supplied length. - // Walk-around for robust implementation. - // int to_write = len; - // while (to_write > 0) { - // int written = uart_write_bytes(EX_UART_NUM, (const char *) (rx_buffer + (len - to_write)), to_write); - // // int written = send(sock, rx_buffer + (len - to_write), to_write, 0); - // // if (written < 0) { - // // ESP_LOGE(TAG, "Error occurred during sending: errno %d", errno); - // // // Failed to retransmit, giving up - // // return; - // // } - // to_write -= written; - // } - } - } while (len > 0); -} -static int sock; -static void tcp_server_task(void *pvParameters) -{ - char addr_str[128]; - int addr_family = (int)pvParameters; - int ip_protocol = 0; - int keepAlive = 1; - int keepIdle = KEEPALIVE_IDLE; - int keepInterval = KEEPALIVE_INTERVAL; - int keepCount = KEEPALIVE_COUNT; - struct sockaddr_storage dest_addr; - -#ifdef CONFIG_LWIP_IPV4 - if (addr_family == AF_INET) { - struct sockaddr_in *dest_addr_ip4 = (struct sockaddr_in *)&dest_addr; - dest_addr_ip4->sin_addr.s_addr = htonl(INADDR_ANY); - dest_addr_ip4->sin_family = AF_INET; - dest_addr_ip4->sin_port = htons(PORT); - ip_protocol = IPPROTO_IP; - } -#endif -#ifdef CONFIG_EXAMPLE_IPV6 - if (addr_family == AF_INET6) { - struct sockaddr_in6 *dest_addr_ip6 = (struct sockaddr_in6 *)&dest_addr; - bzero(&dest_addr_ip6->sin6_addr.un, sizeof(dest_addr_ip6->sin6_addr.un)); - dest_addr_ip6->sin6_family = AF_INET6; - dest_addr_ip6->sin6_port = htons(PORT); - ip_protocol = IPPROTO_IPV6; - } -#endif - - int listen_sock = socket(addr_family, SOCK_STREAM, ip_protocol); - if (listen_sock < 0) { - ESP_LOGE(TAG, "Unable to create socket: errno %d", errno); - vTaskDelete(NULL); - return; - } - int opt = 1; - setsockopt(listen_sock, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)); -#if defined(CONFIG_EXAMPLE_IPV4) && defined(CONFIG_EXAMPLE_IPV6) - // Note that by default IPV6 binds to both protocols, it is must be disabled - // if both protocols used at the same time (used in CI) - setsockopt(listen_sock, IPPROTO_IPV6, IPV6_V6ONLY, &opt, sizeof(opt)); -#endif - - ESP_LOGI(TAG, "Socket created"); - - int err = bind(listen_sock, (struct sockaddr *)&dest_addr, sizeof(dest_addr)); - if (err != 0) { - ESP_LOGE(TAG, "Socket unable to bind: errno %d", errno); - ESP_LOGE(TAG, "IPPROTO: %d", addr_family); - goto CLEAN_UP; - } - ESP_LOGI(TAG, "Socket bound, port %d", PORT); - - err = listen(listen_sock, 1); - if (err != 0) { - ESP_LOGE(TAG, "Error occurred during listen: errno %d", errno); - goto CLEAN_UP; - } - - while (1) { - - ESP_LOGI(TAG, "Socket listening"); - - struct sockaddr_storage source_addr; // Large enough for both IPv4 or IPv6 - socklen_t addr_len = sizeof(source_addr); - sock = accept(listen_sock, (struct sockaddr *)&source_addr, &addr_len); - if (sock < 0) { - ESP_LOGE(TAG, "Unable to accept connection: errno %d", errno); - break; - } - - // Set tcp keepalive option - setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, &keepAlive, sizeof(int)); - setsockopt(sock, IPPROTO_TCP, TCP_KEEPIDLE, &keepIdle, sizeof(int)); - setsockopt(sock, IPPROTO_TCP, TCP_KEEPINTVL, &keepInterval, sizeof(int)); - setsockopt(sock, IPPROTO_TCP, TCP_KEEPCNT, &keepCount, sizeof(int)); - // Convert ip address to string -#ifdef CONFIG_EXAMPLE_IPV4 - if (source_addr.ss_family == PF_INET) { - inet_ntoa_r(((struct sockaddr_in *)&source_addr)->sin_addr, addr_str, sizeof(addr_str) - 1); - } -#endif -#ifdef CONFIG_EXAMPLE_IPV6 - if (source_addr.ss_family == PF_INET6) { - inet6_ntoa_r(((struct sockaddr_in6 *)&source_addr)->sin6_addr, addr_str, sizeof(addr_str) - 1); - } -#endif - ESP_LOGI(TAG, "Socket accepted ip address: %s", addr_str); - - do_retransmit(sock); - - shutdown(sock, 0); - close(sock); - } - -CLEAN_UP: - close(listen_sock); - vTaskDelete(NULL); -} +static const char *TAG = "main"; static void echo_task(void *arg) @@ -420,18 +186,21 @@ void app_main(void) }; // ESP_ERROR_CHECK(uart_set_pin(UART_NUM_1, 4, 5, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE)); //Install UART driver, and get the queue. - uart_driver_install(EX_UART_NUM, BUF_SIZE * 2, BUF_SIZE * 2, 20, &uart0_queue, 0); - uart_param_config(EX_UART_NUM, &uart_config); - xTaskCreate(echo_task, "USB SERIAL JTAG_echo_task", ECHO_TASK_STACK_SIZE, NULL, 10, NULL); + // uart_driver_install(EX_UART_NUM, BUF_SIZE * 2, BUF_SIZE * 2, 20, &uart0_queue, 0); + // uart_param_config(EX_UART_NUM, &uart_config); + // xTaskCreate(echo_task, "USB SERIAL JTAG_echo_task", ECHO_TASK_STACK_SIZE, NULL, 10, NULL); //Create a task to handler UART event from ISR - xTaskCreate(uart_event_task, "uart_event_task", 2048*10, NULL, 12, NULL); + // xTaskCreate(uart_event_task, "uart_event_task", 2048*10, NULL, 12, NULL); // ESP_LOGI(TAG, "ESP_WIFI_MODE_STA"); - // wifi_init_sta(); + wifi_init_softap(); + vTaskDelay(1000/ portTICK_PERIOD_MS); + start_web_server(); // xTaskCreate(tcp_server_task, "tcp_server", 4096, (void*)AF_INET, 5, NULL); + #if 0 const loader_esp32_config_t config = { .baud_rate = 115200, .uart_port = UART_NUM_1, @@ -452,5 +221,5 @@ void app_main(void) }else{ ESP_LOGE(TAG, "connect_to_target initialization failed."); } - + #endif } diff --git a/main/wifi/wifi_ap.c b/main/wifi/wifi_ap.c new file mode 100644 index 0000000..61f5793 --- /dev/null +++ b/main/wifi/wifi_ap.c @@ -0,0 +1,70 @@ +#include "wifi_task.h" + +static const char *TAG = "wifi softAP"; + +#define EXAMPLE_ESP_WIFI_SSID "ESP32_Online_Link" +#define EXAMPLE_ESP_WIFI_PASS "12345678" +#define EXAMPLE_ESP_WIFI_CHANNEL 1 +#define EXAMPLE_MAX_STA_CONN 4 + + +static void wifi_event_handler(void* arg, esp_event_base_t event_base, + int32_t event_id, void* event_data) +{ + if (event_id == WIFI_EVENT_AP_STACONNECTED) { + wifi_event_ap_staconnected_t* event = (wifi_event_ap_staconnected_t*) event_data; + ESP_LOGI(TAG, "station "MACSTR" join, AID=%d", + MAC2STR(event->mac), event->aid); + } else if (event_id == WIFI_EVENT_AP_STADISCONNECTED) { + wifi_event_ap_stadisconnected_t* event = (wifi_event_ap_stadisconnected_t*) event_data; + ESP_LOGI(TAG, "station "MACSTR" leave, AID=%d, reason=%d", + MAC2STR(event->mac), event->aid, event->reason); + } +} + +void wifi_init_softap(void) +{ + // ESP_ERROR_CHECK(esp_netif_init()); + // ESP_ERROR_CHECK(esp_event_loop_create_default()); + esp_netif_create_default_wifi_ap(); + + wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); + ESP_ERROR_CHECK(esp_wifi_init(&cfg)); + + ESP_ERROR_CHECK(esp_event_handler_instance_register(WIFI_EVENT, + ESP_EVENT_ANY_ID, + &wifi_event_handler, + NULL, + NULL)); + + wifi_config_t wifi_config = { + .ap = { + .ssid = EXAMPLE_ESP_WIFI_SSID, + .ssid_len = strlen(EXAMPLE_ESP_WIFI_SSID), + .channel = EXAMPLE_ESP_WIFI_CHANNEL, + .password = EXAMPLE_ESP_WIFI_PASS, + .max_connection = EXAMPLE_MAX_STA_CONN, +#ifdef CONFIG_ESP_WIFI_SOFTAP_SAE_SUPPORT + .authmode = WIFI_AUTH_WPA3_PSK, + .sae_pwe_h2e = WPA3_SAE_PWE_BOTH, +#else /* CONFIG_ESP_WIFI_SOFTAP_SAE_SUPPORT */ + .authmode = WIFI_AUTH_WPA2_PSK, +#endif + .pmf_cfg = { + .required = true, + }, + }, + }; + if (strlen(EXAMPLE_ESP_WIFI_PASS) == 0) { + wifi_config.ap.authmode = WIFI_AUTH_OPEN; + } + + ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_AP)); + ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_AP, &wifi_config)); + ESP_ERROR_CHECK(esp_wifi_start()); + + ESP_LOGI(TAG, "wifi_init_softap finished. SSID:%s password:%s channel:%d", + EXAMPLE_ESP_WIFI_SSID, EXAMPLE_ESP_WIFI_PASS, EXAMPLE_ESP_WIFI_CHANNEL); +} + + diff --git a/main/wifi/wifi_html.c b/main/wifi/wifi_html.c new file mode 100644 index 0000000..af39c69 --- /dev/null +++ b/main/wifi/wifi_html.c @@ -0,0 +1,296 @@ +#include "wifi_task.h" +#include "esp_http_server.h" +#include "esp_vfs.h" + +#include "cJSON.h" +static const char *TAG = "wifi_html"; + + +static esp_err_t index_get_handler(httpd_req_t *req) +{ + extern const unsigned char wifi_config_start[] asm("_binary_wifi_html_start"); + extern const unsigned char wifi_config_end[] asm("_binary_wifi_html_end"); + const size_t wifi_config_size = (wifi_config_end - wifi_config_start); + + /* Add file upload form and script which on execution sends a POST request to /upload */ + httpd_resp_set_type(req,HTTPD_TYPE_TEXT); + httpd_resp_send(req, (const char *)wifi_config_start, wifi_config_size); + return ESP_OK; +} + +static esp_err_t Home_get_handler(httpd_req_t *req) +{ + extern const unsigned char home_start[] asm("_binary_home_html_start"); + extern const unsigned char home_end[] asm("_binary_home_html_end"); + const size_t home_size = (home_end - home_start); + + /* Add file upload form and script which on execution sends a POST request to /upload */ + httpd_resp_set_type(req,HTTPD_TYPE_TEXT); + httpd_resp_send(req, (const char *)home_start, home_size); + return ESP_OK; + +} + +static esp_err_t upgrade_ota_bin(httpd_req_t *req) +{ + extern const unsigned char upload_script_start[] asm("_binary_upload_script_html_start"); + extern const unsigned char upload_script_end[] asm("_binary_upload_script_html_end"); + const size_t upload_script_size = (upload_script_end - upload_script_start); + + /* Add file upload form and script which on execution sends a POST request to /upload */ + httpd_resp_set_type(req,HTTPD_TYPE_TEXT); + httpd_resp_send(req, (const char *)upload_script_start, upload_script_size); + return ESP_OK; +} + +static esp_err_t Save_file_handler(httpd_req_t *req) +{ + + extern const unsigned char file_server_start[] asm("_binary_file_server_html_start"); + extern const unsigned char file_server_end[] asm("_binary_file_server_html_end"); + const size_t file_server_size = (file_server_end - file_server_start); + + /* Add file upload form and script which on execution sends a POST request to /upload */ + httpd_resp_set_type(req,HTTPD_TYPE_TEXT); + httpd_resp_send(req, (const char *)file_server_start, file_server_size); + return ESP_OK; +} + +char wifi_name[20] = {0}; +char wifi_password[12] = {0}; +static esp_err_t echo_post_handler(httpd_req_t *req) +{ + char buf[100]; + // char ssid[10]; + // char pswd[10]; + bool wifi_write = false; + int ret, remaining = req->content_len; + ESP_LOGI(TAG,"req->content_len:%d",req->content_len); + while (remaining > 0) { + /* Read the data for the request */ + if ((ret = httpd_req_recv(req, buf, + MIN(remaining, sizeof(buf)))) <= 0) { + if (ret == HTTPD_SOCK_ERR_TIMEOUT) { + /* Retry receiving if timeout occurred */ + continue; + } + return ESP_FAIL; + } + + /* Send back the same data */ + httpd_resp_send_chunk(req, buf, ret); + remaining -= ret; + + cJSON *root = cJSON_Parse(buf); + // int ssid = cJSON_GetObjectItem(root, "wifi_name")->valueint; + // int code = cJSON_GetObjectItem(root, "wifi_code")->valueint; + + char *ssid = cJSON_GetObjectItem(root, "wifi_name")->valuestring; + char *code = cJSON_GetObjectItem(root, "wifi_code")->valuestring; + int len1 = strlen(ssid); + int len2 = strlen(code); + memcpy(wifi_name,ssid,strlen(ssid)); + memcpy(wifi_password,code,strlen(code)); + wifi_name[len1] = '\0'; + wifi_password[len2] = '\0'; + cJSON_Delete(root); + // ESP_LOGI(TAG, "json load finished. SSID:%d password:%d ",ssid,code); + // ESP_LOGI(TAG, "json load finished. SSID:%s password:%s ",user_id,user_code); + printf("\r\nwifi_ssid:"); + for(int i = 0;icontent_len; + char* buff; + uint16_t received = 0; + + //ota_bin_data.buf = malloc(8192); + + ESP_LOGI(TAG,"req->url:%s",req->uri); + ESP_LOGI(TAG,"req->content_len:%d",req->content_len); + // if(Search_Binfile(req->uri,strlen(req->uri)) == true) + // { + // //ESP_LOGI(TAG,"received:%d",received); + // buff = (char*)ota_tx_data.data; + // ota_tx_data.type = TYPE_MES_HEAD; + // ota_tx_data.size = req->content_len; + // xQueueSend(ota_data_queue, &ota_tx_data, portMAX_DELAY); + // xEventGroupSetBits(esp_event_group,OTA_EVENT); + // while (remaining > 0) + // { + // if ((received = httpd_req_recv(req, &buff[0], MIN(remaining, 4096)))) + // { + // ota_tx_data.type = TYPE_WIFI_HTTP; + // // ota_bin_data.buf[received] = '\0'; + // ota_tx_data.size = received; + // //ESP_LOGI(TAG,"received:%d %c",received,http_file_data.buf[0]); + // xQueueSend(ota_data_queue, &ota_tx_data, portMAX_DELAY); + // remaining -= received; + // } + // } + // }else{ + // buff = http_file_data.buff; + // sprintf(http_file_data.file_name,req->uri); + // http_file_data.type = TYPE_START_OTA; + // http_file_data.file_size = req->content_len; + // xQueueSend(web_data_queue, &http_file_data, portMAX_DELAY); + // while (remaining > 0) + // { + // if ((received = httpd_req_recv(req, &buff[0], MIN(remaining, 8192)))) + // { + // http_file_data.type = TYPE_START_OTA|TYPE_DATA; + // // ota_bin_data.buf[received] = '\0'; + // http_file_data.buff_size = received; + // //ESP_LOGI(TAG,"received:%d %c",received,http_file_data.buf[0]); + // xQueueSend(web_data_queue, &http_file_data, portMAX_DELAY); + // remaining -= received; + // } + // } + // } + + + //free(ota_bin_data.buf); + ESP_LOGI(TAG,"upgrade ok %d",remaining); + /* Redirect onto root to see the updated file list */ + httpd_resp_set_status(req, "303 See Other"); + httpd_resp_set_hdr(req, "Location", "/ota"); + httpd_resp_sendstr(req, "File uploaded successfully"); + return ESP_OK; +} + +/* Scratch buffer size */ +#define SCRATCH_BUFSIZE 8192 + +struct file_server_data { + /* Base path of file storage */ + char base_path[ESP_VFS_PATH_MAX + 1]; + + /* Scratch buffer for temporary storage during file transfer */ + char scratch[SCRATCH_BUFSIZE]; +}; + +esp_err_t start_web_server(void) +{ + static struct file_server_data *server_data = NULL; + /* Allocate memory for server data */ + server_data = calloc(1, sizeof(struct file_server_data)); + if (!server_data) { + ESP_LOGE(TAG, "Failed to allocate memory for server data"); + return ESP_ERR_NO_MEM; + } + strlcpy(server_data->base_path, "/data", + sizeof(server_data->base_path)); + httpd_handle_t server = NULL; + httpd_config_t config = HTTPD_DEFAULT_CONFIG(); + /* Use the URI wildcard matching function in order to + * allow the same handler to respond to multiple different + * target URIs which match the wildcard scheme */ + + config.uri_match_fn = httpd_uri_match_wildcard; + + ESP_LOGI(TAG, "Starting HTTP Server"); + if (httpd_start(&server, &config) != ESP_OK) { + ESP_LOGE(TAG, "Failed to start file server!"); + return ESP_FAIL; + } + + //start_file_server("/sdcard",server); + //return ESP_OK; + httpd_uri_t index_page = { + .uri = "/", //192.168.1.4 + .method = HTTP_GET, + .handler = Home_get_handler, + /* Let's pass response string in user + * context to demonstrate it's usage */ + .user_ctx = server_data + }; + httpd_register_uri_handler(server, &index_page); + // httpd_uri_t upgrade_ota = { + // .uri = "/ota", //192.168.1.4 + // .method = HTTP_GET, + // .handler = upgrade_ota_bin, + // /* Let's pass response string in user + // * context to demonstrate it's usage */ + // .user_ctx = NULL, + // }; + // httpd_register_uri_handler(server, &upgrade_ota); + + httpd_uri_t home_page = { + .uri = "/config", //192.168.1.4 + .method = HTTP_GET, + .handler = index_get_handler, + /* Let's pass response string in user + * context to demonstrate it's usage */ + .user_ctx = NULL, + }; + httpd_register_uri_handler(server, &home_page); + + httpd_uri_t echo = { + .uri = "/config", + .method = HTTP_POST, + .handler = echo_post_handler, + .user_ctx = server_data, + }; + httpd_register_uri_handler(server, &echo); + + // static const httpd_uri_t upgrade_post = { + // .uri = "/upload/*", + // .method = HTTP_POST, + // .handler = upgrade_post_handler, + // .user_ctx = NULL + // }; + // httpd_register_uri_handler(server, &upgrade_post); + + return ESP_OK; +} \ No newline at end of file diff --git a/main/wifi/wifi_sta.c b/main/wifi/wifi_sta.c new file mode 100644 index 0000000..56faae9 --- /dev/null +++ b/main/wifi/wifi_sta.c @@ -0,0 +1,116 @@ +#include "wifi_task.h" + + +static const char *TAG = "wifi_sta"; + +#define EXAMPLE_ESP_WIFI_SSID "Yu886" +#define EXAMPLE_ESP_WIFI_PASS "2023yu2023" +#define EXAMPLE_ESP_MAXIMUM_RETRY 5 + + +/* FreeRTOS event group to signal when we are connected*/ +static EventGroupHandle_t s_wifi_event_group; + +static int s_retry_num = 0; + +#define WIFI_CONNECTED_BIT BIT0 +#define WIFI_FAIL_BIT BIT1 + + +static void event_handler(void *arg, esp_event_base_t event_base, + int32_t event_id, void *event_data) +{ + if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_START) + { + esp_wifi_connect(); + } + else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_DISCONNECTED) + { + if (s_retry_num < EXAMPLE_ESP_MAXIMUM_RETRY) + { + esp_wifi_connect(); + s_retry_num++; + ESP_LOGI(TAG, "retry to connect to the AP"); + } + else + { + xEventGroupSetBits(s_wifi_event_group, WIFI_FAIL_BIT); + } + ESP_LOGI(TAG, "connect to the AP fail"); + } + else if (event_base == IP_EVENT && event_id == IP_EVENT_STA_GOT_IP) + { + ip_event_got_ip_t *event = (ip_event_got_ip_t *)event_data; + ESP_LOGI(TAG, "got ip:" IPSTR, IP2STR(&event->ip_info.ip)); + s_retry_num = 0; + xEventGroupSetBits(s_wifi_event_group, WIFI_CONNECTED_BIT); + } +} + +void wifi_init_station(void) +{ + s_wifi_event_group = xEventGroupCreate(); + + esp_netif_create_default_wifi_sta(); + + wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); + ESP_ERROR_CHECK(esp_wifi_init(&cfg)); + + esp_event_handler_instance_t instance_any_id; + esp_event_handler_instance_t instance_got_ip; + ESP_ERROR_CHECK(esp_event_handler_instance_register(WIFI_EVENT, + ESP_EVENT_ANY_ID, + &event_handler, + NULL, + &instance_any_id)); + ESP_ERROR_CHECK(esp_event_handler_instance_register(IP_EVENT, + IP_EVENT_STA_GOT_IP, + &event_handler, + NULL, + &instance_got_ip)); + + wifi_config_t wifi_config = { + .sta = { + .ssid = EXAMPLE_ESP_WIFI_SSID, + .password = EXAMPLE_ESP_WIFI_PASS, + /* Authmode threshold resets to WPA2 as default if password matches WPA2 standards (password len => 8). + * If you want to connect the device to deprecated WEP/WPA networks, Please set the threshold value + * to WIFI_AUTH_WEP/WIFI_AUTH_WPA_PSK and set the password with length and format matching to + * WIFI_AUTH_WEP/WIFI_AUTH_WPA_PSK standards. + */ + .threshold.authmode = WIFI_AUTH_WPA2_PSK, + .sae_pwe_h2e = WPA3_SAE_PWE_BOTH, + .sae_h2e_identifier = "", + }, + }; + ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA)); + ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, &wifi_config)); + ESP_ERROR_CHECK(esp_wifi_start()); + + ESP_LOGI(TAG, "wifi_init_sta finished."); + + /* Waiting until either the connection is established (WIFI_CONNECTED_BIT) or connection failed for the maximum + * number of re-tries (WIFI_FAIL_BIT). The bits are set by event_handler() (see above) */ + EventBits_t bits = xEventGroupWaitBits(s_wifi_event_group, + WIFI_CONNECTED_BIT | WIFI_FAIL_BIT, + pdFALSE, + pdFALSE, + portMAX_DELAY); + + /* xEventGroupWaitBits() returns the bits before the call returned, hence we can test which event actually + * happened. */ + if (bits & WIFI_CONNECTED_BIT) + { + ESP_LOGI(TAG, "connected to ap SSID:%s password:%s", + EXAMPLE_ESP_WIFI_SSID, EXAMPLE_ESP_WIFI_PASS); + } + else if (bits & WIFI_FAIL_BIT) + { + ESP_LOGI(TAG, "Failed to connect to SSID:%s, password:%s", + EXAMPLE_ESP_WIFI_SSID, EXAMPLE_ESP_WIFI_PASS); + } + else + { + ESP_LOGE(TAG, "UNEXPECTED EVENT"); + } +} diff --git a/main/wifi/wifi_task.c b/main/wifi/wifi_task.c new file mode 100644 index 0000000..cabb842 --- /dev/null +++ b/main/wifi/wifi_task.c @@ -0,0 +1,142 @@ +#include "wifi_task.h" + +static const char *TAG = "wifi_task"; + +#define PORT 23 +#define KEEPALIVE_IDLE 5 +#define KEEPALIVE_INTERVAL 5 +#define KEEPALIVE_COUNT 3 + + +static void do_retransmit(const int sock) +{ + int len; + char rx_buffer[128]; + + do { + len = recv(sock, rx_buffer, sizeof(rx_buffer) - 1, 0); + if (len < 0) { + ESP_LOGE(TAG, "Error occurred during receiving: errno %d", errno); + } else if (len == 0) { + ESP_LOGW(TAG, "Connection closed"); + } else { + rx_buffer[len] = 0; // Null-terminate whatever is received and treat it like a string + ESP_LOGI(TAG, "Received %d bytes: %s", len, rx_buffer); + // uart_write_bytes(EX_UART_NUM, (const char *) rx_buffer, len); + // send() can return less bytes than supplied length. + // Walk-around for robust implementation. + // int to_write = len; + // while (to_write > 0) { + // int written = uart_write_bytes(EX_UART_NUM, (const char *) (rx_buffer + (len - to_write)), to_write); + // // int written = send(sock, rx_buffer + (len - to_write), to_write, 0); + // // if (written < 0) { + // // ESP_LOGE(TAG, "Error occurred during sending: errno %d", errno); + // // // Failed to retransmit, giving up + // // return; + // // } + // to_write -= written; + // } + } + } while (len > 0); +} +static int sock; +static void tcp_server_task(void *pvParameters) +{ + char addr_str[128]; + int addr_family = (int)pvParameters; + int ip_protocol = 0; + int keepAlive = 1; + int keepIdle = KEEPALIVE_IDLE; + int keepInterval = KEEPALIVE_INTERVAL; + int keepCount = KEEPALIVE_COUNT; + struct sockaddr_storage dest_addr; + +#ifdef CONFIG_LWIP_IPV4 + if (addr_family == AF_INET) { + struct sockaddr_in *dest_addr_ip4 = (struct sockaddr_in *)&dest_addr; + dest_addr_ip4->sin_addr.s_addr = htonl(INADDR_ANY); + dest_addr_ip4->sin_family = AF_INET; + dest_addr_ip4->sin_port = htons(PORT); + ip_protocol = IPPROTO_IP; + } +#endif +#ifdef CONFIG_EXAMPLE_IPV6 + if (addr_family == AF_INET6) { + struct sockaddr_in6 *dest_addr_ip6 = (struct sockaddr_in6 *)&dest_addr; + bzero(&dest_addr_ip6->sin6_addr.un, sizeof(dest_addr_ip6->sin6_addr.un)); + dest_addr_ip6->sin6_family = AF_INET6; + dest_addr_ip6->sin6_port = htons(PORT); + ip_protocol = IPPROTO_IPV6; + } +#endif + + int listen_sock = socket(addr_family, SOCK_STREAM, ip_protocol); + if (listen_sock < 0) { + ESP_LOGE(TAG, "Unable to create socket: errno %d", errno); + vTaskDelete(NULL); + return; + } + int opt = 1; + setsockopt(listen_sock, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)); +#if defined(CONFIG_EXAMPLE_IPV4) && defined(CONFIG_EXAMPLE_IPV6) + // Note that by default IPV6 binds to both protocols, it is must be disabled + // if both protocols used at the same time (used in CI) + setsockopt(listen_sock, IPPROTO_IPV6, IPV6_V6ONLY, &opt, sizeof(opt)); +#endif + + ESP_LOGI(TAG, "Socket created"); + + int err = bind(listen_sock, (struct sockaddr *)&dest_addr, sizeof(dest_addr)); + if (err != 0) { + ESP_LOGE(TAG, "Socket unable to bind: errno %d", errno); + ESP_LOGE(TAG, "IPPROTO: %d", addr_family); + goto CLEAN_UP; + } + ESP_LOGI(TAG, "Socket bound, port %d", PORT); + + err = listen(listen_sock, 1); + if (err != 0) { + ESP_LOGE(TAG, "Error occurred during listen: errno %d", errno); + goto CLEAN_UP; + } + + while (1) { + + ESP_LOGI(TAG, "Socket listening"); + + struct sockaddr_storage source_addr; // Large enough for both IPv4 or IPv6 + socklen_t addr_len = sizeof(source_addr); + sock = accept(listen_sock, (struct sockaddr *)&source_addr, &addr_len); + if (sock < 0) { + ESP_LOGE(TAG, "Unable to accept connection: errno %d", errno); + break; + } + + // Set tcp keepalive option + setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, &keepAlive, sizeof(int)); + setsockopt(sock, IPPROTO_TCP, TCP_KEEPIDLE, &keepIdle, sizeof(int)); + setsockopt(sock, IPPROTO_TCP, TCP_KEEPINTVL, &keepInterval, sizeof(int)); + setsockopt(sock, IPPROTO_TCP, TCP_KEEPCNT, &keepCount, sizeof(int)); + // Convert ip address to string +#ifdef CONFIG_EXAMPLE_IPV4 + if (source_addr.ss_family == PF_INET) { + inet_ntoa_r(((struct sockaddr_in *)&source_addr)->sin_addr, addr_str, sizeof(addr_str) - 1); + } +#endif +#ifdef CONFIG_EXAMPLE_IPV6 + if (source_addr.ss_family == PF_INET6) { + inet6_ntoa_r(((struct sockaddr_in6 *)&source_addr)->sin6_addr, addr_str, sizeof(addr_str) - 1); + } +#endif + ESP_LOGI(TAG, "Socket accepted ip address: %s", addr_str); + + do_retransmit(sock); + + shutdown(sock, 0); + close(sock); + } + +CLEAN_UP: + close(listen_sock); + vTaskDelete(NULL); +} diff --git a/main/wifi/wifi_task.h b/main/wifi/wifi_task.h new file mode 100644 index 0000000..f4899a8 --- /dev/null +++ b/main/wifi/wifi_task.h @@ -0,0 +1,34 @@ +#ifndef WIFI_TASK_H +#define WIFI_TASK_H + +#include "stdio.h" +#include +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" +#include "esp_log.h" +#include "esp_check.h" +#include "freertos/queue.h" +#include "esp_system.h" +#include "esp_wifi.h" +#include "esp_event.h" +#include "freertos/event_groups.h" +#include "esp_mac.h" + +#include "nvs_flash.h" +#include "lwip/err.h" +#include "lwip/sockets.h" +#include "lwip/sys.h" +#include + + + +#include "sdkconfig.h" +#include "driver/uart.h" + +#define MIN(a, b) ((a) < (b) ? (a) : (b)) + +void wifi_init_station(void); +void wifi_init_softap(void); +esp_err_t start_web_server(void); + +#endif \ No newline at end of file diff --git a/main/wifi/www/file_server.html b/main/wifi/www/file_server.html new file mode 100644 index 0000000..aebb50c --- /dev/null +++ b/main/wifi/www/file_server.html @@ -0,0 +1,80 @@ + + + +
+

ESP32 File Server

+
+ + + + + + + + + + +
+ + + +
+ + + + + +
+
+ diff --git a/main/wifi/www/home.html b/main/wifi/www/home.html new file mode 100644 index 0000000..36b744b --- /dev/null +++ b/main/wifi/www/home.html @@ -0,0 +1,96 @@ + + + + + + 在线配置 + + + + +
+

ESP32 Web 在 线 工 具

+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+ +
+
+
+
+
+ + +
+
+ +
+
+ + + diff --git a/main/wifi/www/upload_script.html b/main/wifi/www/upload_script.html new file mode 100644 index 0000000..dd1410a --- /dev/null +++ b/main/wifi/www/upload_script.html @@ -0,0 +1,129 @@ + + + + + 在线配置 + + + +
+

ESP32S2 OTA Bin Server

+ + + + + + + + + + + + + + + + + + + + + +
+
+
+ +
+
+
+
+ + + diff --git a/main/wifi/www/upload_script_copy.html b/main/wifi/www/upload_script_copy.html new file mode 100644 index 0000000..5b4f24f --- /dev/null +++ b/main/wifi/www/upload_script_copy.html @@ -0,0 +1,82 @@ + + + + 在线OTA更新 + +
+

ESP32S2 OTA Bin Server

+
+ + + + + + + + + + +
+ + + +
+ + + + + +
+
+ diff --git a/main/wifi/www/wifi.html b/main/wifi/www/wifi.html new file mode 100644 index 0000000..4069627 --- /dev/null +++ b/main/wifi/www/wifi.html @@ -0,0 +1,47 @@ + + + + + +

wifi 密码配置

+
+ + +
+ + +
+ +
+
+ diff --git a/main/wifi/www/wifi_config.html b/main/wifi/www/wifi_config.html new file mode 100644 index 0000000..1feb182 --- /dev/null +++ b/main/wifi/www/wifi_config.html @@ -0,0 +1,84 @@ + + + + + + 在线配置 + + + + +
+

ESP32 WIFI 配网

+
+
+ +
+
+ +
+
+ +
+ + +
+ + +
+
+
+ + + + diff --git a/sdkconfig b/sdkconfig index 40349f0..1f0a978 100644 --- a/sdkconfig +++ b/sdkconfig @@ -591,7 +591,6 @@ CONFIG_COMPILER_ORPHAN_SECTIONS_PLACE=y # # CONFIG_APPTRACE_DEST_JTAG is not set CONFIG_APPTRACE_DEST_NONE=y -# CONFIG_APPTRACE_DEST_UART0 is not set # CONFIG_APPTRACE_DEST_UART1 is not set # CONFIG_APPTRACE_DEST_UART2 is not set # CONFIG_APPTRACE_DEST_USB_CDC is not set @@ -1120,15 +1119,17 @@ CONFIG_ESP_MAIN_TASK_AFFINITY_CPU0=y # CONFIG_ESP_MAIN_TASK_AFFINITY_NO_AFFINITY is not set CONFIG_ESP_MAIN_TASK_AFFINITY=0x0 CONFIG_ESP_MINIMAL_SHARED_STACK_SIZE=2048 -# CONFIG_ESP_CONSOLE_UART_DEFAULT is not set +CONFIG_ESP_CONSOLE_UART_DEFAULT=y # CONFIG_ESP_CONSOLE_USB_CDC is not set # CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG is not set # CONFIG_ESP_CONSOLE_UART_CUSTOM is not set -CONFIG_ESP_CONSOLE_NONE=y +# CONFIG_ESP_CONSOLE_NONE is not set CONFIG_ESP_CONSOLE_SECONDARY_NONE=y # CONFIG_ESP_CONSOLE_SECONDARY_USB_SERIAL_JTAG is not set -CONFIG_ESP_CONSOLE_UART_NUM=-1 -CONFIG_ESP_CONSOLE_ROM_SERIAL_PORT_NUM=-1 +CONFIG_ESP_CONSOLE_UART=y +CONFIG_ESP_CONSOLE_UART_NUM=0 +CONFIG_ESP_CONSOLE_ROM_SERIAL_PORT_NUM=0 +CONFIG_ESP_CONSOLE_UART_BAUDRATE=115200 CONFIG_ESP_INT_WDT=y CONFIG_ESP_INT_WDT_TIMEOUT_MS=300 CONFIG_ESP_INT_WDT_CHECK_CPU1=y @@ -1398,13 +1399,14 @@ CONFIG_HEAP_TRACING_OFF=y # CONFIG_LOG_DEFAULT_LEVEL_NONE is not set # CONFIG_LOG_DEFAULT_LEVEL_ERROR is not set # CONFIG_LOG_DEFAULT_LEVEL_WARN is not set -# CONFIG_LOG_DEFAULT_LEVEL_INFO is not set -CONFIG_LOG_DEFAULT_LEVEL_DEBUG=y +CONFIG_LOG_DEFAULT_LEVEL_INFO=y +# CONFIG_LOG_DEFAULT_LEVEL_DEBUG is not set # CONFIG_LOG_DEFAULT_LEVEL_VERBOSE is not set -CONFIG_LOG_DEFAULT_LEVEL=4 +CONFIG_LOG_DEFAULT_LEVEL=3 CONFIG_LOG_MAXIMUM_EQUALS_DEFAULT=y +# CONFIG_LOG_MAXIMUM_LEVEL_DEBUG is not set # CONFIG_LOG_MAXIMUM_LEVEL_VERBOSE is not set -CONFIG_LOG_MAXIMUM_LEVEL=4 +CONFIG_LOG_MAXIMUM_LEVEL=3 # CONFIG_LOG_MASTER_LEVEL is not set CONFIG_LOG_COLORS=y CONFIG_LOG_TIMESTAMP_SOURCE_RTOS=y @@ -2100,11 +2102,13 @@ CONFIG_ESP32S3_DEFAULT_CPU_FREQ_MHZ=160 CONFIG_SYSTEM_EVENT_QUEUE_SIZE=32 CONFIG_SYSTEM_EVENT_TASK_STACK_SIZE=2304 CONFIG_MAIN_TASK_STACK_SIZE=3584 -# CONFIG_CONSOLE_UART_DEFAULT is not set +CONFIG_CONSOLE_UART_DEFAULT=y # CONFIG_CONSOLE_UART_CUSTOM is not set -CONFIG_CONSOLE_UART_NONE=y -CONFIG_ESP_CONSOLE_UART_NONE=y -CONFIG_CONSOLE_UART_NUM=-1 +# CONFIG_CONSOLE_UART_NONE is not set +# CONFIG_ESP_CONSOLE_UART_NONE is not set +CONFIG_CONSOLE_UART=y +CONFIG_CONSOLE_UART_NUM=0 +CONFIG_CONSOLE_UART_BAUDRATE=115200 CONFIG_INT_WDT=y CONFIG_INT_WDT_TIMEOUT_MS=300 CONFIG_INT_WDT_CHECK_CPU1=y diff --git a/sdkconfig.old b/sdkconfig.old index 6e16b6b..34da556 100644 --- a/sdkconfig.old +++ b/sdkconfig.old @@ -480,8 +480,8 @@ CONFIG_ESP_ROM_SUPPORT_DEEP_SLEEP_WAKEUP_STUB=y # # Boot ROM Behavior # -CONFIG_BOOT_ROM_LOG_ALWAYS_ON=y -# CONFIG_BOOT_ROM_LOG_ALWAYS_OFF is not set +# CONFIG_BOOT_ROM_LOG_ALWAYS_ON is not set +CONFIG_BOOT_ROM_LOG_ALWAYS_OFF=y # CONFIG_BOOT_ROM_LOG_ON_GPIO_HIGH is not set # CONFIG_BOOT_ROM_LOG_ON_GPIO_LOW is not set # end of Boot ROM Behavior @@ -591,7 +591,6 @@ CONFIG_COMPILER_ORPHAN_SECTIONS_PLACE=y # # CONFIG_APPTRACE_DEST_JTAG is not set CONFIG_APPTRACE_DEST_NONE=y -# CONFIG_APPTRACE_DEST_UART0 is not set # CONFIG_APPTRACE_DEST_UART1 is not set # CONFIG_APPTRACE_DEST_UART2 is not set # CONFIG_APPTRACE_DEST_USB_CDC is not set @@ -1120,15 +1119,17 @@ CONFIG_ESP_MAIN_TASK_AFFINITY_CPU0=y # CONFIG_ESP_MAIN_TASK_AFFINITY_NO_AFFINITY is not set CONFIG_ESP_MAIN_TASK_AFFINITY=0x0 CONFIG_ESP_MINIMAL_SHARED_STACK_SIZE=2048 -# CONFIG_ESP_CONSOLE_UART_DEFAULT is not set +CONFIG_ESP_CONSOLE_UART_DEFAULT=y # CONFIG_ESP_CONSOLE_USB_CDC is not set -CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG=y +# CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG is not set # CONFIG_ESP_CONSOLE_UART_CUSTOM is not set # CONFIG_ESP_CONSOLE_NONE is not set CONFIG_ESP_CONSOLE_SECONDARY_NONE=y -CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG_ENABLED=y -CONFIG_ESP_CONSOLE_UART_NUM=-1 -CONFIG_ESP_CONSOLE_ROM_SERIAL_PORT_NUM=4 +# CONFIG_ESP_CONSOLE_SECONDARY_USB_SERIAL_JTAG is not set +CONFIG_ESP_CONSOLE_UART=y +CONFIG_ESP_CONSOLE_UART_NUM=0 +CONFIG_ESP_CONSOLE_ROM_SERIAL_PORT_NUM=0 +CONFIG_ESP_CONSOLE_UART_BAUDRATE=115200 CONFIG_ESP_INT_WDT=y CONFIG_ESP_INT_WDT_TIMEOUT_MS=300 CONFIG_ESP_INT_WDT_CHECK_CPU1=y @@ -2100,11 +2101,13 @@ CONFIG_ESP32S3_DEFAULT_CPU_FREQ_MHZ=160 CONFIG_SYSTEM_EVENT_QUEUE_SIZE=32 CONFIG_SYSTEM_EVENT_TASK_STACK_SIZE=2304 CONFIG_MAIN_TASK_STACK_SIZE=3584 -# CONFIG_CONSOLE_UART_DEFAULT is not set +CONFIG_CONSOLE_UART_DEFAULT=y # CONFIG_CONSOLE_UART_CUSTOM is not set # CONFIG_CONSOLE_UART_NONE is not set # CONFIG_ESP_CONSOLE_UART_NONE is not set -CONFIG_CONSOLE_UART_NUM=-1 +CONFIG_CONSOLE_UART=y +CONFIG_CONSOLE_UART_NUM=0 +CONFIG_CONSOLE_UART_BAUDRATE=115200 CONFIG_INT_WDT=y CONFIG_INT_WDT_TIMEOUT_MS=300 CONFIG_INT_WDT_CHECK_CPU1=y