protocol_examples_common.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* Common functions for protocol examples, to establish Wi-Fi or Ethernet connection.
  2. This example code is in the Public Domain (or CC0 licensed, at your option.)
  3. Unless required by applicable law or agreed to in writing, this
  4. software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
  5. CONDITIONS OF ANY KIND, either express or implied.
  6. */
  7. #pragma once
  8. #ifdef __cplusplus
  9. extern "C" {
  10. #endif
  11. #include "esp_err.h"
  12. #include "tcpip_adapter.h"
  13. // IDF-V4++ #include "esp_netif.h"
  14. #ifdef CONFIG_EXAMPLE_CONNECT_ETHERNET
  15. #define EXAMPLE_INTERFACE TCPIP_ADAPTER_IF_ETH
  16. #endif
  17. #ifdef CONFIG_EXAMPLE_CONNECT_WIFI
  18. #define EXAMPLE_INTERFACE TCPIP_ADAPTER_IF_STA
  19. #endif
  20. /**
  21. * @brief Configure Wi-Fi or Ethernet, connect, wait for IP
  22. *
  23. * This all-in-one helper function is used in protocols examples to
  24. * reduce the amount of boilerplate in the example.
  25. *
  26. * It is not intended to be used in real world applications.
  27. * See examples under examples/wifi/getting_started/ and examples/ethernet/
  28. * for more complete Wi-Fi or Ethernet initialization code.
  29. *
  30. * Read "Establishing Wi-Fi or Ethernet Connection" section in
  31. * examples/protocols/README.md for more information about this function.
  32. *
  33. * @return ESP_OK on successful connection
  34. */
  35. esp_err_t example_connect();
  36. /**
  37. * Counterpart to example_connect, de-initializes Wi-Fi or Ethernet
  38. */
  39. esp_err_t example_disconnect();
  40. /**
  41. * @brief Configure stdin and stdout to use blocking I/O
  42. *
  43. * This helper function is used in ASIO examples. It wraps installing the
  44. * UART driver and configuring VFS layer to use UART driver for console I/O.
  45. */
  46. esp_err_t example_configure_stdin_stdout();
  47. #ifdef __cplusplus
  48. }
  49. #endif