protocol_examples_common.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. #ifdef CONFIG_EXAMPLE_CONNECT_ETHERNET
  14. #define EXAMPLE_INTERFACE TCPIP_ADAPTER_IF_ETH
  15. #endif
  16. #ifdef CONFIG_EXAMPLE_CONNECT_WIFI
  17. #define EXAMPLE_INTERFACE TCPIP_ADAPTER_IF_STA
  18. #endif
  19. /**
  20. * @brief Configure Wi-Fi or Ethernet, connect, wait for IP
  21. *
  22. * This all-in-one helper function is used in protocols examples to
  23. * reduce the amount of boilerplate in the example.
  24. *
  25. * It is not intended to be used in real world applications.
  26. * See examples under examples/wifi/getting_started/ and examples/ethernet/
  27. * for more complete Wi-Fi or Ethernet initialization code.
  28. *
  29. * Read "Establishing Wi-Fi or Ethernet Connection" section in
  30. * examples/protocols/README.md for more information about this function.
  31. *
  32. * @return ESP_OK on successful connection
  33. */
  34. esp_err_t example_connect();
  35. /**
  36. * Counterpart to example_connect, de-initializes Wi-Fi or Ethernet
  37. */
  38. esp_err_t example_disconnect();
  39. /**
  40. * @brief Configure stdin and stdout to use blocking I/O
  41. *
  42. * This helper function is used in ASIO examples. It wraps installing the
  43. * UART driver and configuring VFS layer to use UART driver for console I/O.
  44. */
  45. esp_err_t example_configure_stdin_stdout();
  46. #ifdef __cplusplus
  47. }
  48. #endif