/* Common functions for protocol examples, to establish Wi-Fi or Ethernet connection. This example code is in the Public Domain (or CC0 licensed, at your option.) Unless required by applicable law or agreed to in writing, this software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *//* ... */#pragmaonce#include"sdkconfig.h"#include"esp_err.h"#if!CONFIG_IDF_TARGET_LINUX#include"esp_netif.h"#ifCONFIG_EXAMPLE_CONNECT_ETHERNET#include"esp_eth.h"#endif/* ... */#endif// !CONFIG_IDF_TARGET_LINUX#ifdef__cplusplusextern"C"{#endif#if!CONFIG_IDF_TARGET_LINUX#ifCONFIG_EXAMPLE_CONNECT_WIFI#defineEXAMPLE_NETIF_DESC_STA"example_netif_sta"#endif#ifCONFIG_EXAMPLE_CONNECT_ETHERNET#defineEXAMPLE_NETIF_DESC_ETH"example_netif_eth"#endif#ifCONFIG_EXAMPLE_CONNECT_THREAD#defineEXAMPLE_NETIF_DESC_THREAD"example_netif_thread"#endif#ifCONFIG_EXAMPLE_CONNECT_PPP#defineEXAMPLE_NETIF_DESC_PPP"example_netif_ppp"#endif#ifCONFIG_EXAMPLE_WIFI_SCAN_METHOD_FAST#defineEXAMPLE_WIFI_SCAN_METHODWIFI_FAST_SCAN#elifCONFIG_EXAMPLE_WIFI_SCAN_METHOD_ALL_CHANNEL#defineEXAMPLE_WIFI_SCAN_METHODWIFI_ALL_CHANNEL_SCAN#endif#ifCONFIG_EXAMPLE_WIFI_CONNECT_AP_BY_SIGNAL#defineEXAMPLE_WIFI_CONNECT_AP_SORT_METHODWIFI_CONNECT_AP_BY_SIGNAL#elifCONFIG_EXAMPLE_WIFI_CONNECT_AP_BY_SECURITY#defineEXAMPLE_WIFI_CONNECT_AP_SORT_METHODWIFI_CONNECT_AP_BY_SECURITY#endif#ifCONFIG_EXAMPLE_WIFI_AUTH_OPEN#defineEXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLDWIFI_AUTH_OPEN#elifCONFIG_EXAMPLE_WIFI_AUTH_WEP#defineEXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLDWIFI_AUTH_WEP#elifCONFIG_EXAMPLE_WIFI_AUTH_WPA_PSK#defineEXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLDWIFI_AUTH_WPA_PSK#elifCONFIG_EXAMPLE_WIFI_AUTH_WPA2_PSK#defineEXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLDWIFI_AUTH_WPA2_PSK#elifCONFIG_EXAMPLE_WIFI_AUTH_WPA_WPA2_PSK#defineEXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLDWIFI_AUTH_WPA_WPA2_PSK#elifCONFIG_EXAMPLE_WIFI_AUTH_WPA2_ENTERPRISE#defineEXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLDWIFI_AUTH_WPA2_ENTERPRISE#elifCONFIG_EXAMPLE_WIFI_AUTH_WPA3_PSK#defineEXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLDWIFI_AUTH_WPA3_PSK#elifCONFIG_EXAMPLE_WIFI_AUTH_WPA2_WPA3_PSK#defineEXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLDWIFI_AUTH_WPA2_WPA3_PSK#elifCONFIG_EXAMPLE_WIFI_AUTH_WAPI_PSK#defineEXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLDWIFI_AUTH_WAPI_PSK#endif/* Example default interface, prefer the ethernet one if running in example-test (CI) configuration */#ifCONFIG_EXAMPLE_CONNECT_ETHERNET#defineEXAMPLE_INTERFACEget_example_netif_from_desc(EXAMPLE_NETIF_DESC_ETH)#defineget_example_netif()get_example_netif_from_desc(EXAMPLE_NETIF_DESC_ETH)/* ... */#elifCONFIG_EXAMPLE_CONNECT_WIFI#defineEXAMPLE_INTERFACEget_example_netif_from_desc(EXAMPLE_NETIF_DESC_STA)#defineget_example_netif()get_example_netif_from_desc(EXAMPLE_NETIF_DESC_STA)/* ... */#elifCONFIG_EXAMPLE_CONNECT_THREAD#defineEXAMPLE_INTERFACEget_example_netif_from_desc(EXAMPLE_NETIF_DESC_THREAD)#defineget_example_netif()get_example_netif_from_desc(EXAMPLE_NETIF_DESC_THREAD)/* ... */#elifCONFIG_EXAMPLE_CONNECT_PPP#defineEXAMPLE_INTERFACEget_example_netif_from_desc(EXAMPLE_NETIF_DESC_PPP)#defineget_example_netif()get_example_netif_from_desc(EXAMPLE_NETIF_DESC_PPP)/* ... */#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_texample_connect(void);/** * Counterpart to example_connect, de-initializes Wi-Fi or Ethernet *//* ... */esp_err_texample_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_texample_configure_stdin_stdout(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(constchar*desc);#ifCONFIG_EXAMPLE_PROVIDE_WIFI_CONSOLE_CMD/** * @brief Register wifi connect commands * * Provide a simple wifi_connect command in esp_console. * This function can be used after esp_console is initialized. *//* ... */voidexample_register_wifi_connect_commands(void);/* ... */#endif#ifCONFIG_EXAMPLE_CONNECT_ETHERNET/** * @brief Get the example Ethernet driver handle * * @return esp_eth_handle_t *//* ... */esp_eth_handle_tget_example_eth_handle(void);/* ... */#endif// CONFIG_EXAMPLE_CONNECT_ETHERNET/* ... */#elsestaticinlineesp_err_texample_connect(void){returnESP_OK;}#endif// !CONFIG_IDF_TARGET_LINUX#ifdef__cplusplus}{...}#endif
Details
Show: from
Types: Columns:
All items filtered out
All items filtered out
This file uses the notable symbols shown below. Click anywhere in the file to view more details.