From 3262d745138cbc6946cd09f5acd744bc6fa60a7f Mon Sep 17 00:00:00 2001 From: zhangwenxu Date: Tue, 4 Jan 2022 20:45:37 +0800 Subject: [PATCH 1/2] openthread: ot extension command refactor --- .../extension_command/CMakeLists.txt | 22 ++ .../extension_command/Kconfig.projbuild | 44 ++++ .../openthread/extension_command/README.md | 191 ++++++++++++++++++ .../include}/esp_ot_cli_extension.h | 2 +- .../include}/esp_ot_iperf.h | 4 +- .../include}/esp_ot_tcp_socket.h | 4 +- .../include}/esp_ot_udp_socket.h | 0 .../include/esp_ot_wifi_cmd.h} | 12 +- .../src}/esp_ot_cli_extension.c | 12 +- .../src}/esp_ot_iperf.c | 4 +- .../src}/esp_ot_tcp_socket.c | 4 +- .../src}/esp_ot_udp_socket.c | 0 .../src/esp_ot_wifi_cmd.c} | 56 ++--- examples/openthread/ot_br/CMakeLists.txt | 4 +- examples/openthread/ot_br/README.md | 49 +---- examples/openthread/ot_br/main/CMakeLists.txt | 11 +- examples/openthread/ot_br/main/esp_ot_br.c | 4 +- .../ot_br/main/esp_ot_cli_extension.c | 29 --- examples/openthread/ot_cli/CMakeLists.txt | 4 +- examples/openthread/ot_cli/README.md | 111 +--------- .../openthread/ot_cli/main/CMakeLists.txt | 8 +- .../openthread/ot_cli/main/Kconfig.projbuild | 23 --- .../ot_cli/main/esp_ot_cli_extension.h | 28 --- 23 files changed, 315 insertions(+), 311 deletions(-) create mode 100644 examples/openthread/extension_command/CMakeLists.txt create mode 100644 examples/openthread/extension_command/Kconfig.projbuild create mode 100644 examples/openthread/extension_command/README.md rename examples/openthread/{ot_br/main => extension_command/include}/esp_ot_cli_extension.h (87%) rename examples/openthread/{ot_cli/main => extension_command/include}/esp_ot_iperf.h (83%) rename examples/openthread/{ot_cli/main => extension_command/include}/esp_ot_tcp_socket.h (86%) rename examples/openthread/{ot_cli/main => extension_command/include}/esp_ot_udp_socket.h (100%) rename examples/openthread/{ot_br/main/esp_br_wifi_cmd.h => extension_command/include/esp_ot_wifi_cmd.h} (64%) rename examples/openthread/{ot_cli/main => extension_command/src}/esp_ot_cli_extension.c (74%) rename examples/openthread/{ot_cli/main => extension_command/src}/esp_ot_iperf.c (97%) rename examples/openthread/{ot_cli/main => extension_command/src}/esp_ot_tcp_socket.c (98%) rename examples/openthread/{ot_cli/main => extension_command/src}/esp_ot_udp_socket.c (100%) rename examples/openthread/{ot_br/main/esp_br_wifi_cmd.c => extension_command/src/esp_ot_wifi_cmd.c} (74%) delete mode 100644 examples/openthread/ot_br/main/esp_ot_cli_extension.c delete mode 100644 examples/openthread/ot_cli/main/Kconfig.projbuild delete mode 100644 examples/openthread/ot_cli/main/esp_ot_cli_extension.h diff --git a/examples/openthread/extension_command/CMakeLists.txt b/examples/openthread/extension_command/CMakeLists.txt new file mode 100644 index 0000000000..d8b4a31ee9 --- /dev/null +++ b/examples/openthread/extension_command/CMakeLists.txt @@ -0,0 +1,22 @@ +set(srcs "src/esp_ot_cli_extension.c") + +if(CONFIG_OPENTHREAD_CLI_IPERF) + list(APPEND srcs "src/esp_ot_iperf.c") +endif() + +if(CONFIG_OPENTHREAD_CLI_TCP_SOCKET) + list(APPEND srcs "src/esp_ot_tcp_socket.c") +endif() + +if(CONFIG_OPENTHREAD_CLI_UDP_SOCKET) + list(APPEND srcs "src/esp_ot_udp_socket.c") +endif() + +if(CONFIG_OPENTHREAD_CLI_WIFI) + list(APPEND srcs "src/esp_ot_wifi_cmd.c") +endif() + +set(include "include") +idf_component_register(SRCS "${srcs}" + INCLUDE_DIRS "${include}" + REQUIRES lwip openthread iperf) diff --git a/examples/openthread/extension_command/Kconfig.projbuild b/examples/openthread/extension_command/Kconfig.projbuild new file mode 100644 index 0000000000..295d6bde1f --- /dev/null +++ b/examples/openthread/extension_command/Kconfig.projbuild @@ -0,0 +1,44 @@ +menu "OpenThread Extension CLI" + + menuconfig OPENTHREAD_CLI_ESP_EXTENSION + depends on OPENTHREAD_FTD || OPENTHREAD_MTD + bool "Enable Espressif's extended features" + default y + help + Enable Espressif's extended features. + + config OPENTHREAD_CLI_IPERF + bool "Enable iperf command" + depends on OPENTHREAD_CLI_ESP_EXTENSION + default y + + config OPENTHREAD_CLI_TCP_SOCKET + bool "Enable TCP socket command" + depends on OPENTHREAD_CLI_ESP_EXTENSION + default y + + config OPENTHREAD_CLI_TCP_SERVER_PORT + int "the port of TCP server" + default 12345 + depends on OPENTHREAD_CLI_TCP_SOCKET + help + Set the connect port of socket + + config OPENTHREAD_CLI_UDP_SOCKET + bool "Enable UDP socket command" + depends on OPENTHREAD_CLI_ESP_EXTENSION + default y + + config OPENTHREAD_CLI_UDP_SERVER_PORT + int "the port of UDP server" + default 54321 + depends on OPENTHREAD_CLI_UDP_SOCKET + help + Set the connect port of socket + + config OPENTHREAD_CLI_WIFI + bool "Enable wifi connection command" + depends on OPENTHREAD_CLI_ESP_EXTENSION && OPENTHREAD_BORDER_ROUTER + default y + +endmenu diff --git a/examples/openthread/extension_command/README.md b/examples/openthread/extension_command/README.md new file mode 100644 index 0000000000..113f5932dd --- /dev/null +++ b/examples/openthread/extension_command/README.md @@ -0,0 +1,191 @@ +# Openthread Extension Command + +The Openthread Extension Command is a series of command lines extended from [OpenThread CLI](https://github.com/openthread/openthread/blob/main/src/cli/README.md). +Openthread Extension Command doesn't run alone, it needs to be used in conjunction with these examples: +* [ot_cli](../ot_cli) +* [ot_br](../ot_br) + +## How to use the example + +Run the configuration command `idf.py menuconfig` to enable the operations you need for your example: `OpenThread Extension CLI` -> `Enable Espressif's extended features`. + +## OT Extension Command Line List + +* [iperf](#iperf) +* [tcpsockclient](#tcpsockclient) +* [tcpsockserver](#tcpsockserver) +* [udpsockclient](#udpsockclient) +* [udpsockserver](#udpsockserver) +* [wifi](#wifi) + +### iperf + +Iperf is a tool for active measurements of the maximum achievable bandwidth on Thread network, which is based TCP and UDP. + +Print the iperf help: +```bash +iperf +---iperf parameter--- +-s : server mode, only receive +-u : upd mode +-V : use IPV6 address +-c : client mode, only transmit +-i : seconds between periodic bandwidth reports +-t