ESP8266_RTOS_SDK  v1.4.0
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 
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 
78 
96 bool wifi_station_set_config(struct station_config *config);
97 
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;
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 
202 
219 bool wifi_station_set_auto_connect(bool set);
220 
230 
243 bool wifi_station_set_reconnect_policy(bool set);
244 
245 typedef enum {
253 
262 
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 
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
bool wifi_station_get_auto_connect(void)
Check if the ESP8266 station will connect to the recorded AP automatically when the power is on...
uint8 channel
Definition: esp_sta.h:148
uint8 wifi_station_get_ap_info(struct station_config config[])
Get the information of APs (5 at most) recorded by ESP8266 station.
bool wifi_station_connect(void)
Connect the ESP8266 WiFi station to the AP.
AUTH_MODE
Definition: esp_wifi.h:59
uint8 show_hidden
Definition: esp_sta.h:149
bool wifi_station_get_config_default(struct station_config *config)
Get the configuration parameters saved in the Flash of the ESP8266 WiFi station.
AUTH_MODE authmode
Definition: esp_sta.h:160
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...
Definition: esp_sta.h:52
bool wifi_station_dhcpc_start(void)
Enable the ESP8266 station DHCP client.
uint8 channel
Definition: esp_sta.h:158
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...
Definition: esp_sta.h:145
uint8 ssid[32]
Definition: esp_sta.h:53
Definition: esp_sta.h:250
uint8 * bssid
Definition: esp_sta.h:147
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...
uint8 bssid[6]
Definition: esp_sta.h:56
bool wifi_station_scan(struct scan_config *config, scan_done_cb_t cb)
Scan all available APs.
STATION_STATUS wifi_station_get_connect_status(void)
Get the connection status of the ESP8266 WiFi station.
sint8 rssi
Definition: esp_sta.h:159
Definition: esp_sta.h:248
uint8 ssid_len
Definition: esp_sta.h:157
uint8 * ssid
Definition: esp_sta.h:146
uint8 wifi_station_get_current_ap_id(void)
Get the information of APs (5 at most) recorded by ESP8266 station.
void(* scan_done_cb_t)(void *arg, STATUS status)
Callback function for wifi_station_scan.
Definition: esp_sta.h:176
Definition: esp_sta.h:249
bool wifi_station_get_config(struct station_config *config)
Get the current configuration of the ESP8266 WiFi station.
bool wifi_station_get_reconnect_policy(void)
Check whether the ESP8266 station will reconnect to the AP after disconnection.
Definition: esp_sta.h:246
uint8 is_hidden
Definition: esp_sta.h:161
char * wifi_station_get_hostname(void)
Get ESP8266 station DHCP hostname.
dhcp_status
Definition: esp_misc.h:83
STAILQ_ENTRY(bss_info) next
uint8 bssid[6]
Definition: esp_sta.h:155
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...
sint16 freq_offset
Definition: esp_sta.h:162
Definition: esp_sta.h:247
bool wifi_station_set_config(struct station_config *config)
Set the configuration of the ESP8266 station and save it to the Flash.
uint8 password[64]
Definition: esp_sta.h:54
STATION_STATUS
Definition: esp_sta.h:245
enum dhcp_status wifi_station_dhcpc_status(void)
Get the ESP8266 station DHCP client status.
Definition: esp_sta.h:251
bool wifi_station_disconnect(void)
Disconnect the ESP8266 WiFi station from the AP.
bool wifi_station_set_hostname(char *name)
Set ESP8266 station DHCP hostname.
uint8 ssid[32]
Definition: esp_sta.h:156
sint8 wifi_station_get_rssi(void)
Get rssi of the AP which ESP8266 station connected to.
bool wifi_station_dhcpc_stop(void)
Disable the ESP8266 station DHCP client.
uint8 bssid_set
Definition: esp_sta.h:55
bool wifi_station_ap_change(uint8 current_ap_id)
Switch the ESP8266 station connection to a recorded AP.
Definition: esp_sta.h:152