From 5abeac9d91fb3ba1c4121de8b4a922e2871e04a8 Mon Sep 17 00:00:00 2001 From: David Cermak Date: Mon, 15 May 2023 17:51:44 +0200 Subject: [PATCH] examples: Fix icmp-echo to auto connect to Ethernet/WiFi if selected Closes https://github.com/espressif/esp-idf/issues/10655 --- examples/protocols/icmp_echo/main/echo_example_main.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/examples/protocols/icmp_echo/main/echo_example_main.c b/examples/protocols/icmp_echo/main/echo_example_main.c index 02cc26582b..a300757479 100644 --- a/examples/protocols/icmp_echo/main/echo_example_main.c +++ b/examples/protocols/icmp_echo/main/echo_example_main.c @@ -220,8 +220,19 @@ void app_main(void) ESP_ERROR_CHECK(esp_console_new_repl_usb_serial_jtag(&usbjtag_config, &repl_config, &repl)); #endif + /* Use either WiFi console commands or menuconfig options to connect to WiFi/Ethernet + * + * Please disable `Provide wifi connect commands` in `Example Connection Configuration` + * to connect immediately using configured interface and settings (WiFi/Ethernet). + */ +#if defined(CONFIG_EXAMPLE_PROVIDE_WIFI_CONSOLE_CMD) /* register wifi connect commands */ example_register_wifi_connect_commands(); +#elif defined(CONFIG_EXAMPLE_CONNECT_WIFI) || defined(CONFIG_EXAMPLE_CONNECT_ETHERNET) + /* automatic connection per menuconfig */ + ESP_ERROR_CHECK(example_connect()); +#endif + /* register command `ping` */ register_ping(); /* register command `quit` */