esp_ot_cli_extension.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: CC0-1.0
  5. *
  6. * OpenThread Command Line Example
  7. *
  8. * This example code is in the Public Domain (or CC0 licensed, at your option.)
  9. *
  10. * Unless required by applicable law or agreed to in writing, this
  11. * software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
  12. * CONDITIONS OF ANY KIND, either express or implied.
  13. */
  14. #include "esp_openthread.h"
  15. #include "esp_ot_cli_extension.h"
  16. #include "esp_ot_iperf.h"
  17. #include "esp_ot_tcp_socket.h"
  18. #include "esp_ot_udp_socket.h"
  19. #include "esp_ot_wifi_cmd.h"
  20. #include "freertos/FreeRTOS.h"
  21. #include "freertos/portmacro.h"
  22. #include "freertos/task.h"
  23. #include "openthread/cli.h"
  24. static const otCliCommand kCommands[] = {
  25. #if CONFIG_OPENTHREAD_CLI_TCP_SOCKET
  26. {"tcpsockserver", esp_ot_process_tcp_server},
  27. {"tcpsockclient", esp_ot_process_tcp_client},
  28. #endif // CONFIG_OPENTHREAD_CLI_TCP_SOCKET
  29. #if CONFIG_OPENTHREAD_CLI_UDP_SOCKET
  30. {"udpsockserver", esp_ot_process_udp_server},
  31. {"udpsockclient", esp_ot_process_udp_client},
  32. {"mcast", esp_ot_process_mcast_group},
  33. #endif // CONFIG_OPENTHREAD_CLI_UDP_SOCKET
  34. #if CONFIG_OPENTHREAD_CLI_IPERF
  35. {"iperf", esp_ot_process_iperf},
  36. #endif // CONFIG_OPENTHREAD_CLI_IPERF
  37. #if CONFIG_OPENTHREAD_CLI_WIFI
  38. {"wifi", esp_ot_process_wifi_cmd},
  39. #endif // CONFIG_OPENTHREAD_CLI_WIFI
  40. };
  41. void esp_cli_custom_command_init()
  42. {
  43. otInstance *instance = esp_openthread_get_instance();
  44. otCliSetUserCommands(kCommands, (sizeof(kCommands) / sizeof(kCommands[0])), instance);
  45. }