header: format and fix typos

SYSTEM_EVENT_STA_GOTIP to SYSTEM_EVENT_STA_GOT_IP
This commit is contained in:
Wu Jian Gang
2016-09-12 16:43:32 +08:00
parent ded5df7513
commit c5f8396df4
4 changed files with 105 additions and 106 deletions

164
components/esp32/include/esp_wifi.h Executable file → Normal file
View File

@@ -15,13 +15,13 @@
/* Notes about WiFi Programming
*
* The esp32 wifi programming model can be dipcts as following picture:
* The esp32 WiFi programming model can be depicted as following picture:
*
*
* default handler user handler
* ------------- --------------- ---------------
* | | event | | callback or | |
* | tcpip | ---------> | event | ----------> | application |
* ------------- --------------- ---------------
* | | event | | callback or | |
* | tcpip | ---------> | event | ----------> | application |
* | stack | | task | event | task |
* |-----------| |-------------| |-------------|
* /|\ |
@@ -35,23 +35,23 @@
* | |\ API call
* | |
* |-------------|
*
* The wifi driver can be consider as black box, it knows nothing about the high layer code, such as
* TCPIP stack, application task, event task etc, all it can do is to receive API call from high laeyer
* or post event queue to a specified Queue, which is initilized by API esp_wifi_init().
*
* The WiFi driver can be consider as black box, it knows nothing about the high layer code, such as
* TCPIP stack, application task, event task etc, all it can do is to receive API call from high layer
* or post event queue to a specified Queue, which is initialized by API esp_wifi_init().
*
* The event task is a daemon task, which receives events from WiFi driver or from other subsystem, such
* as TCPIP stack, event task will call the default callback function on receiving the event. For example,
* on receiving event SYSTEM_EVENT_STA_CONNECTED, it will call tcpip_adapter_start() to start the DHCP
* client in it's default handler.
* client in it's default handler.
*
* Application can register it's owner event callback function by API esp_event_init, then the application callback
* function will be called after the default callback. Also, if application don't want to excute the callback
* in event task, what it need to do is to post the related event to application task in the application callback function.
*
* The application task (code) generally mix all these thing together, it call APIs to init the system/wifi and
* Application can register it's own event callback function by API esp_event_init, then the application callback
* function will be called after the default callback. Also, if application doesn't want to execute the callback
* in the event task, what it needs to do is to post the related event to application task in the application callback function.
*
* The application task (code) generally mixes all these thing together, it calls APIs to init the system/WiFi and
* handle the events when necessary.
*
*
*/
#ifndef __ESP_WIFI_H__
@@ -85,7 +85,7 @@ typedef enum {
WIFI_COUNTRY_CN = 0, /**< country China, channel range [1, 14] */
WIFI_COUNTRY_JP, /**< country Japan, channel range [1, 14] */
WIFI_COUNTRY_US, /**< country USA, channel range [1, 11] */
WIFI_COUNTRY_EU, /**< country Europe, channel rane [1, 13] */
WIFI_COUNTRY_EU, /**< country Europe, channel range [1, 13] */
WIFI_COUNTRY_MAX
} wifi_country_t;
@@ -137,12 +137,12 @@ typedef enum {
} wifi_second_chan_t;
/**
* @brief startup wifi driver and register application specific callback function
* @brief startup WiFi driver and register application specific callback function
*
* @attention 1. This API should be called in application startup code to init wifi driver
* @attention 2. The callback fuction is used to provide application specific wifi configuration,
* such as, set the wifi mode, register the event callback, set ap ssid etc before
* wifi is startup
* @attention 1. This API should be called in application startup code to init WiFi driver
* @attention 2. The callback function is used to provide application specific WiFi configuration,
* such as, set the WiFi mode, register the event callback, set AP SSID etc before
* WiFi is startup
* @attention 3. Avoid to create application task in the callback, otherwise you may get wrong behavior
* @attention 4. If the callback return is not ESP_OK, the startup will fail!
* @attention 5. Before this API can be called, system_init()/esp_event_init()/tcpip_adapter_init() should
@@ -157,7 +157,7 @@ typedef esp_err_t (* wifi_startup_cb_t)(void);
void esp_wifi_startup(wifi_startup_cb_t cb);
typedef struct {
void *event_q; /**< Wifi event q handler, it's a freertos queue */
void *event_q; /**< WiFi event q handler, it's a freeRTOS queue */
uint8_t rx_ba_win; /**< TBC */
uint8_t tx_ba_win; /**< TBC */
uint8_t rx_buf_cnt; /**< TBC */
@@ -165,29 +165,29 @@ typedef struct {
} wifi_init_config_t;
/**
* @brief Init wifi
* Alloc resource for wifi driver, such as wifi control structure, rx/tx buffer,
* wifi nvs structure etc, this wifi also start wifi task
* @brief Init WiFi
* Alloc resource for WiFi driver, such as WiFi control structure, RX/TX buffer,
* WiFi NVS structure etc, this WiFi also start WiFi task
*
* @attention 1. This API must be called before all other wifi api can be called
* @attention 2. Generally we should init event_q in *config, wifi driver will post the event
* to this queue when event happens, such as, when sta connects to api, wifi driver
* will post sta connected event to this queue. If the queue is not initialized, wifi
* @attention 1. This API must be called before all other WiFi API can be called
* @attention 2. Generally we should init event_q in *config, WiFi driver will post the event
* to this queue when event happens, such as, when station connects to WiFi, WiFi driver
* will post station connected event to this queue. If the queue is not initialized, WiFi
* will not post any events
* @attention 3. For other paramters, currently it's not ready, just ignore it.
* @attention 3. For other parameters, currently it's not ready, just ignore it.
*
* @param wifi_init_config_t *config : provide WiFi init configuration
*
* @param wifi_init_config_t *config : provide wifi init configuration
*
* @return ESP_OK : succeed
* @return others : fail
*/
esp_err_t esp_wifi_init(wifi_init_config_t *config);
/**
* @brief Deinit wifi
* Free all resource allocated in esp_wifi_init and stop wifi task
* @brief Deinit WiFi
* Free all resource allocated in esp_wifi_init and stop WiFi task
*
* @attention 1. This API should be called if you want to remove wifi driver from the system
* @attention 1. This API should be called if you want to remove WiFi driver from the system
*
* @return ESP_OK : succeed
* @return others : fail
@@ -210,7 +210,7 @@ esp_err_t esp_wifi_set_mode(wifi_mode_t mode);
/**
* @brief Get current operating mode of WiFi
*
* @param wifi_mode_t *mode : store current wifi mode
* @param wifi_mode_t *mode : store current WiFi mode
*
* @return ESP_OK : succeed
* @return others : fail
@@ -218,10 +218,10 @@ esp_err_t esp_wifi_set_mode(wifi_mode_t mode);
esp_err_t esp_wifi_get_mode(wifi_mode_t *mode);
/**
* @brief Start wifi according to current configuration
* If mode is WIFI_MODE_STA, it create sta control block and start sta
* If mode is WIFI_MODE_AP, it create ap control block and start ap
* If mode is WIFI_MODE_APSTA, it create apd and sta control block and start ap and sta
* @brief Start WiFi according to current configuration
* If mode is WIFI_MODE_STA, it create station control block and start station
* If mode is WIFI_MODE_AP, it create soft-AP control block and start soft-AP
* If mode is WIFI_MODE_APSTA, it create soft-AP and station control block and start soft-AP and station
*
* @param null
*
@@ -231,10 +231,10 @@ esp_err_t esp_wifi_get_mode(wifi_mode_t *mode);
esp_err_t esp_wifi_start(void);
/**
* @brief Stop wifi
If mode is WIFI_MODE_STA, it stop sta and free sta control block
* If mode is WIFI_MODE_AP, it stop ap and free ap control block
* If mode is WIFI_MODE_APSTA, it stop sta/ap and free sta/ap control block
* @brief Stop WiFi
If mode is WIFI_MODE_STA, it stop station and free station control block
* If mode is WIFI_MODE_AP, it stop soft-AP and free soft-AP control block
* If mode is WIFI_MODE_APSTA, it stop station/soft-AP and free station/soft-AP control block
*
* @param null
*
@@ -244,7 +244,7 @@ esp_err_t esp_wifi_start(void);
esp_err_t esp_wifi_stop(void);
/**
* @brief Connect the ESP32 WiFi sta to the AP.
* @brief Connect the ESP32 WiFi station to the AP.
*
* @attention 1. This API only impact WIFI_MODE_STA or WIFI_MODE_APSTA mode
* @attention 2. If the ESP32 is connected to an AP, call esp_wifi_disconnect to disconnect.
@@ -257,7 +257,7 @@ esp_err_t esp_wifi_stop(void);
esp_err_t esp_wifi_connect(void);
/**
* @brief Disconnect the ESP32 WiFi sta from the AP.
* @brief Disconnect the ESP32 WiFi station from the AP.
*
* @param null
*
@@ -277,9 +277,9 @@ esp_err_t esp_wifi_disconnect(void);
esp_err_t esp_wifi_clear_fast_connect(void);
/**
* @brief Kick the all sta or associated id equals to aid
* @brief Kick the all station or associated id equals to aid
*
* @param uint16_t aid : when aid is 0, kick all sta, otherwise kick sta whose associated id is aid
* @param uint16_t aid : when aid is 0, kick all stations, otherwise kick station whose associated id is aid
*
* @return ESP_OK : succeed
* @return others : fail
@@ -296,13 +296,13 @@ typedef struct {
/**
* @brief Scan all available APs.
*
* @attention If this API is called, the found APs are stored in wifi driver dynamic allocated memory and the
* @attention If this API is called, the found APs are stored in WiFi driver dynamic allocated memory and the
* will be freed in esp_wifi_get_ap_list, so generally, call esp_wifi_get_ap_list to cause
* the memory to be freed once the scan is done
*
* @param struct scan_config *config : configuration of scanning
* @param bool block : if block is true, this api will block the caller until the scan is done, otherwise
* it will return immeidately
* @param bool block : if block is true, this API will block the caller until the scan is done, otherwise
* it will return immediately
*
* @return ESP_OK : succeed
* @return others : fail
@@ -335,9 +335,9 @@ typedef struct {
uint8_t ssid[32]; /**< SSID of AP */
uint8_t primary; /**< channel of AP */
wifi_second_chan_t second; /**< second channel of AP */
signed char rssi; /**< signal strength of AP */
int8_t rssi; /**< signal strength of AP */
wifi_auth_mode_t authmode; /**< authmode of AP */
}wifi_ap_list_t;
} wifi_ap_list_t;
/**
* @brief Get AP list found in last scan
@@ -359,7 +359,7 @@ typedef enum {
} wifi_ps_type_t;
/**
* @brief Set current power save type
* @brief Set current power save type
*
* @param wifi_ps_type_t type : power save type
*
@@ -387,9 +387,9 @@ esp_err_t esp_wifi_get_ps(wifi_ps_type_t *type);
* The default protocol is (WIFI_PROTOCOL_11B|WIFI_PROTOCOL_11G|WIFI_PROTOCOL_11N)
*
* @attention Currently we only support 802.11b or 802.11bg or 802.11bgn mode
*
* @param wifi_interface_t ifx : interfaces
* @param uint8_t protocol : wifi protocol bitmap
*
* @param wifi_interface_t ifx : interfaces
* @param uint8_t protocol : WiFi protocol bitmap
*
* @return ESP_OK : succeed
* @return others : fail
@@ -399,8 +399,8 @@ esp_err_t esp_wifi_set_protocol(wifi_interface_t ifx, uint8_t protocol_bitmap);
/**
* @brief Get the current protocol bitmap of specified ifx
*
* @param wifi_interface_t ifx : interfaces
* @param uint8_t protocol : store current wifi protocol bitmap of interface ifx
* @param wifi_interface_t ifx : interfaces
* @param uint8_t protocol : store current WiFi protocol bitmap of interface ifx
*
* @return ESP_OK : succeed
* @return others : fail
@@ -494,7 +494,7 @@ esp_err_t esp_wifi_get_country(wifi_country_t *country);
* - The bit0 of the first byte of ESP32 MAC address can not be 1. For example, the MAC address
* can set to be "1a:XX:XX:XX:XX:XX", but can not be "15:XX:XX:XX:XX:XX".
*
* @param wifi_interface_t ifx : interface
* @param wifi_interface_t ifx : interface
* @param uint8 mac[6]: the MAC address.
*
* @return true : succeed
@@ -517,8 +517,8 @@ esp_err_t esp_wifi_get_mac(wifi_interface_t ifx, uint8_t mac[6]);
*
* Each time a packet is received, the callback function will be called.
*
* @param uint8 *buf : the data received
* @param uint16 len : data length
* @param void *buf : the data received
* @param uint16_t len : data length
*
* @return ESP_OK : succeed
* @return others : fail
@@ -540,7 +540,7 @@ esp_err_t esp_wifi_set_promiscuous_rx_cb(wifi_promiscuous_cb_t cb);
/**
* @brief Enable the promiscuous mode.
*
* @param uint8 promiscuous : 0 - disable / 1 - enable
* @param uint8 promiscuous : 0 - disable / 1 - enable
*
* @return ESP_OK : succeed
* @return others : fail
@@ -565,7 +565,7 @@ typedef struct {
wifi_auth_mode_t authmode; /**< Auth mode of ESP32 soft-AP. Do not support AUTH_WEP in soft-AP mode */
uint8_t ssid_hidden; /**< Broadcast SSID or not, default 0, broadcast the SSID */
uint8_t max_connection; /**< Max number of stations allowed to connect in, default 4, max 4 */
uint16_t beacon_interval; /**< Beacon interval, 100 ~ 60000 ms, default 100 */
uint16_t beacon_interval; /**< Beacon interval, 100 ~ 60000 ms, default 100 ms */
} wifi_ap_config_t;
typedef struct {
@@ -583,13 +583,13 @@ typedef union {
/**
* @brief Set the configuration of the ESP32 STA or AP
*
* @attention 1. This api can be called only when specified interface is enabled, otherwise, API fail
* @attention 2. For sta configuration, bssid_set needs to be 0; and it needs to be 1 only when users need to check the MAC address of the AP.
* @attention 1. This API can be called only when specified interface is enabled, otherwise, API fail
* @attention 2. For station configuration, bssid_set needs to be 0; and it needs to be 1 only when users need to check the MAC address of the AP.
* @attention 3. ESP32 is limited to only one channel, so when in the soft-AP+station mode, the soft-AP will adjust its channel automatically to be the same as
* the channel of the ESP32 station.
*
* @param wifi_interface_t ifx : interface
* @param wifi_config_t *conf : sta or ap configuration
* @param wifi_interface_t ifx : interface
* @param wifi_config_t *conf : station or soft-AP configuration
*
* @return ESP_OK : succeed
* @return others : fail
@@ -599,8 +599,8 @@ esp_err_t esp_wifi_set_config(wifi_interface_t ifx, wifi_config_t *conf);
/**
* @brief Get configuration of specified interface
*
* @param wifi_interface_t ifx : interface
* @param wifi_config_t *conf : sta or ap configuration
* @param wifi_interface_t ifx : interface
* @param wifi_config_t *conf : station or soft-AP configuration
*
* @return ESP_OK : succeed
* @return others : fail
@@ -613,11 +613,11 @@ struct station_info {
};
/**
* @brief Get STAs associated with soft-AP
* @brief Get STAs associated with soft-AP
*
* @attention SSC only API
*
* @param struct station_info **station : sta list
* @param struct station_info **station : station list
*
* @return ESP_OK : succeed
* @return others : fail
@@ -632,7 +632,7 @@ typedef enum {
} wifi_storage_t;
/**
* @brief Set the wifi API configuration storage type
* @brief Set the WiFi API configuration storage type
*
* @attention 1. The default value is WIFI_STORAGE_FLASH
*
@@ -644,20 +644,20 @@ typedef enum {
esp_err_t esp_wifi_set_storage(wifi_storage_t storage);
/**
* @brief Set the wifi API configuration storage type
* @brief The WiFi RX callback function
*
* Each time the wifi need to forward the packets to high layer, the callback function will be called
* Each time the WiFi need to forward the packets to high layer, the callback function will be called
*
*/
typedef esp_err_t (*wifi_rxcb_t)(void *buffer, uint16_t len, void* eb);
typedef esp_err_t (*wifi_rxcb_t)(void *buffer, uint16_t len, void *eb);
/**
* @brief Set the wifi rx callback
* @brief Set the WiFi RX callback
*
* @attention 1. Currently we support only one rx callback for each interface
* @attention 1. Currently we support only one RX callback for each interface
*
* @param wifi_interface_t ifx : interface
* @param wifi_rxcb_t fn : wifi rx callback
* @param wifi_interface_t ifx : interface
* @param wifi_rxcb_t fn : WiFi RX callback
*
* @return ESP_OK : succeed
* @return others : fail
@@ -665,10 +665,10 @@ typedef esp_err_t (*wifi_rxcb_t)(void *buffer, uint16_t len, void* eb);
esp_err_t esp_wifi_reg_rxcb(wifi_interface_t ifx, wifi_rxcb_t fn);
/**
* @brief Set auto connect
* @brief Set auto connect
* The default value is true
*
* @attention 1.
* @attention 1.
*
* @param bool en : true - enable auto connect / false - disable auto connect
*