Select one of the symbols to view example projects that use it.
 
Outline
#include "sdkconfig.h"
#include "esp_err.h"
#include "esp_netif.h"
#include "esp_eth.h"
#define EXAMPLE_NETIF_DESC_STA
#define EXAMPLE_NETIF_DESC_ETH
#define EXAMPLE_NETIF_DESC_THREAD
#define EXAMPLE_NETIF_DESC_PPP
#define EXAMPLE_WIFI_SCAN_METHOD
#define EXAMPLE_WIFI_SCAN_METHOD
#define EXAMPLE_WIFI_CONNECT_AP_SORT_METHOD
#define EXAMPLE_WIFI_CONNECT_AP_SORT_METHOD
#define EXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLD
#define EXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLD
#define EXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLD
#define EXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLD
#define EXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLD
#define EXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLD
#define EXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLD
#define EXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLD
#define EXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLD
#define EXAMPLE_INTERFACE
#define get_example_netif
#define EXAMPLE_INTERFACE
#define get_example_netif
#define EXAMPLE_INTERFACE
#define get_example_netif
#define EXAMPLE_INTERFACE
#define get_example_netif
example_connect();
example_disconnect();
example_configure_stdin_stdout();
get_example_netif_from_desc(const char *);
example_register_wifi_connect_commands();
Files
loading...
SourceVuESP-IDF Framework and ExamplesESP-IDFexamples/common_components/protocol_examples_common/include/protocol_examples_common.h
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/* 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. *//* ... */ #pragma once #include "sdkconfig.h" #include "esp_err.h" #if !CONFIG_IDF_TARGET_LINUX #include "esp_netif.h" #if CONFIG_EXAMPLE_CONNECT_ETHERNET #include "esp_eth.h" #endif/* ... */ #endif // !CONFIG_IDF_TARGET_LINUX #ifdef __cplusplus extern "C" { #endif #if !CONFIG_IDF_TARGET_LINUX #if CONFIG_EXAMPLE_CONNECT_WIFI #define EXAMPLE_NETIF_DESC_STA "example_netif_sta" #endif #if CONFIG_EXAMPLE_CONNECT_ETHERNET #define EXAMPLE_NETIF_DESC_ETH "example_netif_eth" #endif #if CONFIG_EXAMPLE_CONNECT_THREAD #define EXAMPLE_NETIF_DESC_THREAD "example_netif_thread" #endif #if CONFIG_EXAMPLE_CONNECT_PPP #define EXAMPLE_NETIF_DESC_PPP "example_netif_ppp" #endif #if CONFIG_EXAMPLE_WIFI_SCAN_METHOD_FAST #define EXAMPLE_WIFI_SCAN_METHOD WIFI_FAST_SCAN #elif CONFIG_EXAMPLE_WIFI_SCAN_METHOD_ALL_CHANNEL #define EXAMPLE_WIFI_SCAN_METHOD WIFI_ALL_CHANNEL_SCAN #endif #if CONFIG_EXAMPLE_WIFI_CONNECT_AP_BY_SIGNAL #define EXAMPLE_WIFI_CONNECT_AP_SORT_METHOD WIFI_CONNECT_AP_BY_SIGNAL #elif CONFIG_EXAMPLE_WIFI_CONNECT_AP_BY_SECURITY #define EXAMPLE_WIFI_CONNECT_AP_SORT_METHOD WIFI_CONNECT_AP_BY_SECURITY #endif #if CONFIG_EXAMPLE_WIFI_AUTH_OPEN #define EXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_OPEN #elif CONFIG_EXAMPLE_WIFI_AUTH_WEP #define EXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WEP #elif CONFIG_EXAMPLE_WIFI_AUTH_WPA_PSK #define EXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA_PSK #elif CONFIG_EXAMPLE_WIFI_AUTH_WPA2_PSK #define EXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA2_PSK #elif CONFIG_EXAMPLE_WIFI_AUTH_WPA_WPA2_PSK #define EXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA_WPA2_PSK #elif CONFIG_EXAMPLE_WIFI_AUTH_WPA2_ENTERPRISE #define EXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA2_ENTERPRISE #elif CONFIG_EXAMPLE_WIFI_AUTH_WPA3_PSK #define EXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA3_PSK #elif CONFIG_EXAMPLE_WIFI_AUTH_WPA2_WPA3_PSK #define EXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA2_WPA3_PSK #elif CONFIG_EXAMPLE_WIFI_AUTH_WAPI_PSK #define EXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WAPI_PSK #endif /* Example default interface, prefer the ethernet one if running in example-test (CI) configuration */ #if CONFIG_EXAMPLE_CONNECT_ETHERNET #define EXAMPLE_INTERFACE get_example_netif_from_desc(EXAMPLE_NETIF_DESC_ETH) #define get_example_netif() get_example_netif_from_desc(EXAMPLE_NETIF_DESC_ETH)/* ... */ #elif CONFIG_EXAMPLE_CONNECT_WIFI #define EXAMPLE_INTERFACE get_example_netif_from_desc(EXAMPLE_NETIF_DESC_STA) #define get_example_netif() get_example_netif_from_desc(EXAMPLE_NETIF_DESC_STA)/* ... */ #elif CONFIG_EXAMPLE_CONNECT_THREAD #define EXAMPLE_INTERFACE get_example_netif_from_desc(EXAMPLE_NETIF_DESC_THREAD) #define get_example_netif() get_example_netif_from_desc(EXAMPLE_NETIF_DESC_THREAD)/* ... */ #elif CONFIG_EXAMPLE_CONNECT_PPP #define EXAMPLE_INTERFACE get_example_netif_from_desc(EXAMPLE_NETIF_DESC_PPP) #define get_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_t example_connect(void); /** * Counterpart to example_connect, de-initializes Wi-Fi or Ethernet *//* ... */ esp_err_t example_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_t example_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(const char *desc); #if CONFIG_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. *//* ... */ void example_register_wifi_connect_commands(void);/* ... */ #endif #if CONFIG_EXAMPLE_CONNECT_ETHERNET /** * @brief Get the example Ethernet driver handle * * @return esp_eth_handle_t *//* ... */ esp_eth_handle_t get_example_eth_handle(void);/* ... */ #endif // CONFIG_EXAMPLE_CONNECT_ETHERNET /* ... */ #else static inline esp_err_t example_connect(void) {return ESP_OK;} #endif // !CONFIG_IDF_TARGET_LINUX #ifdef __cplusplus }{...} #endif
Details