From 1d8923cfbbf987e4afda37d2b59ed6c0db2acc40 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Mon, 18 Sep 2023 12:18:24 +0200 Subject: [PATCH 01/11] fix(asio): specify override_path in example manifest files --- components/asio/examples/asio_chat/main/idf_component.yml | 2 +- components/asio/examples/async_request/CMakeLists.txt | 2 +- .../asio/examples/async_request/main/idf_component.yml | 2 +- components/asio/examples/socks4/CMakeLists.txt | 2 +- components/asio/examples/socks4/main/idf_component.yml | 2 +- components/asio/examples/ssl_client_server/CMakeLists.txt | 2 +- .../asio/examples/ssl_client_server/main/idf_component.yml | 2 +- components/asio/examples/tcp_echo_server/CMakeLists.txt | 2 +- .../asio/examples/tcp_echo_server/main/idf_component.yml | 2 +- components/asio/examples/udp_echo_server/CMakeLists.txt | 2 +- .../asio/examples/udp_echo_server/main/idf_component.yml | 2 +- components/asio/idf_component.yml | 5 ++++- 12 files changed, 15 insertions(+), 12 deletions(-) diff --git a/components/asio/examples/asio_chat/main/idf_component.yml b/components/asio/examples/asio_chat/main/idf_component.yml index 1a02b5d708..13632c90e4 100644 --- a/components/asio/examples/asio_chat/main/idf_component.yml +++ b/components/asio/examples/asio_chat/main/idf_component.yml @@ -3,4 +3,4 @@ dependencies: idf: ">=5.0" espressif/asio: version: "^1.14.1" - override_path: '../../../' + override_path: "../../../" diff --git a/components/asio/examples/async_request/CMakeLists.txt b/components/asio/examples/async_request/CMakeLists.txt index 727490ba03..ff659707e0 100644 --- a/components/asio/examples/async_request/CMakeLists.txt +++ b/components/asio/examples/async_request/CMakeLists.txt @@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.16) # (Not part of the boilerplate) # This example uses an extra component for common functions such as Wi-Fi and Ethernet connection. -set(EXTRA_COMPONENT_DIRS ../../ ../../../../common_components/protocol_examples_common) +set(EXTRA_COMPONENT_DIRS ../../../../common_components/protocol_examples_common) include($ENV{IDF_PATH}/tools/cmake/project.cmake) project(async_http_request) diff --git a/components/asio/examples/async_request/main/idf_component.yml b/components/asio/examples/async_request/main/idf_component.yml index 1a02b5d708..13632c90e4 100644 --- a/components/asio/examples/async_request/main/idf_component.yml +++ b/components/asio/examples/async_request/main/idf_component.yml @@ -3,4 +3,4 @@ dependencies: idf: ">=5.0" espressif/asio: version: "^1.14.1" - override_path: '../../../' + override_path: "../../../" diff --git a/components/asio/examples/socks4/CMakeLists.txt b/components/asio/examples/socks4/CMakeLists.txt index b1e1aeb25d..f1ffe9d125 100644 --- a/components/asio/examples/socks4/CMakeLists.txt +++ b/components/asio/examples/socks4/CMakeLists.txt @@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.16) # (Not part of the boilerplate) # This example uses an extra component for common functions such as Wi-Fi and Ethernet connection. -set(EXTRA_COMPONENT_DIRS ../.. ../../../../common_components/protocol_examples_common) +set(EXTRA_COMPONENT_DIRS ../../../../common_components/protocol_examples_common) include($ENV{IDF_PATH}/tools/cmake/project.cmake) project(asio_sock4) diff --git a/components/asio/examples/socks4/main/idf_component.yml b/components/asio/examples/socks4/main/idf_component.yml index 1a02b5d708..13632c90e4 100644 --- a/components/asio/examples/socks4/main/idf_component.yml +++ b/components/asio/examples/socks4/main/idf_component.yml @@ -3,4 +3,4 @@ dependencies: idf: ">=5.0" espressif/asio: version: "^1.14.1" - override_path: '../../../' + override_path: "../../../" diff --git a/components/asio/examples/ssl_client_server/CMakeLists.txt b/components/asio/examples/ssl_client_server/CMakeLists.txt index 171887543e..73ee939a78 100644 --- a/components/asio/examples/ssl_client_server/CMakeLists.txt +++ b/components/asio/examples/ssl_client_server/CMakeLists.txt @@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.16) # (Not part of the boilerplate) # This example uses an extra component for common functions such as Wi-Fi and Ethernet connection. -set(EXTRA_COMPONENT_DIRS ../.. ../../../../common_components/protocol_examples_common) +set(EXTRA_COMPONENT_DIRS ../../../../common_components/protocol_examples_common) set(EXCLUDE_COMPONENTS openssl) include($ENV{IDF_PATH}/tools/cmake/project.cmake) diff --git a/components/asio/examples/ssl_client_server/main/idf_component.yml b/components/asio/examples/ssl_client_server/main/idf_component.yml index 1a02b5d708..13632c90e4 100644 --- a/components/asio/examples/ssl_client_server/main/idf_component.yml +++ b/components/asio/examples/ssl_client_server/main/idf_component.yml @@ -3,4 +3,4 @@ dependencies: idf: ">=5.0" espressif/asio: version: "^1.14.1" - override_path: '../../../' + override_path: "../../../" diff --git a/components/asio/examples/tcp_echo_server/CMakeLists.txt b/components/asio/examples/tcp_echo_server/CMakeLists.txt index 57a5faa328..29e2906771 100644 --- a/components/asio/examples/tcp_echo_server/CMakeLists.txt +++ b/components/asio/examples/tcp_echo_server/CMakeLists.txt @@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.16) # (Not part of the boilerplate) # This example uses an extra component for common functions such as Wi-Fi and Ethernet connection. -set(EXTRA_COMPONENT_DIRS ../.. ../../../../common_components/protocol_examples_common) +set(EXTRA_COMPONENT_DIRS ../../../../common_components/protocol_examples_common) include($ENV{IDF_PATH}/tools/cmake/project.cmake) project(asio_tcp_echo_server) diff --git a/components/asio/examples/tcp_echo_server/main/idf_component.yml b/components/asio/examples/tcp_echo_server/main/idf_component.yml index 1a02b5d708..13632c90e4 100644 --- a/components/asio/examples/tcp_echo_server/main/idf_component.yml +++ b/components/asio/examples/tcp_echo_server/main/idf_component.yml @@ -3,4 +3,4 @@ dependencies: idf: ">=5.0" espressif/asio: version: "^1.14.1" - override_path: '../../../' + override_path: "../../../" diff --git a/components/asio/examples/udp_echo_server/CMakeLists.txt b/components/asio/examples/udp_echo_server/CMakeLists.txt index 4014b91f1a..2e0c280243 100644 --- a/components/asio/examples/udp_echo_server/CMakeLists.txt +++ b/components/asio/examples/udp_echo_server/CMakeLists.txt @@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.16) # (Not part of the boilerplate) # This example uses an extra component for common functions such as Wi-Fi and Ethernet connection. -set(EXTRA_COMPONENT_DIRS ../../ ../../../../common_components/protocol_examples_common) +set(EXTRA_COMPONENT_DIRS ../../../../common_components/protocol_examples_common) include($ENV{IDF_PATH}/tools/cmake/project.cmake) project(asio_udp_echo_server) diff --git a/components/asio/examples/udp_echo_server/main/idf_component.yml b/components/asio/examples/udp_echo_server/main/idf_component.yml index 1a02b5d708..13632c90e4 100644 --- a/components/asio/examples/udp_echo_server/main/idf_component.yml +++ b/components/asio/examples/udp_echo_server/main/idf_component.yml @@ -3,4 +3,4 @@ dependencies: idf: ">=5.0" espressif/asio: version: "^1.14.1" - override_path: '../../../' + override_path: "../../../" diff --git a/components/asio/idf_component.yml b/components/asio/idf_component.yml index 2a9a960b77..2ea9eded52 100644 --- a/components/asio/idf_component.yml +++ b/components/asio/idf_component.yml @@ -1,6 +1,9 @@ version: "1.28.0~0" -description: ASIO +description: Cross-platform C++ library for network and I/O programming url: https://github.com/espressif/esp-protocols/tree/master/components/asio +issues: https://github.com/espressif/esp-protocols/issues +documentation: https://docs.espressif.com/projects/esp-protocols/asio/docs/latest/index.html +repository: https://github.com/espressif/esp-protocols.git dependencies: idf: version: ">=5.0" From 5b78da4689d2a13197023851bdf0cdd2bf23a885 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Mon, 18 Sep 2023 12:19:48 +0200 Subject: [PATCH 02/11] fix(esp_modem): specify override_path in example manifest files --- components/esp_modem/examples/ap_to_pppos/CMakeLists.txt | 2 -- .../esp_modem/examples/ap_to_pppos/main/idf_component.yml | 4 ++++ components/esp_modem/examples/linux_modem/CMakeLists.txt | 2 +- .../esp_modem/examples/linux_modem/main/idf_component.yml | 4 ++++ components/esp_modem/examples/modem_psm/CMakeLists.txt | 2 -- .../esp_modem/examples/modem_psm/main/idf_component.yml | 4 ++++ .../esp_modem/examples/modem_tcp_client/CMakeLists.txt | 2 -- .../examples/modem_tcp_client/main/idf_component.yml | 4 ++++ components/esp_modem/examples/pppos_client/CMakeLists.txt | 2 -- .../esp_modem/examples/simple_cmux_client/CMakeLists.txt | 2 -- .../examples/simple_cmux_client/main/idf_component.yml | 4 ++++ components/esp_modem/idf_component.yml | 5 ++++- 12 files changed, 25 insertions(+), 12 deletions(-) create mode 100644 components/esp_modem/examples/ap_to_pppos/main/idf_component.yml create mode 100644 components/esp_modem/examples/linux_modem/main/idf_component.yml create mode 100644 components/esp_modem/examples/modem_psm/main/idf_component.yml create mode 100644 components/esp_modem/examples/modem_tcp_client/main/idf_component.yml create mode 100644 components/esp_modem/examples/simple_cmux_client/main/idf_component.yml diff --git a/components/esp_modem/examples/ap_to_pppos/CMakeLists.txt b/components/esp_modem/examples/ap_to_pppos/CMakeLists.txt index c7d69911f9..ee35286324 100644 --- a/components/esp_modem/examples/ap_to_pppos/CMakeLists.txt +++ b/components/esp_modem/examples/ap_to_pppos/CMakeLists.txt @@ -2,7 +2,5 @@ # CMakeLists in this exact order for cmake to work correctly cmake_minimum_required(VERSION 3.5) -set(EXTRA_COMPONENT_DIRS "../..") - include($ENV{IDF_PATH}/tools/cmake/project.cmake) project(ap-to-pppos) diff --git a/components/esp_modem/examples/ap_to_pppos/main/idf_component.yml b/components/esp_modem/examples/ap_to_pppos/main/idf_component.yml new file mode 100644 index 0000000000..3289c9b167 --- /dev/null +++ b/components/esp_modem/examples/ap_to_pppos/main/idf_component.yml @@ -0,0 +1,4 @@ +dependencies: + espressif/esp_modem: + version: "^1.0.1" + override_path: "../../../" diff --git a/components/esp_modem/examples/linux_modem/CMakeLists.txt b/components/esp_modem/examples/linux_modem/CMakeLists.txt index 552e236815..dd08e1b21d 100644 --- a/components/esp_modem/examples/linux_modem/CMakeLists.txt +++ b/components/esp_modem/examples/linux_modem/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.5) include($ENV{IDF_PATH}/tools/cmake/project.cmake) -set(EXTRA_COMPONENT_DIRS ../.. ../../port/linux) +set(EXTRA_COMPONENT_DIRS ../../port/linux) set(COMPONENTS main) project(linux_modem) diff --git a/components/esp_modem/examples/linux_modem/main/idf_component.yml b/components/esp_modem/examples/linux_modem/main/idf_component.yml new file mode 100644 index 0000000000..3289c9b167 --- /dev/null +++ b/components/esp_modem/examples/linux_modem/main/idf_component.yml @@ -0,0 +1,4 @@ +dependencies: + espressif/esp_modem: + version: "^1.0.1" + override_path: "../../../" diff --git a/components/esp_modem/examples/modem_psm/CMakeLists.txt b/components/esp_modem/examples/modem_psm/CMakeLists.txt index ca0ca4bc5d..5fe31f3dac 100644 --- a/components/esp_modem/examples/modem_psm/CMakeLists.txt +++ b/components/esp_modem/examples/modem_psm/CMakeLists.txt @@ -4,7 +4,5 @@ # CMakeLists in this exact order for cmake to work correctly cmake_minimum_required(VERSION 3.16) -set(EXTRA_COMPONENT_DIRS "../..") - include($ENV{IDF_PATH}/tools/cmake/project.cmake) project(modem_psm) diff --git a/components/esp_modem/examples/modem_psm/main/idf_component.yml b/components/esp_modem/examples/modem_psm/main/idf_component.yml new file mode 100644 index 0000000000..3289c9b167 --- /dev/null +++ b/components/esp_modem/examples/modem_psm/main/idf_component.yml @@ -0,0 +1,4 @@ +dependencies: + espressif/esp_modem: + version: "^1.0.1" + override_path: "../../../" diff --git a/components/esp_modem/examples/modem_tcp_client/CMakeLists.txt b/components/esp_modem/examples/modem_tcp_client/CMakeLists.txt index d3291e8665..cb840e95a8 100644 --- a/components/esp_modem/examples/modem_tcp_client/CMakeLists.txt +++ b/components/esp_modem/examples/modem_tcp_client/CMakeLists.txt @@ -2,7 +2,5 @@ # in this exact order for cmake to work correctly cmake_minimum_required(VERSION 3.8) -set(EXTRA_COMPONENT_DIRS "../..") - include($ENV{IDF_PATH}/tools/cmake/project.cmake) project(modem_tcp_client) diff --git a/components/esp_modem/examples/modem_tcp_client/main/idf_component.yml b/components/esp_modem/examples/modem_tcp_client/main/idf_component.yml new file mode 100644 index 0000000000..3289c9b167 --- /dev/null +++ b/components/esp_modem/examples/modem_tcp_client/main/idf_component.yml @@ -0,0 +1,4 @@ +dependencies: + espressif/esp_modem: + version: "^1.0.1" + override_path: "../../../" diff --git a/components/esp_modem/examples/pppos_client/CMakeLists.txt b/components/esp_modem/examples/pppos_client/CMakeLists.txt index 4728071e66..9609525782 100644 --- a/components/esp_modem/examples/pppos_client/CMakeLists.txt +++ b/components/esp_modem/examples/pppos_client/CMakeLists.txt @@ -2,7 +2,5 @@ # in this exact order for cmake to work correctly cmake_minimum_required(VERSION 3.5) -set(EXTRA_COMPONENT_DIRS "../..") - include($ENV{IDF_PATH}/tools/cmake/project.cmake) project(pppos_client) diff --git a/components/esp_modem/examples/simple_cmux_client/CMakeLists.txt b/components/esp_modem/examples/simple_cmux_client/CMakeLists.txt index be1c2ac41d..24a58cfc25 100644 --- a/components/esp_modem/examples/simple_cmux_client/CMakeLists.txt +++ b/components/esp_modem/examples/simple_cmux_client/CMakeLists.txt @@ -3,7 +3,5 @@ cmake_minimum_required(VERSION 3.8) set(CMAKE_CXX_STANDARD 17) -set(EXTRA_COMPONENT_DIRS "../..") - include($ENV{IDF_PATH}/tools/cmake/project.cmake) project(simple_cmux_client) diff --git a/components/esp_modem/examples/simple_cmux_client/main/idf_component.yml b/components/esp_modem/examples/simple_cmux_client/main/idf_component.yml new file mode 100644 index 0000000000..3289c9b167 --- /dev/null +++ b/components/esp_modem/examples/simple_cmux_client/main/idf_component.yml @@ -0,0 +1,4 @@ +dependencies: + espressif/esp_modem: + version: "^1.0.1" + override_path: "../../../" diff --git a/components/esp_modem/idf_component.yml b/components/esp_modem/idf_component.yml index 85350d5288..818d8a61ff 100644 --- a/components/esp_modem/idf_component.yml +++ b/components/esp_modem/idf_component.yml @@ -1,6 +1,9 @@ version: "1.0.4" -description: esp modem +description: Library for communicating with cellular modems in command and data modes url: https://github.com/espressif/esp-protocols/tree/master/components/esp_modem +issues: https://github.com/espressif/esp-protocols/issues +documentation: https://docs.espressif.com/projects/esp-protocols/esp_modem/docs/latest/index.html +repository: https://github.com/espressif/esp-protocols.git dependencies: # Required IDF version idf: From fa005c6363f4cce7730265972095e9f97ac155f5 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Mon, 18 Sep 2023 12:20:44 +0200 Subject: [PATCH 03/11] fix(esp_mqtt_cxx): specify override_path in example manifest files --- components/esp_mqtt_cxx/examples/ssl/CMakeLists.txt | 3 +-- components/esp_mqtt_cxx/examples/ssl/main/idf_component.yml | 1 + components/esp_mqtt_cxx/examples/tcp/CMakeLists.txt | 3 +-- components/esp_mqtt_cxx/examples/tcp/main/idf_component.yml | 1 + components/esp_mqtt_cxx/idf_component.yml | 5 ++++- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/components/esp_mqtt_cxx/examples/ssl/CMakeLists.txt b/components/esp_mqtt_cxx/examples/ssl/CMakeLists.txt index 32809b4df9..d40b15ccb4 100644 --- a/components/esp_mqtt_cxx/examples/ssl/CMakeLists.txt +++ b/components/esp_mqtt_cxx/examples/ssl/CMakeLists.txt @@ -4,9 +4,8 @@ cmake_minimum_required(VERSION 3.16) # (Not part of the boilerplate) This example uses an extra component for common # functions such as Wi-Fi and Ethernet connection. -# The path to esp_mqtt_cxx is also added. set(EXTRA_COMPONENT_DIRS - "../../../../common_components/protocol_examples_common" "../../") + "../../../../common_components/protocol_examples_common") include($ENV{IDF_PATH}/tools/cmake/project.cmake) project(mqtt_ssl_cxx) diff --git a/components/esp_mqtt_cxx/examples/ssl/main/idf_component.yml b/components/esp_mqtt_cxx/examples/ssl/main/idf_component.yml index 63646bfcf6..dbfc8fa8e9 100644 --- a/components/esp_mqtt_cxx/examples/ssl/main/idf_component.yml +++ b/components/esp_mqtt_cxx/examples/ssl/main/idf_component.yml @@ -3,3 +3,4 @@ dependencies: idf: ">=5.0" espressif/esp_mqtt_cxx: version: "^0.1.0" + override_path: "../../../" diff --git a/components/esp_mqtt_cxx/examples/tcp/CMakeLists.txt b/components/esp_mqtt_cxx/examples/tcp/CMakeLists.txt index 146f3592d3..0446c56dac 100644 --- a/components/esp_mqtt_cxx/examples/tcp/CMakeLists.txt +++ b/components/esp_mqtt_cxx/examples/tcp/CMakeLists.txt @@ -4,9 +4,8 @@ cmake_minimum_required(VERSION 3.16) # (Not part of the boilerplate) # This example uses an extra component for common functions such as Wi-Fi and Ethernet connection. -# The path to esp_mqtt_cxx is also added. set(EXTRA_COMPONENT_DIRS - "../../../../common_components/protocol_examples_common" "../../") + "../../../../common_components/protocol_examples_common") include($ENV{IDF_PATH}/tools/cmake/project.cmake) project(mqtt_tcp_cxx) diff --git a/components/esp_mqtt_cxx/examples/tcp/main/idf_component.yml b/components/esp_mqtt_cxx/examples/tcp/main/idf_component.yml index 63646bfcf6..dbfc8fa8e9 100644 --- a/components/esp_mqtt_cxx/examples/tcp/main/idf_component.yml +++ b/components/esp_mqtt_cxx/examples/tcp/main/idf_component.yml @@ -3,3 +3,4 @@ dependencies: idf: ">=5.0" espressif/esp_mqtt_cxx: version: "^0.1.0" + override_path: "../../../" diff --git a/components/esp_mqtt_cxx/idf_component.yml b/components/esp_mqtt_cxx/idf_component.yml index 328410dad7..23274899db 100644 --- a/components/esp_mqtt_cxx/idf_component.yml +++ b/components/esp_mqtt_cxx/idf_component.yml @@ -1,6 +1,9 @@ version: "0.2.0" -description: esp mqtt cxx +description: C++ APIs for ESP-MQTT library url: https://github.com/espressif/esp-protocols/tree/master/components/esp_mqtt_cxx +issues: https://github.com/espressif/esp-protocols/issues +documentation: https://docs.espressif.com/projects/esp-protocols/esp_mqtt_cxx/docs/latest/index.html +repository: https://github.com/espressif/esp-protocols.git dependencies: espressif/esp-idf-cxx: "^1.0.0-beta" # Required IDF version From d5e789883f0306c647385ec329a1d58de9bf006c Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Mon, 18 Sep 2023 12:21:34 +0200 Subject: [PATCH 04/11] fix(esp_websocket_client): specify override_path in example manifests --- components/esp_websocket_client/examples/target/CMakeLists.txt | 1 - .../esp_websocket_client/examples/target/main/idf_component.yml | 1 + components/esp_websocket_client/idf_component.yml | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/esp_websocket_client/examples/target/CMakeLists.txt b/components/esp_websocket_client/examples/target/CMakeLists.txt index 4dbe3b1688..53f7bc0545 100644 --- a/components/esp_websocket_client/examples/target/CMakeLists.txt +++ b/components/esp_websocket_client/examples/target/CMakeLists.txt @@ -2,7 +2,6 @@ # in this exact order for cmake to work correctly cmake_minimum_required(VERSION 3.5) -set(EXTRA_COMPONENT_DIRS "../..") # This example uses an extra component for common functions such as Wi-Fi and Ethernet connection. list(APPEND EXTRA_COMPONENT_DIRS "../../../../common_components/protocol_examples_common") diff --git a/components/esp_websocket_client/examples/target/main/idf_component.yml b/components/esp_websocket_client/examples/target/main/idf_component.yml index d353156d6e..dbbe4a314e 100644 --- a/components/esp_websocket_client/examples/target/main/idf_component.yml +++ b/components/esp_websocket_client/examples/target/main/idf_component.yml @@ -3,3 +3,4 @@ dependencies: idf: ">=5.0" espressif/esp_websocket_client: version: "^1.0.0" + override_path: "../../../" diff --git a/components/esp_websocket_client/idf_component.yml b/components/esp_websocket_client/idf_component.yml index c7e147701f..7a35c35f98 100644 --- a/components/esp_websocket_client/idf_component.yml +++ b/components/esp_websocket_client/idf_component.yml @@ -1,5 +1,5 @@ version: "1.1.0" -description: esp websocket client +description: WebSocket protocol client for ESP-IDF url: https://github.com/espressif/esp-protocols/tree/master/components/esp_websocket_client dependencies: idf: From 09abb18be631bd5b6879eb7579982e481ac45889 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Thu, 21 Sep 2023 16:24:44 +0200 Subject: [PATCH 05/11] fix(asio): reference protocol_examples_common from IDF This makes the example project usable from the component registry --- components/asio/examples/asio_chat/CMakeLists.txt | 4 ---- components/asio/examples/asio_chat/main/idf_component.yml | 2 ++ components/asio/examples/async_request/CMakeLists.txt | 4 ---- components/asio/examples/async_request/main/idf_component.yml | 2 ++ components/asio/examples/socks4/CMakeLists.txt | 4 ---- components/asio/examples/socks4/main/idf_component.yml | 2 ++ components/asio/examples/ssl_client_server/CMakeLists.txt | 3 --- .../asio/examples/ssl_client_server/main/idf_component.yml | 2 ++ components/asio/examples/tcp_echo_server/CMakeLists.txt | 4 ---- .../asio/examples/tcp_echo_server/main/idf_component.yml | 2 ++ components/asio/examples/udp_echo_server/CMakeLists.txt | 4 ---- .../asio/examples/udp_echo_server/main/idf_component.yml | 2 ++ 12 files changed, 12 insertions(+), 23 deletions(-) diff --git a/components/asio/examples/asio_chat/CMakeLists.txt b/components/asio/examples/asio_chat/CMakeLists.txt index 7212f3e339..72a61303a5 100644 --- a/components/asio/examples/asio_chat/CMakeLists.txt +++ b/components/asio/examples/asio_chat/CMakeLists.txt @@ -2,9 +2,5 @@ # in this exact order for cmake to work correctly cmake_minimum_required(VERSION 3.16) -# (Not part of the boilerplate) -# This example uses an extra component for common functions such as Wi-Fi and Ethernet connection. -set(EXTRA_COMPONENT_DIRS ../.. ../../../../common_components/protocol_examples_common) - include($ENV{IDF_PATH}/tools/cmake/project.cmake) project(asio_chat) diff --git a/components/asio/examples/asio_chat/main/idf_component.yml b/components/asio/examples/asio_chat/main/idf_component.yml index 13632c90e4..87c1515f98 100644 --- a/components/asio/examples/asio_chat/main/idf_component.yml +++ b/components/asio/examples/asio_chat/main/idf_component.yml @@ -4,3 +4,5 @@ dependencies: espressif/asio: version: "^1.14.1" override_path: "../../../" + protocol_examples_common: + path: ${IDF_PATH}/examples/common_components/protocol_examples_common diff --git a/components/asio/examples/async_request/CMakeLists.txt b/components/asio/examples/async_request/CMakeLists.txt index ff659707e0..1febd7afd8 100644 --- a/components/asio/examples/async_request/CMakeLists.txt +++ b/components/asio/examples/async_request/CMakeLists.txt @@ -2,9 +2,5 @@ # in this exact order for cmake to work correctly cmake_minimum_required(VERSION 3.16) -# (Not part of the boilerplate) -# This example uses an extra component for common functions such as Wi-Fi and Ethernet connection. -set(EXTRA_COMPONENT_DIRS ../../../../common_components/protocol_examples_common) - include($ENV{IDF_PATH}/tools/cmake/project.cmake) project(async_http_request) diff --git a/components/asio/examples/async_request/main/idf_component.yml b/components/asio/examples/async_request/main/idf_component.yml index 13632c90e4..87c1515f98 100644 --- a/components/asio/examples/async_request/main/idf_component.yml +++ b/components/asio/examples/async_request/main/idf_component.yml @@ -4,3 +4,5 @@ dependencies: espressif/asio: version: "^1.14.1" override_path: "../../../" + protocol_examples_common: + path: ${IDF_PATH}/examples/common_components/protocol_examples_common diff --git a/components/asio/examples/socks4/CMakeLists.txt b/components/asio/examples/socks4/CMakeLists.txt index f1ffe9d125..1f2e63fb9b 100644 --- a/components/asio/examples/socks4/CMakeLists.txt +++ b/components/asio/examples/socks4/CMakeLists.txt @@ -2,9 +2,5 @@ # in this exact order for cmake to work correctly cmake_minimum_required(VERSION 3.16) -# (Not part of the boilerplate) -# This example uses an extra component for common functions such as Wi-Fi and Ethernet connection. -set(EXTRA_COMPONENT_DIRS ../../../../common_components/protocol_examples_common) - include($ENV{IDF_PATH}/tools/cmake/project.cmake) project(asio_sock4) diff --git a/components/asio/examples/socks4/main/idf_component.yml b/components/asio/examples/socks4/main/idf_component.yml index 13632c90e4..87c1515f98 100644 --- a/components/asio/examples/socks4/main/idf_component.yml +++ b/components/asio/examples/socks4/main/idf_component.yml @@ -4,3 +4,5 @@ dependencies: espressif/asio: version: "^1.14.1" override_path: "../../../" + protocol_examples_common: + path: ${IDF_PATH}/examples/common_components/protocol_examples_common diff --git a/components/asio/examples/ssl_client_server/CMakeLists.txt b/components/asio/examples/ssl_client_server/CMakeLists.txt index 73ee939a78..7dc1b47d22 100644 --- a/components/asio/examples/ssl_client_server/CMakeLists.txt +++ b/components/asio/examples/ssl_client_server/CMakeLists.txt @@ -2,9 +2,6 @@ # in this exact order for cmake to work correctly cmake_minimum_required(VERSION 3.16) -# (Not part of the boilerplate) -# This example uses an extra component for common functions such as Wi-Fi and Ethernet connection. -set(EXTRA_COMPONENT_DIRS ../../../../common_components/protocol_examples_common) set(EXCLUDE_COMPONENTS openssl) include($ENV{IDF_PATH}/tools/cmake/project.cmake) diff --git a/components/asio/examples/ssl_client_server/main/idf_component.yml b/components/asio/examples/ssl_client_server/main/idf_component.yml index 13632c90e4..87c1515f98 100644 --- a/components/asio/examples/ssl_client_server/main/idf_component.yml +++ b/components/asio/examples/ssl_client_server/main/idf_component.yml @@ -4,3 +4,5 @@ dependencies: espressif/asio: version: "^1.14.1" override_path: "../../../" + protocol_examples_common: + path: ${IDF_PATH}/examples/common_components/protocol_examples_common diff --git a/components/asio/examples/tcp_echo_server/CMakeLists.txt b/components/asio/examples/tcp_echo_server/CMakeLists.txt index 29e2906771..c09d833cf2 100644 --- a/components/asio/examples/tcp_echo_server/CMakeLists.txt +++ b/components/asio/examples/tcp_echo_server/CMakeLists.txt @@ -2,9 +2,5 @@ # in this exact order for cmake to work correctly cmake_minimum_required(VERSION 3.16) -# (Not part of the boilerplate) -# This example uses an extra component for common functions such as Wi-Fi and Ethernet connection. -set(EXTRA_COMPONENT_DIRS ../../../../common_components/protocol_examples_common) - include($ENV{IDF_PATH}/tools/cmake/project.cmake) project(asio_tcp_echo_server) diff --git a/components/asio/examples/tcp_echo_server/main/idf_component.yml b/components/asio/examples/tcp_echo_server/main/idf_component.yml index 13632c90e4..87c1515f98 100644 --- a/components/asio/examples/tcp_echo_server/main/idf_component.yml +++ b/components/asio/examples/tcp_echo_server/main/idf_component.yml @@ -4,3 +4,5 @@ dependencies: espressif/asio: version: "^1.14.1" override_path: "../../../" + protocol_examples_common: + path: ${IDF_PATH}/examples/common_components/protocol_examples_common diff --git a/components/asio/examples/udp_echo_server/CMakeLists.txt b/components/asio/examples/udp_echo_server/CMakeLists.txt index 2e0c280243..103fe5bd17 100644 --- a/components/asio/examples/udp_echo_server/CMakeLists.txt +++ b/components/asio/examples/udp_echo_server/CMakeLists.txt @@ -2,9 +2,5 @@ # in this exact order for cmake to work correctly cmake_minimum_required(VERSION 3.16) -# (Not part of the boilerplate) -# This example uses an extra component for common functions such as Wi-Fi and Ethernet connection. -set(EXTRA_COMPONENT_DIRS ../../../../common_components/protocol_examples_common) - include($ENV{IDF_PATH}/tools/cmake/project.cmake) project(asio_udp_echo_server) diff --git a/components/asio/examples/udp_echo_server/main/idf_component.yml b/components/asio/examples/udp_echo_server/main/idf_component.yml index 13632c90e4..87c1515f98 100644 --- a/components/asio/examples/udp_echo_server/main/idf_component.yml +++ b/components/asio/examples/udp_echo_server/main/idf_component.yml @@ -4,3 +4,5 @@ dependencies: espressif/asio: version: "^1.14.1" override_path: "../../../" + protocol_examples_common: + path: ${IDF_PATH}/examples/common_components/protocol_examples_common From d6b6f634d7fc7c146e7afe03fe5cb4170ae61635 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Thu, 21 Sep 2023 16:25:12 +0200 Subject: [PATCH 06/11] fix(esp_modem): remove unused GNU Make based buildsystem files --- components/esp_modem/examples/modem_console/Makefile | 10 ---------- .../esp_modem/examples/modem_console/main/component.mk | 4 ---- components/esp_modem/test/target/main/component.mk | 8 -------- 3 files changed, 22 deletions(-) delete mode 100644 components/esp_modem/examples/modem_console/Makefile delete mode 100644 components/esp_modem/examples/modem_console/main/component.mk delete mode 100644 components/esp_modem/test/target/main/component.mk diff --git a/components/esp_modem/examples/modem_console/Makefile b/components/esp_modem/examples/modem_console/Makefile deleted file mode 100644 index 70855c84d5..0000000000 --- a/components/esp_modem/examples/modem_console/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -# -# This is a project Makefile. It is assumed the directory this Makefile resides in is a -# project subdirectory. -# - -PROJECT_NAME := modem-console - -EXTRA_COMPONENT_DIRS = $(IDF_PATH)/examples/common_components/protocol_examples_common - -include $(IDF_PATH)/make/project.mk diff --git a/components/esp_modem/examples/modem_console/main/component.mk b/components/esp_modem/examples/modem_console/main/component.mk deleted file mode 100644 index a98f634eae..0000000000 --- a/components/esp_modem/examples/modem_console/main/component.mk +++ /dev/null @@ -1,4 +0,0 @@ -# -# "main" pseudo-component makefile. -# -# (Uses default behaviour of compiling all source files in directory, adding 'include' to include path.) diff --git a/components/esp_modem/test/target/main/component.mk b/components/esp_modem/test/target/main/component.mk deleted file mode 100644 index 0adf45649a..0000000000 --- a/components/esp_modem/test/target/main/component.mk +++ /dev/null @@ -1,8 +0,0 @@ -# -# Main component makefile. -# -# This Makefile can be left empty. By default, it will take the sources in the -# src/ directory, compile them and link them into lib(subdirectory_name).a -# in the build directory. This behaviour is entirely configurable, -# please read the ESP-IDF documents if you need to do this. -# From e6c0538d55f411bedeaaf1634cdfcdca1915487e Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Thu, 21 Sep 2023 16:25:42 +0200 Subject: [PATCH 07/11] fix(esp_mqtt_cxx): reference protocol_examples_common from IDF This makes the example project usable from the component registry --- components/esp_mqtt_cxx/examples/ssl/CMakeLists.txt | 5 ----- components/esp_mqtt_cxx/examples/ssl/main/idf_component.yml | 4 +++- components/esp_mqtt_cxx/examples/tcp/CMakeLists.txt | 5 ----- components/esp_mqtt_cxx/examples/tcp/main/idf_component.yml | 4 +++- 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/components/esp_mqtt_cxx/examples/ssl/CMakeLists.txt b/components/esp_mqtt_cxx/examples/ssl/CMakeLists.txt index d40b15ccb4..1548cb2864 100644 --- a/components/esp_mqtt_cxx/examples/ssl/CMakeLists.txt +++ b/components/esp_mqtt_cxx/examples/ssl/CMakeLists.txt @@ -2,11 +2,6 @@ # CMakeLists in this exact order for cmake to work correctly cmake_minimum_required(VERSION 3.16) -# (Not part of the boilerplate) This example uses an extra component for common -# functions such as Wi-Fi and Ethernet connection. -set(EXTRA_COMPONENT_DIRS - "../../../../common_components/protocol_examples_common") - include($ENV{IDF_PATH}/tools/cmake/project.cmake) project(mqtt_ssl_cxx) diff --git a/components/esp_mqtt_cxx/examples/ssl/main/idf_component.yml b/components/esp_mqtt_cxx/examples/ssl/main/idf_component.yml index dbfc8fa8e9..3addb485a0 100644 --- a/components/esp_mqtt_cxx/examples/ssl/main/idf_component.yml +++ b/components/esp_mqtt_cxx/examples/ssl/main/idf_component.yml @@ -2,5 +2,7 @@ dependencies: ## Required IDF version idf: ">=5.0" espressif/esp_mqtt_cxx: - version: "^0.1.0" + version: "~0" override_path: "../../../" + protocol_examples_common: + path: ${IDF_PATH}/examples/common_components/protocol_examples_common diff --git a/components/esp_mqtt_cxx/examples/tcp/CMakeLists.txt b/components/esp_mqtt_cxx/examples/tcp/CMakeLists.txt index 0446c56dac..baf71459b0 100644 --- a/components/esp_mqtt_cxx/examples/tcp/CMakeLists.txt +++ b/components/esp_mqtt_cxx/examples/tcp/CMakeLists.txt @@ -2,10 +2,5 @@ # in this exact order for cmake to work correctly cmake_minimum_required(VERSION 3.16) -# (Not part of the boilerplate) -# This example uses an extra component for common functions such as Wi-Fi and Ethernet connection. -set(EXTRA_COMPONENT_DIRS - "../../../../common_components/protocol_examples_common") - include($ENV{IDF_PATH}/tools/cmake/project.cmake) project(mqtt_tcp_cxx) diff --git a/components/esp_mqtt_cxx/examples/tcp/main/idf_component.yml b/components/esp_mqtt_cxx/examples/tcp/main/idf_component.yml index dbfc8fa8e9..3addb485a0 100644 --- a/components/esp_mqtt_cxx/examples/tcp/main/idf_component.yml +++ b/components/esp_mqtt_cxx/examples/tcp/main/idf_component.yml @@ -2,5 +2,7 @@ dependencies: ## Required IDF version idf: ">=5.0" espressif/esp_mqtt_cxx: - version: "^0.1.0" + version: "~0" override_path: "../../../" + protocol_examples_common: + path: ${IDF_PATH}/examples/common_components/protocol_examples_common From 025ede12e843ab41a55d8b095b758656a41c441d Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Thu, 21 Sep 2023 16:26:45 +0200 Subject: [PATCH 08/11] fix(esp_websocket_client): reference protocol_examples_common from IDF This makes the 'target' example usable from the component registry. 'linux' example still has a bunch of EXTRA_COMPONENT_DIRS, but at least we can delete the protocol_examples_common copy. --- components/esp_websocket_client/examples/linux/CMakeLists.txt | 1 - .../esp_websocket_client/examples/linux/main/idf_component.yml | 3 +++ components/esp_websocket_client/examples/target/CMakeLists.txt | 3 --- .../examples/target/main/idf_component.yml | 2 ++ 4 files changed, 5 insertions(+), 4 deletions(-) create mode 100644 components/esp_websocket_client/examples/linux/main/idf_component.yml diff --git a/components/esp_websocket_client/examples/linux/CMakeLists.txt b/components/esp_websocket_client/examples/linux/CMakeLists.txt index b4c7bb3a91..2a08ac5e8c 100644 --- a/components/esp_websocket_client/examples/linux/CMakeLists.txt +++ b/components/esp_websocket_client/examples/linux/CMakeLists.txt @@ -8,7 +8,6 @@ set(EXTRA_COMPONENT_DIRS "${common_component_dir}/linux_compat" "${common_component_dir}/linux_compat/freertos") -list(APPEND EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/protocol_examples_common) list(APPEND EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/protocols/linux_stubs/esp_stubs) include($ENV{IDF_PATH}/tools/cmake/project.cmake) diff --git a/components/esp_websocket_client/examples/linux/main/idf_component.yml b/components/esp_websocket_client/examples/linux/main/idf_component.yml new file mode 100644 index 0000000000..718194867b --- /dev/null +++ b/components/esp_websocket_client/examples/linux/main/idf_component.yml @@ -0,0 +1,3 @@ +dependencies: + protocol_examples_common: + path: ${IDF_PATH}/examples/common_components/protocol_examples_common diff --git a/components/esp_websocket_client/examples/target/CMakeLists.txt b/components/esp_websocket_client/examples/target/CMakeLists.txt index 53f7bc0545..6858816b3e 100644 --- a/components/esp_websocket_client/examples/target/CMakeLists.txt +++ b/components/esp_websocket_client/examples/target/CMakeLists.txt @@ -2,8 +2,5 @@ # in this exact order for cmake to work correctly cmake_minimum_required(VERSION 3.5) -# This example uses an extra component for common functions such as Wi-Fi and Ethernet connection. -list(APPEND EXTRA_COMPONENT_DIRS "../../../../common_components/protocol_examples_common") - include($ENV{IDF_PATH}/tools/cmake/project.cmake) project(websocket_example) diff --git a/components/esp_websocket_client/examples/target/main/idf_component.yml b/components/esp_websocket_client/examples/target/main/idf_component.yml index dbbe4a314e..0cc1eea4d0 100644 --- a/components/esp_websocket_client/examples/target/main/idf_component.yml +++ b/components/esp_websocket_client/examples/target/main/idf_component.yml @@ -4,3 +4,5 @@ dependencies: espressif/esp_websocket_client: version: "^1.0.0" override_path: "../../../" + protocol_examples_common: + path: ${IDF_PATH}/examples/common_components/protocol_examples_common From c83b76ea8fc53f429c0b8025cd37769731c3a353 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Thu, 21 Sep 2023 16:27:13 +0200 Subject: [PATCH 09/11] fix(mdns): reference protocol_examples_common from IDF This makes the example project usable from the component registry --- components/mdns/examples/CMakeLists.txt | 4 ---- components/mdns/examples/main/idf_component.yml | 2 ++ 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/components/mdns/examples/CMakeLists.txt b/components/mdns/examples/CMakeLists.txt index cbea5b1bd8..cf9625cbea 100644 --- a/components/mdns/examples/CMakeLists.txt +++ b/components/mdns/examples/CMakeLists.txt @@ -2,9 +2,5 @@ # in this exact order for cmake to work correctly cmake_minimum_required(VERSION 3.5) -set(EXTRA_COMPONENT_DIRS "..") -# This example uses an extra component for common functions such as Wi-Fi and Ethernet connection. -list(APPEND EXTRA_COMPONENT_DIRS "../../../common_components/protocol_examples_common") - include($ENV{IDF_PATH}/tools/cmake/project.cmake) project(mdns_test) diff --git a/components/mdns/examples/main/idf_component.yml b/components/mdns/examples/main/idf_component.yml index 95845f82ac..952edfb0dc 100644 --- a/components/mdns/examples/main/idf_component.yml +++ b/components/mdns/examples/main/idf_component.yml @@ -3,3 +3,5 @@ dependencies: idf: ">=5.0" espressif/mdns: version: "^1.0.0" + protocol_examples_common: + path: ${IDF_PATH}/examples/common_components/protocol_examples_common From d28232b9f8c2cc5c0c66cc5b4d767b4f329e66d3 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Thu, 21 Sep 2023 16:30:18 +0200 Subject: [PATCH 10/11] fix(mdns): move the example into a subdirectory By default, component manager expects that the examples are located under /examples/. Move mdns example so that it is found. --- .github/workflows/mdns__build-target-test.yml | 4 ++-- components/mdns/examples/{ => query_advertise}/CMakeLists.txt | 2 +- components/mdns/examples/{ => query_advertise}/README.md | 2 +- .../mdns/examples/{ => query_advertise}/main/CMakeLists.txt | 0 .../examples/{ => query_advertise}/main/Kconfig.projbuild | 0 .../examples/{ => query_advertise}/main/idf_component.yml | 1 + .../examples/{ => query_advertise}/main/mdns_example_main.c | 0 components/mdns/examples/{ => query_advertise}/pytest_mdns.py | 0 .../{ => query_advertise}/sdkconfig.ci.eth_custom_netif | 0 .../mdns/examples/{ => query_advertise}/sdkconfig.ci.eth_def | 0 .../examples/{ => query_advertise}/sdkconfig.ci.eth_no_ipv6 | 0 .../examples/{ => query_advertise}/sdkconfig.ci.eth_socket | 0 12 files changed, 5 insertions(+), 4 deletions(-) rename components/mdns/examples/{ => query_advertise}/CMakeLists.txt (89%) rename components/mdns/examples/{ => query_advertise}/README.md (98%) rename components/mdns/examples/{ => query_advertise}/main/CMakeLists.txt (100%) rename components/mdns/examples/{ => query_advertise}/main/Kconfig.projbuild (100%) rename components/mdns/examples/{ => query_advertise}/main/idf_component.yml (86%) rename components/mdns/examples/{ => query_advertise}/main/mdns_example_main.c (100%) rename components/mdns/examples/{ => query_advertise}/pytest_mdns.py (100%) rename components/mdns/examples/{ => query_advertise}/sdkconfig.ci.eth_custom_netif (100%) rename components/mdns/examples/{ => query_advertise}/sdkconfig.ci.eth_def (100%) rename components/mdns/examples/{ => query_advertise}/sdkconfig.ci.eth_no_ipv6 (100%) rename components/mdns/examples/{ => query_advertise}/sdkconfig.ci.eth_socket (100%) diff --git a/.github/workflows/mdns__build-target-test.yml b/.github/workflows/mdns__build-target-test.yml index 2baf99a0c3..868256a764 100644 --- a/.github/workflows/mdns__build-target-test.yml +++ b/.github/workflows/mdns__build-target-test.yml @@ -14,7 +14,7 @@ jobs: strategy: matrix: idf_ver: ["latest", "release-v5.0"] - test: [ { app: example, path: "examples" }, { app: unit_test, path: "tests/unit_test" }, { app: test_app, path: "tests/test_apps" } ] + test: [ { app: example, path: "examples/query_advertise" }, { app: unit_test, path: "tests/unit_test" }, { app: test_app, path: "tests/test_apps" } ] runs-on: ubuntu-20.04 container: espressif/idf:${{ matrix.idf_ver }} steps: @@ -50,7 +50,7 @@ jobs: matrix: idf_ver: ["latest"] idf_target: ["esp32"] - test: [ { app: example, path: "examples" }, { app: unit_test, path: "tests/unit_test" }, { app: test_app, path: "tests/test_apps" } ] + test: [ { app: example, path: "examples/query_advertise" }, { app: unit_test, path: "tests/unit_test" }, { app: test_app, path: "tests/test_apps" } ] needs: build_mdns runs-on: - self-hosted diff --git a/components/mdns/examples/CMakeLists.txt b/components/mdns/examples/query_advertise/CMakeLists.txt similarity index 89% rename from components/mdns/examples/CMakeLists.txt rename to components/mdns/examples/query_advertise/CMakeLists.txt index cf9625cbea..9a16f140a0 100644 --- a/components/mdns/examples/CMakeLists.txt +++ b/components/mdns/examples/query_advertise/CMakeLists.txt @@ -3,4 +3,4 @@ cmake_minimum_required(VERSION 3.5) include($ENV{IDF_PATH}/tools/cmake/project.cmake) -project(mdns_test) +project(query_advertise) diff --git a/components/mdns/examples/README.md b/components/mdns/examples/query_advertise/README.md similarity index 98% rename from components/mdns/examples/README.md rename to components/mdns/examples/query_advertise/README.md index 04047a6f72..6ccdef9702 100644 --- a/components/mdns/examples/README.md +++ b/components/mdns/examples/query_advertise/README.md @@ -1,6 +1,6 @@ # mDNS example -Shows how to use mDNS to advertise lookup services and hosts +Shows how to use mDNS to advertise and query services and hosts ## Example workflow diff --git a/components/mdns/examples/main/CMakeLists.txt b/components/mdns/examples/query_advertise/main/CMakeLists.txt similarity index 100% rename from components/mdns/examples/main/CMakeLists.txt rename to components/mdns/examples/query_advertise/main/CMakeLists.txt diff --git a/components/mdns/examples/main/Kconfig.projbuild b/components/mdns/examples/query_advertise/main/Kconfig.projbuild similarity index 100% rename from components/mdns/examples/main/Kconfig.projbuild rename to components/mdns/examples/query_advertise/main/Kconfig.projbuild diff --git a/components/mdns/examples/main/idf_component.yml b/components/mdns/examples/query_advertise/main/idf_component.yml similarity index 86% rename from components/mdns/examples/main/idf_component.yml rename to components/mdns/examples/query_advertise/main/idf_component.yml index 952edfb0dc..e9277dfc99 100644 --- a/components/mdns/examples/main/idf_component.yml +++ b/components/mdns/examples/query_advertise/main/idf_component.yml @@ -3,5 +3,6 @@ dependencies: idf: ">=5.0" espressif/mdns: version: "^1.0.0" + override_path: "../../../" protocol_examples_common: path: ${IDF_PATH}/examples/common_components/protocol_examples_common diff --git a/components/mdns/examples/main/mdns_example_main.c b/components/mdns/examples/query_advertise/main/mdns_example_main.c similarity index 100% rename from components/mdns/examples/main/mdns_example_main.c rename to components/mdns/examples/query_advertise/main/mdns_example_main.c diff --git a/components/mdns/examples/pytest_mdns.py b/components/mdns/examples/query_advertise/pytest_mdns.py similarity index 100% rename from components/mdns/examples/pytest_mdns.py rename to components/mdns/examples/query_advertise/pytest_mdns.py diff --git a/components/mdns/examples/sdkconfig.ci.eth_custom_netif b/components/mdns/examples/query_advertise/sdkconfig.ci.eth_custom_netif similarity index 100% rename from components/mdns/examples/sdkconfig.ci.eth_custom_netif rename to components/mdns/examples/query_advertise/sdkconfig.ci.eth_custom_netif diff --git a/components/mdns/examples/sdkconfig.ci.eth_def b/components/mdns/examples/query_advertise/sdkconfig.ci.eth_def similarity index 100% rename from components/mdns/examples/sdkconfig.ci.eth_def rename to components/mdns/examples/query_advertise/sdkconfig.ci.eth_def diff --git a/components/mdns/examples/sdkconfig.ci.eth_no_ipv6 b/components/mdns/examples/query_advertise/sdkconfig.ci.eth_no_ipv6 similarity index 100% rename from components/mdns/examples/sdkconfig.ci.eth_no_ipv6 rename to components/mdns/examples/query_advertise/sdkconfig.ci.eth_no_ipv6 diff --git a/components/mdns/examples/sdkconfig.ci.eth_socket b/components/mdns/examples/query_advertise/sdkconfig.ci.eth_socket similarity index 100% rename from components/mdns/examples/sdkconfig.ci.eth_socket rename to components/mdns/examples/query_advertise/sdkconfig.ci.eth_socket From 1ee9dae6bf364ea0e31d7df7d7a08358ba335b8b Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Thu, 21 Sep 2023 16:34:33 +0200 Subject: [PATCH 11/11] fix(common): remove protocol_examples_common Remaining references to protocol_examples_common are replaced with references to ESP-IDF. We will later re-add protocol_examples_common or some equivalent of it under components/, and release it to the Component Registry. --- ci/check_copyright_config.yaml | 1 - .../protocol_examples_common/CMakeLists.txt | 4 - .../Kconfig.projbuild | 322 ----------- .../addr_from_stdin.c | 68 --- .../protocol_examples_common/connect.c | 527 ------------------ .../include/addr_from_stdin.h | 45 -- .../include/protocol_examples_common.h | 94 ---- .../protocol_examples_common/stdin_out.c | 30 - .../mdns/tests/test_apps/CMakeLists.txt | 4 - .../tests/test_apps/main/idf_component.yml | 8 + examples/mqtt/CMakeLists.txt | 3 - examples/mqtt/main/idf_component.yml | 3 + 12 files changed, 11 insertions(+), 1098 deletions(-) delete mode 100644 common_components/protocol_examples_common/CMakeLists.txt delete mode 100644 common_components/protocol_examples_common/Kconfig.projbuild delete mode 100644 common_components/protocol_examples_common/addr_from_stdin.c delete mode 100644 common_components/protocol_examples_common/connect.c delete mode 100644 common_components/protocol_examples_common/include/addr_from_stdin.h delete mode 100644 common_components/protocol_examples_common/include/protocol_examples_common.h delete mode 100644 common_components/protocol_examples_common/stdin_out.c create mode 100644 components/mdns/tests/test_apps/main/idf_component.yml create mode 100644 examples/mqtt/main/idf_component.yml diff --git a/ci/check_copyright_config.yaml b/ci/check_copyright_config.yaml index 46e4f698ac..77f9f88028 100644 --- a/ci/check_copyright_config.yaml +++ b/ci/check_copyright_config.yaml @@ -62,4 +62,3 @@ ignore: - 'components/esp_modem/port/linux/**' - 'components/asio/examples/**' - 'components/mdns/**/esp_system_protocols_linux/**' - - 'common_components/protocol_examples_common/**' diff --git a/common_components/protocol_examples_common/CMakeLists.txt b/common_components/protocol_examples_common/CMakeLists.txt deleted file mode 100644 index 66ffbf8b40..0000000000 --- a/common_components/protocol_examples_common/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -idf_component_register(SRCS "connect.c" "stdin_out.c" "addr_from_stdin.c" - INCLUDE_DIRS "include" - PRIV_REQUIRES esp_netif driver esp_eth esp_wifi vfs - ) diff --git a/common_components/protocol_examples_common/Kconfig.projbuild b/common_components/protocol_examples_common/Kconfig.projbuild deleted file mode 100644 index 86ee4f140c..0000000000 --- a/common_components/protocol_examples_common/Kconfig.projbuild +++ /dev/null @@ -1,322 +0,0 @@ -menu "Example Connection Configuration" - - orsource "$IDF_PATH/examples/common_components/env_caps/$IDF_TARGET/Kconfig.env_caps" - - config EXAMPLE_CONNECT_WIFI - bool "connect using WiFi interface" - default y - help - Protocol examples can use Wi-Fi and/or Ethernet to connect to the network. - Choose this option to connect with WiFi - - if EXAMPLE_CONNECT_WIFI - config EXAMPLE_WIFI_SSID - string "WiFi SSID" - default "myssid" - help - SSID (network name) for the example to connect to. - - config EXAMPLE_WIFI_PASSWORD - string "WiFi Password" - default "mypassword" - help - WiFi password (WPA or WPA2) for the example to use. - Can be left blank if the network has no security set. - - choice EXAMPLE_WIFI_SCAN_METHOD - prompt "WiFi Scan Method" - default EXAMPLE_WIFI_SCAN_METHOD_ALL_CHANNEL - help - WiFi scan method: - - If "Fast" is selected, scan will end after find SSID match AP. - - If "All Channel" is selected, scan will end after scan all the channel. - - config EXAMPLE_WIFI_SCAN_METHOD_FAST - bool "Fast" - config EXAMPLE_WIFI_SCAN_METHOD_ALL_CHANNEL - bool "All Channel" - endchoice - - menu "WiFi Scan threshold" - config EXAMPLE_WIFI_SCAN_RSSI_THRESHOLD - int "WiFi minimum rssi" - range -127 0 - - default -127 - help - The minimum rssi to accept in the scan mode. - - choice EXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLD - prompt "WiFi Scan auth mode threshold" - default EXAMPLE_WIFI_AUTH_OPEN - help - The weakest authmode to accept in the scan mode. - - config EXAMPLE_WIFI_AUTH_OPEN - bool "OPEN" - config EXAMPLE_WIFI_AUTH_WEP - bool "WEP" - config EXAMPLE_WIFI_AUTH_WPA_PSK - bool "WPA PSK" - config EXAMPLE_WIFI_AUTH_WPA2_PSK - bool "WPA2 PSK" - config EXAMPLE_WIFI_AUTH_WPA_WPA2_PSK - bool "WPA WPA2 PSK" - config EXAMPLE_WIFI_AUTH_WPA2_ENTERPRISE - bool "WPA2 ENTERPRISE" - config EXAMPLE_WIFI_AUTH_WPA3_PSK - bool "WPA3 PSK" - config EXAMPLE_WIFI_AUTH_WPA2_WPA3_PSK - bool "WPA2 WPA3 PSK" - config EXAMPLE_WIFI_AUTH_WAPI_PSK - bool "WAPI PSK" - endchoice - endmenu - - choice EXAMPLE_WIFI_CONNECT_AP_SORT_METHOD - prompt "WiFi Connect AP Sort Method" - default EXAMPLE_WIFI_CONNECT_AP_BY_SIGNAL - help - WiFi connect AP sort method: - - If "Signal" is selected, Sort matched APs in scan list by RSSI. - - If "Security" is selected, Sort matched APs in scan list by security mode. - - config EXAMPLE_WIFI_CONNECT_AP_BY_SIGNAL - bool "Signal" - config EXAMPLE_WIFI_CONNECT_AP_BY_SECURITY - bool "Security" - endchoice - endif - - config EXAMPLE_CONNECT_ETHERNET - bool "connect using Ethernet interface" - default n - help - Protocol examples can use Wi-Fi and/or Ethernet to connect to the network. - Choose this option to connect with Ethernet - - if EXAMPLE_CONNECT_ETHERNET - config EXAMPLE_USE_SPI_ETHERNET - bool - - choice EXAMPLE_ETHERNET_TYPE - prompt "Ethernet Type" - default EXAMPLE_USE_INTERNAL_ETHERNET if IDF_TARGET_ESP32 - default EXAMPLE_USE_W5500 - help - Select which kind of Ethernet will be used in the example. - - config EXAMPLE_USE_INTERNAL_ETHERNET - depends on IDF_TARGET_ESP32 - select ETH_USE_ESP32_EMAC - bool "Internal EMAC" - help - Select internal Ethernet MAC controller. - - config EXAMPLE_USE_DM9051 - bool "DM9051 Module" - select EXAMPLE_USE_SPI_ETHERNET - select ETH_USE_SPI_ETHERNET - select ETH_SPI_ETHERNET_DM9051 - help - Select external SPI-Ethernet module. - - config EXAMPLE_USE_W5500 - bool "W5500 Module" - select EXAMPLE_USE_SPI_ETHERNET - select ETH_USE_SPI_ETHERNET - select ETH_SPI_ETHERNET_W5500 - help - Select external SPI-Ethernet module (W5500). - - config EXAMPLE_USE_OPENETH - bool "OpenCores Ethernet MAC (EXPERIMENTAL)" - select ETH_USE_OPENETH - help - When this option is enabled, the example is built with support for - OpenCores Ethernet MAC, which allows testing the example in QEMU. - Note that this option is used for internal testing purposes, and - not officially supported. Examples built with this option enabled - will not run on a real ESP32 chip. - - endchoice # EXAMPLE_ETHERNET_TYPE - - if EXAMPLE_USE_INTERNAL_ETHERNET - choice EXAMPLE_ETH_PHY_MODEL - prompt "Ethernet PHY Device" - default EXAMPLE_ETH_PHY_IP101 - help - Select the Ethernet PHY device to use in the example. - - config EXAMPLE_ETH_PHY_IP101 - bool "IP101" - help - IP101 is a single port 10/100 MII/RMII/TP/Fiber Fast Ethernet Transceiver. - Goto http://www.icplus.com.tw/pp-IP101G.html for more information about it. - - config EXAMPLE_ETH_PHY_RTL8201 - bool "RTL8201/SR8201" - help - RTL8201F/SR8201F is a single port 10/100Mb Ethernet Transceiver with auto MDIX. - Goto http://www.corechip-sz.com/productsview.asp?id=22 for more information about it. - - config EXAMPLE_ETH_PHY_LAN87XX - bool "LAN87xx" - help - Below chips are supported: - LAN8710A is a small footprint MII/RMII 10/100 Ethernet Transceiver with HP Auto-MDIX and - flexPWR® Technology. - LAN8720A is a small footprint RMII 10/100 Ethernet Transceiver with HP Auto-MDIX Support. - LAN8740A/LAN8741A is a small footprint MII/RMII 10/100 Energy Efficient Ethernet Transceiver - with HP Auto-MDIX and flexPWR® Technology. - LAN8742A is a small footprint RMII 10/100 Ethernet Transceiver with HP Auto-MDIX and - flexPWR® Technology. - Goto https://www.microchip.com for more information about them. - - config EXAMPLE_ETH_PHY_DP83848 - bool "DP83848" - help - DP83848 is a single port 10/100Mb/s Ethernet Physical Layer Transceiver. - Goto http://www.ti.com/product/DP83848J for more information about it. - - config EXAMPLE_ETH_PHY_KSZ80XX - bool "KSZ80xx" - help - With the KSZ80xx series, Microchip offers single-chip 10BASE-T/100BASE-TX - Ethernet Physical Layer Tranceivers (PHY). - The following chips are supported: KSZ8001, KSZ8021, KSZ8031, KSZ8041, - KSZ8051, KSZ8061, KSZ8081, KSZ8091 - Goto https://www.microchip.com for more information about them. - endchoice - - config EXAMPLE_ETH_MDC_GPIO - int "SMI MDC GPIO number" - range ENV_GPIO_RANGE_MIN ENV_GPIO_OUT_RANGE_MAX - default 23 - help - Set the GPIO number used by SMI MDC. - - config EXAMPLE_ETH_MDIO_GPIO - int "SMI MDIO GPIO number" - range ENV_GPIO_RANGE_MIN ENV_GPIO_OUT_RANGE_MAX - default 18 - help - Set the GPIO number used by SMI MDIO. - endif - - if EXAMPLE_USE_SPI_ETHERNET - config EXAMPLE_ETH_SPI_HOST - int "SPI Host Number" - range 0 2 - default 1 - help - Set the SPI host used to communicate with the SPI Ethernet Controller. - - config EXAMPLE_ETH_SPI_SCLK_GPIO - int "SPI SCLK GPIO number" - range ENV_GPIO_RANGE_MIN ENV_GPIO_OUT_RANGE_MAX - default 14 - help - Set the GPIO number used by SPI SCLK. - - config EXAMPLE_ETH_SPI_MOSI_GPIO - int "SPI MOSI GPIO number" - range ENV_GPIO_RANGE_MIN ENV_GPIO_OUT_RANGE_MAX - default 13 - help - Set the GPIO number used by SPI MOSI. - - config EXAMPLE_ETH_SPI_MISO_GPIO - int "SPI MISO GPIO number" - range ENV_GPIO_RANGE_MIN ENV_GPIO_IN_RANGE_MAX - default 12 - help - Set the GPIO number used by SPI MISO. - - config EXAMPLE_ETH_SPI_CS_GPIO - int "SPI CS GPIO number" - range ENV_GPIO_RANGE_MIN ENV_GPIO_OUT_RANGE_MAX - default 15 - help - Set the GPIO number used by SPI CS. - - config EXAMPLE_ETH_SPI_CLOCK_MHZ - int "SPI clock speed (MHz)" - range 5 80 - default 36 - help - Set the clock speed (MHz) of SPI interface. - - config EXAMPLE_ETH_SPI_INT_GPIO - int "Interrupt GPIO number" - range ENV_GPIO_RANGE_MIN ENV_GPIO_IN_RANGE_MAX - default 4 - help - Set the GPIO number used by the SPI Ethernet module interrupt line. - endif # EXAMPLE_USE_SPI_ETHERNET - - config EXAMPLE_ETH_PHY_RST_GPIO - int "PHY Reset GPIO number" - range -1 ENV_GPIO_OUT_RANGE_MAX - default 5 - help - Set the GPIO number used to reset PHY chip. - Set to -1 to disable PHY chip hardware reset. - - config EXAMPLE_ETH_PHY_ADDR - int "PHY Address" - range 0 31 if EXAMPLE_USE_INTERNAL_ETHERNET - default 1 - help - Set PHY address according your board schematic. - endif # EXAMPLE_CONNECT_ETHERNET - - config EXAMPLE_CONNECT_IPV6 - bool "Obtain IPv6 address" - default y - depends on EXAMPLE_CONNECT_WIFI || EXAMPLE_CONNECT_ETHERNET - select LWIP_IPV6 - help - By default, examples will wait until IPv4 and IPv6 local link addresses are obtained. - Disable this option if the network does not support IPv6. - Choose the preferred IPv6 address type if the connection code should wait until other than - the local link address gets assigned. - Consider enabling IPv6 stateless address autoconfiguration (SLAAC) in the LWIP component. - - if EXAMPLE_CONNECT_IPV6 - choice EXAMPLE_CONNECT_PREFERRED_IPV6 - prompt "Preferred IPv6 Type" - default EXAMPLE_CONNECT_IPV6_PREF_LOCAL_LINK - help - Select which kind of IPv6 address the connect logic waits for. - - config EXAMPLE_CONNECT_IPV6_PREF_LOCAL_LINK - bool "Local Link Address" - help - Blocks until Local link address assigned. - - config EXAMPLE_CONNECT_IPV6_PREF_GLOBAL - bool "Global Address" - help - Blocks until Global address assigned. - - config EXAMPLE_CONNECT_IPV6_PREF_SITE_LOCAL - bool "Site Local Address" - help - Blocks until Site link address assigned. - - config EXAMPLE_CONNECT_IPV6_PREF_UNIQUE_LOCAL - bool "Unique Local Link Address" - help - Blocks until Unique local address assigned. - - endchoice - - endif - - -endmenu diff --git a/common_components/protocol_examples_common/addr_from_stdin.c b/common_components/protocol_examples_common/addr_from_stdin.c deleted file mode 100644 index 0ea452b596..0000000000 --- a/common_components/protocol_examples_common/addr_from_stdin.c +++ /dev/null @@ -1,68 +0,0 @@ -#include -#include "esp_system.h" -#include "esp_log.h" -#include "esp_netif.h" -#include "protocol_examples_common.h" - -#include "lwip/sockets.h" -#include -#include - -#define HOST_IP_SIZE 128 - -esp_err_t get_addr_from_stdin(int port, int sock_type, int *ip_protocol, int *addr_family, struct sockaddr_storage *dest_addr) -{ - char host_ip[HOST_IP_SIZE]; - int len; - static bool already_init = false; - - // this function could be called multiple times -> make sure UART init runs only once - if (!already_init) { - example_configure_stdin_stdout(); - already_init = true; - } - - // ignore empty or LF only string (could receive from DUT class) - do { - fgets(host_ip, HOST_IP_SIZE, stdin); - len = strlen(host_ip); - } while (len <= 1 && host_ip[0] == '\n'); - host_ip[len - 1] = '\0'; - - struct addrinfo hints, *addr_list, *cur; - memset( &hints, 0, sizeof( hints ) ); - - // run getaddrinfo() to decide on the IP protocol - hints.ai_family = AF_UNSPEC; - hints.ai_socktype = sock_type; - hints.ai_protocol = IPPROTO_TCP; - if ( getaddrinfo( host_ip, NULL, &hints, &addr_list ) != 0 ) { - return ESP_FAIL; - } - for ( cur = addr_list; cur != NULL; cur = cur->ai_next ) { - memcpy(dest_addr, cur->ai_addr, sizeof(*dest_addr)); - if (cur->ai_family == AF_INET) { - *ip_protocol = IPPROTO_IP; - *addr_family = AF_INET; - // add port number and return on first IPv4 match - ((struct sockaddr_in *)dest_addr)->sin_port = htons(port); - freeaddrinfo( addr_list ); - return ESP_OK; - - } -#if CONFIG_LWIP_IPV6 - else if (cur->ai_family == AF_INET6) { - *ip_protocol = IPPROTO_IPV6; - *addr_family = AF_INET6; - // add port and interface number and return on first IPv6 match - ((struct sockaddr_in6 *)dest_addr)->sin6_port = htons(port); - ((struct sockaddr_in6 *)dest_addr)->sin6_scope_id = esp_netif_get_netif_impl_index(EXAMPLE_INTERFACE); - freeaddrinfo( addr_list ); - return ESP_OK; - } -#endif - } - // no match found - freeaddrinfo( addr_list ); - return ESP_FAIL; -} diff --git a/common_components/protocol_examples_common/connect.c b/common_components/protocol_examples_common/connect.c deleted file mode 100644 index 3fae508bd6..0000000000 --- a/common_components/protocol_examples_common/connect.c +++ /dev/null @@ -1,527 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Unlicense OR CC0-1.0 - */ - -/* - * Common functions for protocol examples, to establish Wi-Fi or Ethernet connection. - */ - -#include -#include "protocol_examples_common.h" -#include "sdkconfig.h" -#include "esp_event.h" -#include "esp_wifi.h" -#include "esp_wifi_default.h" -#if CONFIG_EXAMPLE_CONNECT_ETHERNET -#include "esp_eth.h" -#if CONFIG_ETH_USE_SPI_ETHERNET -#include "driver/spi_master.h" -#endif // CONFIG_ETH_USE_SPI_ETHERNET -#endif // CONFIG_EXAMPLE_CONNECT_ETHERNET -#include "esp_log.h" -#include "esp_netif.h" -#include "driver/gpio.h" -#include "freertos/FreeRTOS.h" -#include "freertos/task.h" -#include "freertos/event_groups.h" -#include "lwip/err.h" -#include "lwip/sys.h" - -#ifdef CONFIG_EXAMPLE_CONNECT_IPV6 -#define MAX_IP6_ADDRS_PER_NETIF (5) -#define NR_OF_IP_ADDRESSES_TO_WAIT_FOR (s_active_interfaces*2) - -#if defined(CONFIG_EXAMPLE_CONNECT_IPV6_PREF_LOCAL_LINK) -#define EXAMPLE_CONNECT_PREFERRED_IPV6_TYPE ESP_IP6_ADDR_IS_LINK_LOCAL -#elif defined(CONFIG_EXAMPLE_CONNECT_IPV6_PREF_GLOBAL) -#define EXAMPLE_CONNECT_PREFERRED_IPV6_TYPE ESP_IP6_ADDR_IS_GLOBAL -#elif defined(CONFIG_EXAMPLE_CONNECT_IPV6_PREF_SITE_LOCAL) -#define EXAMPLE_CONNECT_PREFERRED_IPV6_TYPE ESP_IP6_ADDR_IS_SITE_LOCAL -#elif defined(CONFIG_EXAMPLE_CONNECT_IPV6_PREF_UNIQUE_LOCAL) -#define EXAMPLE_CONNECT_PREFERRED_IPV6_TYPE ESP_IP6_ADDR_IS_UNIQUE_LOCAL -#endif // if-elif CONFIG_EXAMPLE_CONNECT_IPV6_PREF_... - -#else -#define NR_OF_IP_ADDRESSES_TO_WAIT_FOR (s_active_interfaces) -#endif - -#define EXAMPLE_DO_CONNECT CONFIG_EXAMPLE_CONNECT_WIFI || CONFIG_EXAMPLE_CONNECT_ETHERNET - -#if CONFIG_EXAMPLE_WIFI_SCAN_METHOD_FAST -#define EXAMPLE_WIFI_SCAN_METHOD WIFI_FAST_SCAN -#elif CONFIG_EXAMPLE_WIFI_SCAN_METHOD_ALL_CHANNEL -#define EXAMPLE_WIFI_SCAN_METHOD WIFI_ALL_CHANNEL_SCAN -#endif - -#if CONFIG_EXAMPLE_WIFI_CONNECT_AP_BY_SIGNAL -#define EXAMPLE_WIFI_CONNECT_AP_SORT_METHOD WIFI_CONNECT_AP_BY_SIGNAL -#elif CONFIG_EXAMPLE_WIFI_CONNECT_AP_BY_SECURITY -#define EXAMPLE_WIFI_CONNECT_AP_SORT_METHOD WIFI_CONNECT_AP_BY_SECURITY -#endif - -#if CONFIG_EXAMPLE_WIFI_AUTH_OPEN -#define EXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_OPEN -#elif CONFIG_EXAMPLE_WIFI_AUTH_WEP -#define EXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WEP -#elif CONFIG_EXAMPLE_WIFI_AUTH_WPA_PSK -#define EXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA_PSK -#elif CONFIG_EXAMPLE_WIFI_AUTH_WPA2_PSK -#define EXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA2_PSK -#elif CONFIG_EXAMPLE_WIFI_AUTH_WPA_WPA2_PSK -#define EXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA_WPA2_PSK -#elif CONFIG_EXAMPLE_WIFI_AUTH_WPA2_ENTERPRISE -#define EXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA2_ENTERPRISE -#elif CONFIG_EXAMPLE_WIFI_AUTH_WPA3_PSK -#define EXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA3_PSK -#elif CONFIG_EXAMPLE_WIFI_AUTH_WPA2_WPA3_PSK -#define EXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA2_WPA3_PSK -#elif CONFIG_EXAMPLE_WIFI_AUTH_WAPI_PSK -#define EXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WAPI_PSK -#endif - -static int s_active_interfaces = 0; -static SemaphoreHandle_t s_semph_get_ip_addrs; -static esp_netif_t *s_example_esp_netif = NULL; - -#ifdef CONFIG_EXAMPLE_CONNECT_IPV6 -static esp_ip6_addr_t s_ipv6_addr; - -/* types of ipv6 addresses to be displayed on ipv6 events */ -static const char *s_ipv6_addr_types[] = { - "ESP_IP6_ADDR_IS_UNKNOWN", - "ESP_IP6_ADDR_IS_GLOBAL", - "ESP_IP6_ADDR_IS_LINK_LOCAL", - "ESP_IP6_ADDR_IS_SITE_LOCAL", - "ESP_IP6_ADDR_IS_UNIQUE_LOCAL", - "ESP_IP6_ADDR_IS_IPV4_MAPPED_IPV6" -}; -#endif - -static const char *TAG = "example_connect"; - -#if CONFIG_EXAMPLE_CONNECT_WIFI -static esp_netif_t *wifi_start(void); -static void wifi_stop(void); -#endif -#if CONFIG_EXAMPLE_CONNECT_ETHERNET -static esp_netif_t *eth_start(void); -static void eth_stop(void); -#endif - -/** - * @brief Checks the netif description if it contains specified prefix. - * All netifs created withing common connect component are prefixed with the module TAG, - * so it returns true if the specified netif is owned by this module - */ -static bool is_our_netif(const char *prefix, esp_netif_t *netif) -{ - return strncmp(prefix, esp_netif_get_desc(netif), strlen(prefix) - 1) == 0; -} - -/* set up connection, Wi-Fi and/or Ethernet */ -static void start(void) -{ - -#if CONFIG_EXAMPLE_CONNECT_WIFI - s_example_esp_netif = wifi_start(); - s_active_interfaces++; -#endif - -#if CONFIG_EXAMPLE_CONNECT_ETHERNET - s_example_esp_netif = eth_start(); - s_active_interfaces++; -#endif - -#if CONFIG_EXAMPLE_CONNECT_WIFI && CONFIG_EXAMPLE_CONNECT_ETHERNET - /* if both intefaces at once, clear out to indicate that multiple netifs are active */ - s_example_esp_netif = NULL; -#endif - -#if EXAMPLE_DO_CONNECT - /* create semaphore if at least one interface is active */ - s_semph_get_ip_addrs = xSemaphoreCreateCounting(NR_OF_IP_ADDRESSES_TO_WAIT_FOR, 0); -#endif - -} - -/* tear down connection, release resources */ -static void stop(void) -{ -#if CONFIG_EXAMPLE_CONNECT_WIFI - wifi_stop(); - s_active_interfaces--; -#endif - -#if CONFIG_EXAMPLE_CONNECT_ETHERNET - eth_stop(); - s_active_interfaces--; -#endif -} - -#if EXAMPLE_DO_CONNECT -static esp_ip4_addr_t s_ip_addr; - -static void on_got_ip(void *arg, esp_event_base_t event_base, - int32_t event_id, void *event_data) -{ - ip_event_got_ip_t *event = (ip_event_got_ip_t *)event_data; - if (!is_our_netif(TAG, event->esp_netif)) { - ESP_LOGW(TAG, "Got IPv4 from another interface \"%s\": ignored", esp_netif_get_desc(event->esp_netif)); - return; - } - ESP_LOGI(TAG, "Got IPv4 event: Interface \"%s\" address: " IPSTR, esp_netif_get_desc(event->esp_netif), IP2STR(&event->ip_info.ip)); - memcpy(&s_ip_addr, &event->ip_info.ip, sizeof(s_ip_addr)); - xSemaphoreGive(s_semph_get_ip_addrs); -} -#endif - -#ifdef CONFIG_EXAMPLE_CONNECT_IPV6 - -static void on_got_ipv6(void *arg, esp_event_base_t event_base, - int32_t event_id, void *event_data) -{ - ip_event_got_ip6_t *event = (ip_event_got_ip6_t *)event_data; - if (!is_our_netif(TAG, event->esp_netif)) { - ESP_LOGW(TAG, "Got IPv6 from another netif: ignored"); - return; - } - esp_ip6_addr_type_t ipv6_type = esp_netif_ip6_get_addr_type(&event->ip6_info.ip); - ESP_LOGI(TAG, "Got IPv6 event: Interface \"%s\" address: " IPV6STR ", type: %s", esp_netif_get_desc(event->esp_netif), - IPV62STR(event->ip6_info.ip), s_ipv6_addr_types[ipv6_type]); - if (ipv6_type == EXAMPLE_CONNECT_PREFERRED_IPV6_TYPE) { - memcpy(&s_ipv6_addr, &event->ip6_info.ip, sizeof(s_ipv6_addr)); - xSemaphoreGive(s_semph_get_ip_addrs); - } -} - -#endif // CONFIG_EXAMPLE_CONNECT_IPV6 - -esp_err_t example_connect(void) -{ -#if EXAMPLE_DO_CONNECT - if (s_semph_get_ip_addrs != NULL) { - return ESP_ERR_INVALID_STATE; - } -#endif - start(); - ESP_ERROR_CHECK(esp_register_shutdown_handler(&stop)); - ESP_LOGI(TAG, "Waiting for IP(s)"); - for (int i = 0; i < NR_OF_IP_ADDRESSES_TO_WAIT_FOR; ++i) { - xSemaphoreTake(s_semph_get_ip_addrs, portMAX_DELAY); - } - // iterate over active interfaces, and print out IPs of "our" netifs - esp_netif_t *netif = NULL; - esp_netif_ip_info_t ip; - for (int i = 0; i < esp_netif_get_nr_of_ifs(); ++i) { - netif = esp_netif_next(netif); - if (is_our_netif(TAG, netif)) { - ESP_LOGI(TAG, "Connected to %s", esp_netif_get_desc(netif)); - ESP_ERROR_CHECK(esp_netif_get_ip_info(netif, &ip)); - - ESP_LOGI(TAG, "- IPv4 address: " IPSTR, IP2STR(&ip.ip)); -#ifdef CONFIG_EXAMPLE_CONNECT_IPV6 - esp_ip6_addr_t ip6[MAX_IP6_ADDRS_PER_NETIF]; - int ip6_addrs = esp_netif_get_all_ip6(netif, ip6); - for (int j = 0; j < ip6_addrs; ++j) { - esp_ip6_addr_type_t ipv6_type = esp_netif_ip6_get_addr_type(&(ip6[j])); - ESP_LOGI(TAG, "- IPv6 address: " IPV6STR ", type: %s", IPV62STR(ip6[j]), s_ipv6_addr_types[ipv6_type]); - } -#endif - - } - } - return ESP_OK; -} - -esp_err_t example_disconnect(void) -{ - if (s_semph_get_ip_addrs == NULL) { - return ESP_ERR_INVALID_STATE; - } - vSemaphoreDelete(s_semph_get_ip_addrs); - s_semph_get_ip_addrs = NULL; - stop(); - ESP_ERROR_CHECK(esp_unregister_shutdown_handler(&stop)); - return ESP_OK; -} - -#ifdef CONFIG_EXAMPLE_CONNECT_WIFI - -static void on_wifi_disconnect(void *arg, esp_event_base_t event_base, - int32_t event_id, void *event_data) -{ - ESP_LOGI(TAG, "Wi-Fi disconnected, trying to reconnect..."); - esp_err_t err = esp_wifi_connect(); - if (err == ESP_ERR_WIFI_NOT_STARTED) { - return; - } - ESP_ERROR_CHECK(err); -} - -#ifdef CONFIG_EXAMPLE_CONNECT_IPV6 - -static void on_wifi_connect(void *esp_netif, esp_event_base_t event_base, - int32_t event_id, void *event_data) -{ - esp_netif_create_ip6_linklocal(esp_netif); -} - -#endif // CONFIG_EXAMPLE_CONNECT_IPV6 - -static esp_netif_t *wifi_start(void) -{ - char *desc; - wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); - ESP_ERROR_CHECK(esp_wifi_init(&cfg)); - - esp_netif_inherent_config_t esp_netif_config = ESP_NETIF_INHERENT_DEFAULT_WIFI_STA(); - // Prefix the interface description with the module TAG - // Warning: the interface desc is used in tests to capture actual connection details (IP, gw, mask) - asprintf(&desc, "%s: %s", TAG, esp_netif_config.if_desc); - esp_netif_config.if_desc = desc; - esp_netif_config.route_prio = 128; - esp_netif_t *netif = esp_netif_create_wifi(WIFI_IF_STA, &esp_netif_config); - free(desc); - esp_wifi_set_default_wifi_sta_handlers(); - - ESP_ERROR_CHECK(esp_event_handler_register(WIFI_EVENT, WIFI_EVENT_STA_DISCONNECTED, &on_wifi_disconnect, NULL)); - ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT, IP_EVENT_STA_GOT_IP, &on_got_ip, NULL)); -#ifdef CONFIG_EXAMPLE_CONNECT_IPV6 - ESP_ERROR_CHECK(esp_event_handler_register(WIFI_EVENT, WIFI_EVENT_STA_CONNECTED, &on_wifi_connect, netif)); - ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT, IP_EVENT_GOT_IP6, &on_got_ipv6, NULL)); -#endif - - ESP_ERROR_CHECK(esp_wifi_set_storage(WIFI_STORAGE_RAM)); - wifi_config_t wifi_config = { - .sta = { - .ssid = CONFIG_EXAMPLE_WIFI_SSID, - .password = CONFIG_EXAMPLE_WIFI_PASSWORD, - .scan_method = EXAMPLE_WIFI_SCAN_METHOD, - .sort_method = EXAMPLE_WIFI_CONNECT_AP_SORT_METHOD, - .threshold.rssi = CONFIG_EXAMPLE_WIFI_SCAN_RSSI_THRESHOLD, - .threshold.authmode = EXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLD, - }, - }; - ESP_LOGI(TAG, "Connecting to %s...", wifi_config.sta.ssid); - 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_wifi_connect(); - return netif; -} - -static void wifi_stop(void) -{ - esp_netif_t *wifi_netif = get_example_netif_from_desc("sta"); - ESP_ERROR_CHECK(esp_event_handler_unregister(WIFI_EVENT, WIFI_EVENT_STA_DISCONNECTED, &on_wifi_disconnect)); - ESP_ERROR_CHECK(esp_event_handler_unregister(IP_EVENT, IP_EVENT_STA_GOT_IP, &on_got_ip)); -#ifdef CONFIG_EXAMPLE_CONNECT_IPV6 - ESP_ERROR_CHECK(esp_event_handler_unregister(IP_EVENT, IP_EVENT_GOT_IP6, &on_got_ipv6)); - ESP_ERROR_CHECK(esp_event_handler_unregister(WIFI_EVENT, WIFI_EVENT_STA_CONNECTED, &on_wifi_connect)); -#endif - esp_err_t err = esp_wifi_stop(); - if (err == ESP_ERR_WIFI_NOT_INIT) { - return; - } - ESP_ERROR_CHECK(err); - ESP_ERROR_CHECK(esp_wifi_deinit()); - ESP_ERROR_CHECK(esp_wifi_clear_default_wifi_driver_and_handlers(wifi_netif)); - esp_netif_destroy(wifi_netif); - s_example_esp_netif = NULL; -} -#endif // CONFIG_EXAMPLE_CONNECT_WIFI - -#ifdef CONFIG_EXAMPLE_CONNECT_ETHERNET - -#ifdef CONFIG_EXAMPLE_CONNECT_IPV6 - -/** Event handler for Ethernet events */ -static void on_eth_event(void *esp_netif, esp_event_base_t event_base, - int32_t event_id, void *event_data) -{ - switch (event_id) { - case ETHERNET_EVENT_CONNECTED: - ESP_LOGI(TAG, "Ethernet Link Up"); - ESP_ERROR_CHECK(esp_netif_create_ip6_linklocal(esp_netif)); - break; - default: - break; - } -} - -#endif // CONFIG_EXAMPLE_CONNECT_IPV6 - -static esp_eth_handle_t s_eth_handle = NULL; -static esp_eth_mac_t *s_mac = NULL; -static esp_eth_phy_t *s_phy = NULL; -static esp_eth_netif_glue_handle_t s_eth_glue = NULL; - -static esp_netif_t *eth_start(void) -{ - char *desc; - esp_netif_inherent_config_t esp_netif_config = ESP_NETIF_INHERENT_DEFAULT_ETH(); - // Prefix the interface description with the module TAG - // Warning: the interface desc is used in tests to capture actual connection details (IP, gw, mask) - asprintf(&desc, "%s: %s", TAG, esp_netif_config.if_desc); - esp_netif_config.if_desc = desc; - esp_netif_config.route_prio = 64; - esp_netif_config_t netif_config = { - .base = &esp_netif_config, - .stack = ESP_NETIF_NETSTACK_DEFAULT_ETH - }; - esp_netif_t *netif = esp_netif_new(&netif_config); - assert(netif); - free(desc); - - eth_mac_config_t mac_config = ETH_MAC_DEFAULT_CONFIG(); - eth_phy_config_t phy_config = ETH_PHY_DEFAULT_CONFIG(); - phy_config.phy_addr = CONFIG_EXAMPLE_ETH_PHY_ADDR; - phy_config.reset_gpio_num = CONFIG_EXAMPLE_ETH_PHY_RST_GPIO; -#if CONFIG_EXAMPLE_USE_INTERNAL_ETHERNET - eth_esp32_emac_config_t esp32_emac_config = ETH_ESP32_EMAC_DEFAULT_CONFIG(); - esp32_emac_config.smi_mdc_gpio_num = CONFIG_EXAMPLE_ETH_MDC_GPIO; - esp32_emac_config.smi_mdio_gpio_num = CONFIG_EXAMPLE_ETH_MDIO_GPIO; - s_mac = esp_eth_mac_new_esp32(&esp32_emac_config, &mac_config); -#if CONFIG_EXAMPLE_ETH_PHY_IP101 - s_phy = esp_eth_phy_new_ip101(&phy_config); -#elif CONFIG_EXAMPLE_ETH_PHY_RTL8201 - s_phy = esp_eth_phy_new_rtl8201(&phy_config); -#elif CONFIG_EXAMPLE_ETH_PHY_LAN87XX - s_phy = esp_eth_phy_new_lan87xx(&phy_config); -#elif CONFIG_EXAMPLE_ETH_PHY_DP83848 - s_phy = esp_eth_phy_new_dp83848(&phy_config); -#elif CONFIG_EXAMPLE_ETH_PHY_KSZ80XX - s_phy = esp_eth_phy_new_ksz80xx(&phy_config); -#endif -#elif CONFIG_EXAMPLE_USE_SPI_ETHERNET - gpio_install_isr_service(0); -#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0) - spi_device_handle_t spi_handle = NULL; -#endif - spi_bus_config_t buscfg = { - .miso_io_num = CONFIG_EXAMPLE_ETH_SPI_MISO_GPIO, - .mosi_io_num = CONFIG_EXAMPLE_ETH_SPI_MOSI_GPIO, - .sclk_io_num = CONFIG_EXAMPLE_ETH_SPI_SCLK_GPIO, - .quadwp_io_num = -1, - .quadhd_io_num = -1, - }; - ESP_ERROR_CHECK(spi_bus_initialize(CONFIG_EXAMPLE_ETH_SPI_HOST, &buscfg, 1)); -#if CONFIG_EXAMPLE_USE_DM9051 - spi_device_interface_config_t devcfg = { - .command_bits = 1, - .address_bits = 7, - .mode = 0, - .clock_speed_hz = CONFIG_EXAMPLE_ETH_SPI_CLOCK_MHZ * 1000 * 1000, - .spics_io_num = CONFIG_EXAMPLE_ETH_SPI_CS_GPIO, - .queue_size = 20 - }; -#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0) - ESP_ERROR_CHECK(spi_bus_add_device(CONFIG_EXAMPLE_ETH_SPI_HOST, &devcfg, &spi_handle)); - /* dm9051 ethernet driver is based on spi driver */ - eth_dm9051_config_t dm9051_config = ETH_DM9051_DEFAULT_CONFIG(spi_handle); -#else - eth_dm9051_config_t dm9051_config = ETH_DM9051_DEFAULT_CONFIG(CONFIG_EXAMPLE_ETH_SPI_HOST, &devcfg); -#endif // ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0) - - dm9051_config.int_gpio_num = CONFIG_EXAMPLE_ETH_SPI_INT_GPIO; - s_mac = esp_eth_mac_new_dm9051(&dm9051_config, &mac_config); - s_phy = esp_eth_phy_new_dm9051(&phy_config); -#elif CONFIG_EXAMPLE_USE_W5500 - spi_device_interface_config_t devcfg = { - .command_bits = 16, // Actually it's the address phase in W5500 SPI frame - .address_bits = 8, // Actually it's the control phase in W5500 SPI frame - .mode = 0, - .clock_speed_hz = CONFIG_EXAMPLE_ETH_SPI_CLOCK_MHZ * 1000 * 1000, - .spics_io_num = CONFIG_EXAMPLE_ETH_SPI_CS_GPIO, - .queue_size = 20 - }; -#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0) - ESP_ERROR_CHECK(spi_bus_add_device(CONFIG_EXAMPLE_ETH_SPI_HOST, &devcfg, &spi_handle)); - /* w5500 ethernet driver is based on spi driver */ - eth_w5500_config_t w5500_config = ETH_W5500_DEFAULT_CONFIG(spi_handle); -#else - eth_w5500_config_t w5500_config = ETH_W5500_DEFAULT_CONFIG(CONFIG_EXAMPLE_ETH_SPI_HOST, &devcfg); -#endif // ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0) - w5500_config.int_gpio_num = CONFIG_EXAMPLE_ETH_SPI_INT_GPIO; - s_mac = esp_eth_mac_new_w5500(&w5500_config, &mac_config); - s_phy = esp_eth_phy_new_w5500(&phy_config); -#endif -#elif CONFIG_EXAMPLE_USE_OPENETH - phy_config.autonego_timeout_ms = 100; - s_mac = esp_eth_mac_new_openeth(&mac_config); - s_phy = esp_eth_phy_new_dp83848(&phy_config); -#endif - - // Install Ethernet driver - esp_eth_config_t config = ETH_DEFAULT_CONFIG(s_mac, s_phy); - ESP_ERROR_CHECK(esp_eth_driver_install(&config, &s_eth_handle)); -#if !CONFIG_EXAMPLE_USE_INTERNAL_ETHERNET - /* The SPI Ethernet module might doesn't have a burned factory MAC address, we cat to set it manually. - 02:00:00 is a Locally Administered OUI range so should not be used except when testing on a LAN under your control. - */ - ESP_ERROR_CHECK(esp_eth_ioctl(s_eth_handle, ETH_CMD_S_MAC_ADDR, (uint8_t[]) { - 0x02, 0x00, 0x00, 0x12, 0x34, 0x56 - })); -#endif - // combine driver with netif - s_eth_glue = esp_eth_new_netif_glue(s_eth_handle); - esp_netif_attach(netif, s_eth_glue); - - // Register user defined event handers - ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT, IP_EVENT_ETH_GOT_IP, &on_got_ip, NULL)); -#ifdef CONFIG_EXAMPLE_CONNECT_IPV6 - ESP_ERROR_CHECK(esp_event_handler_register(ETH_EVENT, ETHERNET_EVENT_CONNECTED, &on_eth_event, netif)); - ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT, IP_EVENT_GOT_IP6, &on_got_ipv6, NULL)); -#endif - - esp_eth_start(s_eth_handle); - return netif; -} - -static void eth_stop(void) -{ - esp_netif_t *eth_netif = get_example_netif_from_desc("eth"); - ESP_ERROR_CHECK(esp_event_handler_unregister(IP_EVENT, IP_EVENT_ETH_GOT_IP, &on_got_ip)); -#ifdef CONFIG_EXAMPLE_CONNECT_IPV6 - ESP_ERROR_CHECK(esp_event_handler_unregister(IP_EVENT, IP_EVENT_GOT_IP6, &on_got_ipv6)); - ESP_ERROR_CHECK(esp_event_handler_unregister(ETH_EVENT, ETHERNET_EVENT_CONNECTED, &on_eth_event)); -#endif - ESP_ERROR_CHECK(esp_eth_stop(s_eth_handle)); - ESP_ERROR_CHECK(esp_eth_del_netif_glue(s_eth_glue)); - ESP_ERROR_CHECK(esp_eth_driver_uninstall(s_eth_handle)); - s_eth_handle = NULL; - ESP_ERROR_CHECK(s_phy->del(s_phy)); - ESP_ERROR_CHECK(s_mac->del(s_mac)); - - esp_netif_destroy(eth_netif); - s_example_esp_netif = NULL; -} - -esp_eth_handle_t get_example_eth_handle(void) -{ - return s_eth_handle; -} - -#endif // CONFIG_EXAMPLE_CONNECT_ETHERNET - -esp_netif_t *get_example_netif(void) -{ - return s_example_esp_netif; -} - -esp_netif_t *get_example_netif_from_desc(const char *desc) -{ - esp_netif_t *netif = NULL; - char *expected_desc; - asprintf(&expected_desc, "%s: %s", TAG, desc); - while ((netif = esp_netif_next(netif)) != NULL) { - if (strcmp(esp_netif_get_desc(netif), expected_desc) == 0) { - free(expected_desc); - return netif; - } - } - free(expected_desc); - return netif; -} diff --git a/common_components/protocol_examples_common/include/addr_from_stdin.h b/common_components/protocol_examples_common/include/addr_from_stdin.h deleted file mode 100644 index 823f988837..0000000000 --- a/common_components/protocol_examples_common/include/addr_from_stdin.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Unlicense OR CC0-1.0 - */ - -/* Common utilities for socket address input interface: - The API get_addr_from_stdin() is mainly used by socket client examples which read IP address from stdin (if configured). - This option is typically used in the CI, but could be enabled in the project configuration. - In that case this component is used to receive a string that is evaluated and processed to output - socket structures to open a connectio - */ - -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -#include "lwip/sys.h" -#include -#include - -/** - * @brief Read and evaluate IP address from stdin - * - * This API reads stdin and parses the input address using getaddrinfo() - * to fill in struct sockaddr_storage (for both IPv4 and IPv6) used to open - * a socket. IP protocol is guessed from the IP address string. - * - * @param[in] port port number of expected connection - * @param[in] sock_type expected protocol: SOCK_STREAM or SOCK_DGRAM - * @param[out] ip_protocol resultant IP protocol: IPPROTO_IP or IPPROTO_IP6 - * @param[out] addr_family resultant address family: AF_INET or AF_INET6 - * @param[out] dest_addr sockaddr_storage structure (for both IPv4 and IPv6) - * @return ESP_OK on success, ESP_FAIL otherwise - */ -esp_err_t get_addr_from_stdin(int port, int sock_type, - int *ip_protocol, - int *addr_family, - struct sockaddr_storage *dest_addr); - -#ifdef __cplusplus -} -#endif diff --git a/common_components/protocol_examples_common/include/protocol_examples_common.h b/common_components/protocol_examples_common/include/protocol_examples_common.h deleted file mode 100644 index 44506264da..0000000000 --- a/common_components/protocol_examples_common/include/protocol_examples_common.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Unlicense OR CC0-1.0 - */ - -/* - * Common functions for protocol examples, to establish Wi-Fi or Ethernet connection. - */ - -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -#include "esp_err.h" -#include "esp_netif.h" -#include "esp_eth.h" - -#ifdef CONFIG_EXAMPLE_CONNECT_ETHERNET -#define EXAMPLE_INTERFACE get_example_netif() -#endif - -#ifdef CONFIG_EXAMPLE_CONNECT_WIFI -#define EXAMPLE_INTERFACE get_example_netif() -#endif - -#if !defined (CONFIG_EXAMPLE_CONNECT_ETHERNET) && !defined (CONFIG_EXAMPLE_CONNECT_WIFI) -// This is useful for some tests which do not need a network connection -#define EXAMPLE_INTERFACE NULL -#endif - -/** - * @brief Configure Wi-Fi or Ethernet, connect, wait for IP - * - * This all-in-one helper function is used in protocols examples to - * reduce the amount of boilerplate in the example. - * - * It is not intended to be used in real world applications. - * See examples under examples/wifi/getting_started/ and examples/ethernet/ - * for more complete Wi-Fi or Ethernet initialization code. - * - * Read "Establishing Wi-Fi or Ethernet Connection" section in - * examples/protocols/README.md for more information about this function. - * - * @return ESP_OK on successful connection - */ -esp_err_t example_connect(void); - -/** - * Counterpart to example_connect, de-initializes Wi-Fi or Ethernet - */ -esp_err_t example_disconnect(void); - -/** - * @brief Configure stdin and stdout to use blocking I/O - * - * This helper function is used in ASIO examples. It wraps installing the - * UART driver and configuring VFS layer to use UART driver for console I/O. - */ -esp_err_t example_configure_stdin_stdout(void); - -/** - * @brief Returns esp-netif pointer created by example_connect() - * - * @note If multiple interfaces active at once, this API return NULL - * In that case the get_example_netif_from_desc() should be used - * to get esp-netif pointer based on interface description - */ -esp_netif_t *get_example_netif(void); - -/** - * @brief Returns esp-netif pointer created by example_connect() described by - * the supplied desc field - * - * @param desc Textual interface of created network interface, for example "sta" - * indicate default WiFi station, "eth" default Ethernet interface. - * - */ -esp_netif_t *get_example_netif_from_desc(const char *desc); - -#ifdef CONFIG_EXAMPLE_CONNECT_ETHERNET -/** - * @brief Get the example Ethernet driver handle - * - * @return esp_eth_handle_t - */ -esp_eth_handle_t get_example_eth_handle(void); -#endif // CONFIG_EXAMPLE_CONNECT_ETHERNET - -#ifdef __cplusplus -} -#endif diff --git a/common_components/protocol_examples_common/stdin_out.c b/common_components/protocol_examples_common/stdin_out.c deleted file mode 100644 index e3c3aa151a..0000000000 --- a/common_components/protocol_examples_common/stdin_out.c +++ /dev/null @@ -1,30 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Unlicense OR CC0-1.0 - */ - -/* - * Common functions for protocol examples, to configure stdin and stdout. - */ - -#include "protocol_examples_common.h" -#include "esp_err.h" -#include "esp_vfs_dev.h" -#include "driver/uart.h" -#include "sdkconfig.h" - -esp_err_t example_configure_stdin_stdout(void) -{ - // Initialize VFS & UART so we can use std::cout/cin - setvbuf(stdin, NULL, _IONBF, 0); - /* Install UART driver for interrupt-driven reads and writes */ - ESP_ERROR_CHECK( uart_driver_install( (uart_port_t)CONFIG_ESP_CONSOLE_UART_NUM, - 256, 0, 0, NULL, 0) ); - /* Tell VFS to use UART driver */ - esp_vfs_dev_uart_use_driver(CONFIG_ESP_CONSOLE_UART_NUM); - esp_vfs_dev_uart_port_set_rx_line_endings(CONFIG_ESP_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CR); - /* Move the caret to the beginning of the next line on '\n' */ - esp_vfs_dev_uart_port_set_tx_line_endings(CONFIG_ESP_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CRLF); - return ESP_OK; -} diff --git a/components/mdns/tests/test_apps/CMakeLists.txt b/components/mdns/tests/test_apps/CMakeLists.txt index 1be2ce1c6f..62d1565f92 100644 --- a/components/mdns/tests/test_apps/CMakeLists.txt +++ b/components/mdns/tests/test_apps/CMakeLists.txt @@ -2,10 +2,6 @@ # in this exact order for cmake to work correctly cmake_minimum_required(VERSION 3.5) -# (Not part of the boilerplate) -# This example uses an extra component for common functions such as Wi-Fi and Ethernet connection. -set(EXTRA_COMPONENT_DIRS ../../ ../../../../common_components/protocol_examples_common) - include($ENV{IDF_PATH}/tools/cmake/project.cmake) project(mdns_test_app) diff --git a/components/mdns/tests/test_apps/main/idf_component.yml b/components/mdns/tests/test_apps/main/idf_component.yml new file mode 100644 index 0000000000..e9277dfc99 --- /dev/null +++ b/components/mdns/tests/test_apps/main/idf_component.yml @@ -0,0 +1,8 @@ +dependencies: + ## Required IDF version + idf: ">=5.0" + espressif/mdns: + version: "^1.0.0" + override_path: "../../../" + protocol_examples_common: + path: ${IDF_PATH}/examples/common_components/protocol_examples_common diff --git a/examples/mqtt/CMakeLists.txt b/examples/mqtt/CMakeLists.txt index 49dde1536b..b07caaa52c 100644 --- a/examples/mqtt/CMakeLists.txt +++ b/examples/mqtt/CMakeLists.txt @@ -1,9 +1,6 @@ # This project serves as a demo to enable using esp-mqtt on ESP platform targets as well as on linux cmake_minimum_required(VERSION 3.16) -# For ESP32 platform target -set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/protocol_examples_common) - if("${IDF_TARGET}" STREQUAL "linux") # For linux-target we have two options: # - With lwIP (must be defined on command line, e.g. idf.py -DWITH_LWIP=1) diff --git a/examples/mqtt/main/idf_component.yml b/examples/mqtt/main/idf_component.yml new file mode 100644 index 0000000000..718194867b --- /dev/null +++ b/examples/mqtt/main/idf_component.yml @@ -0,0 +1,3 @@ +dependencies: + protocol_examples_common: + path: ${IDF_PATH}/examples/common_components/protocol_examples_common