ESP8266_RTOS_SDK v1.4.0

- Main Page
- Modules
- Data Structures
- Files

- File List

esp_sta.h
1 /*
2 * ESPRSSIF MIT License
3 *
4 * Copyright (c) 2015 <ESPRESSIF SYSTEMS (SHANGHAI) PTE LTD>
5 *
6 * Permission is hereby granted for use on ESPRESSIF SYSTEMS ESP8266 only, in which case,
7 * it is free of charge, to any person obtaining a copy of this software and associated
8 * documentation files (the "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the Software is furnished
11 * to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all copies or
14 * substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 *
23 */
24
25 #ifndef __ESP_STA_H__
26 #define __ESP_STA_H__
27
28 #include "queue.h"
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33
52 struct station_config {
53 uint8 ssid[32];
54 uint8 password[64];
55 uint8 bssid_set;
56 uint8 bssid[6];
57 };
58
67 bool wifi_station_get_config(struct station_config *config);
68
77 bool wifi_station_get_config_default(struct station_config *config);
78
96 bool wifi_station_set_config(struct station_config *config);
97
116 bool wifi_station_set_config_current(struct station_config *config);
117
130 bool wifi_station_connect(void);
131
143 bool wifi_station_disconnect(void);
144
145 struct scan_config {
146 uint8 *ssid;
147 uint8 *bssid;
148 uint8 channel;
149 uint8 show_hidden;
150 };
151
152 struct bss_info {
153 STAILQ_ENTRY(bss_info) next;
155 uint8 bssid[6];
156 uint8 ssid[32];
157 uint8 ssid_len;
158 uint8 channel;
159 sint8 rssi;
160 AUTH_MODE authmode;
161 uint8 is_hidden;
162 sint16 freq_offset;
163 sint16 freqcal_val;
164 uint8 *esp_mesh_ie;
165 };
166
176 typedef void (* scan_done_cb_t)(void *arg, STATUS status);
177
190 bool wifi_station_scan(struct scan_config *config, scan_done_cb_t cb);
191
201 bool wifi_station_get_auto_connect(void);
202
219 bool wifi_station_set_auto_connect(bool set);
220
229 bool wifi_station_get_reconnect_policy(void);
230
243 bool wifi_station_set_reconnect_policy(bool set);
244
245 typedef enum {
246 STATION_IDLE = 0,
247 STATION_CONNECTING,
248 STATION_WRONG_PASSWORD,
249 STATION_NO_AP_FOUND,
250 STATION_CONNECT_FAIL,
251 STATION_GOT_IP
252 } STATION_STATUS;
253
261 STATION_STATUS wifi_station_get_connect_status(void);
262
270 uint8 wifi_station_get_current_ap_id(void);
271
280 bool wifi_station_ap_change(uint8 current_ap_id);
281
294 bool wifi_station_ap_number_set(uint8 ap_number);
295
309 uint8 wifi_station_get_ap_info(struct station_config config[]);
310
319 sint8 wifi_station_get_rssi(void);
320
335 bool wifi_station_dhcpc_start(void);
336
351 bool wifi_station_dhcpc_stop(void);
352
360 enum dhcp_status wifi_station_dhcpc_status(void);
361
370 bool wifi_station_set_hostname(char *name);
371
379 char* wifi_station_get_hostname(void);
380
389 #ifdef __cplusplus
390 }
391 #endif
392
393 #endif
wifi_station_get_auto_connect
bool wifi_station_get_auto_connect(void)
Check if the ESP8266 station will connect to the recorded AP automatically when the power is on...
scan_config::channel
uint8 channel
Definition: esp_sta.h:148
wifi_station_get_ap_info
uint8 wifi_station_get_ap_info(struct station_config config[])
Get the information of APs (5 at most) recorded by ESP8266 station.
wifi_station_connect
bool wifi_station_connect(void)
Connect the ESP8266 WiFi station to the AP.
AUTH_MODE
AUTH_MODE
Definition: esp_wifi.h:59
scan_config::show_hidden
uint8 show_hidden
Definition: esp_sta.h:149
wifi_station_get_config_default
bool wifi_station_get_config_default(struct station_config *config)
Get the configuration parameters saved in the Flash of the ESP8266 WiFi station.
bss_info::authmode
AUTH_MODE authmode
Definition: esp_sta.h:160
wifi_station_set_auto_connect
bool wifi_station_set_auto_connect(bool set)
Set whether the ESP8266 station will connect to the recorded AP automatically when the power is on...
station_config
Definition: esp_sta.h:52
wifi_station_dhcpc_start
bool wifi_station_dhcpc_start(void)
Enable the ESP8266 station DHCP client.
bss_info::channel
uint8 channel
Definition: esp_sta.h:158
wifi_station_set_config_current
bool wifi_station_set_config_current(struct station_config *config)
Set the configuration of the ESP8266 station. And the configuration will not be saved to the Flash...
scan_config
Definition: esp_sta.h:145
station_config::ssid
uint8 ssid[32]
Definition: esp_sta.h:53
STATION_CONNECT_FAIL
Definition: esp_sta.h:250
scan_config::bssid
uint8 * bssid
Definition: esp_sta.h:147
wifi_station_set_reconnect_policy
bool wifi_station_set_reconnect_policy(bool set)
Set whether the ESP8266 station will reconnect to the AP after disconnection. It will do so by defaul...
station_config::bssid
uint8 bssid[6]
Definition: esp_sta.h:56
wifi_station_scan
bool wifi_station_scan(struct scan_config *config, scan_done_cb_t cb)
Scan all available APs.
wifi_station_get_connect_status
STATION_STATUS wifi_station_get_connect_status(void)
Get the connection status of the ESP8266 WiFi station.
bss_info::rssi
sint8 rssi
Definition: esp_sta.h:159
STATION_WRONG_PASSWORD
Definition: esp_sta.h:248
bss_info::ssid_len
uint8 ssid_len
Definition: esp_sta.h:157
scan_config::ssid
uint8 * ssid
Definition: esp_sta.h:146
wifi_station_get_current_ap_id
uint8 wifi_station_get_current_ap_id(void)
Get the information of APs (5 at most) recorded by ESP8266 station.
scan_done_cb_t
void(* scan_done_cb_t)(void *arg, STATUS status)
Callback function for wifi_station_scan.
Definition: esp_sta.h:176
STATION_NO_AP_FOUND
Definition: esp_sta.h:249
wifi_station_get_config
bool wifi_station_get_config(struct station_config *config)
Get the current configuration of the ESP8266 WiFi station.
wifi_station_get_reconnect_policy
bool wifi_station_get_reconnect_policy(void)
Check whether the ESP8266 station will reconnect to the AP after disconnection.
STATION_IDLE
Definition: esp_sta.h:246
bss_info::is_hidden
uint8 is_hidden
Definition: esp_sta.h:161
wifi_station_get_hostname
char * wifi_station_get_hostname(void)
Get ESP8266 station DHCP hostname.
dhcp_status
dhcp_status
Definition: esp_misc.h:83
bss_info::STAILQ_ENTRY
STAILQ_ENTRY(bss_info) next
bss_info::bssid
uint8 bssid[6]
Definition: esp_sta.h:155
wifi_station_ap_number_set
bool wifi_station_ap_number_set(uint8 ap_number)
Set the number of APs that can be recorded in the ESP8266 station. When the ESP8266 station is connec...
bss_info::freq_offset
sint16 freq_offset
Definition: esp_sta.h:162
STATION_CONNECTING
Definition: esp_sta.h:247
wifi_station_set_config
bool wifi_station_set_config(struct station_config *config)
Set the configuration of the ESP8266 station and save it to the Flash.
station_config::password
uint8 password[64]
Definition: esp_sta.h:54
STATION_STATUS
STATION_STATUS
Definition: esp_sta.h:245
wifi_station_dhcpc_status
enum dhcp_status wifi_station_dhcpc_status(void)
Get the ESP8266 station DHCP client status.
STATION_GOT_IP
Definition: esp_sta.h:251
wifi_station_disconnect
bool wifi_station_disconnect(void)
Disconnect the ESP8266 WiFi station from the AP.
wifi_station_set_hostname
bool wifi_station_set_hostname(char *name)
Set ESP8266 station DHCP hostname.
bss_info::ssid
uint8 ssid[32]
Definition: esp_sta.h:156
wifi_station_get_rssi
sint8 wifi_station_get_rssi(void)
Get rssi of the AP which ESP8266 station connected to.
wifi_station_dhcpc_stop
bool wifi_station_dhcpc_stop(void)
Disable the ESP8266 station DHCP client.
station_config::bssid_set
uint8 bssid_set
Definition: esp_sta.h:55
wifi_station_ap_change
bool wifi_station_ap_change(uint8 current_ap_id)
Switch the ESP8266 station connection to a recorded AP.
bss_info
Definition: esp_sta.h:152