header: format and fix typos
SYSTEM_EVENT_STA_GOTIP to SYSTEM_EVENT_STA_GOT_IP
This commit is contained in:
parent
ded5df7513
commit
c5f8396df4
4 changed files with 105 additions and 106 deletions
|
@ -65,7 +65,7 @@ static system_event_handle_t g_system_event_handle_table[] = {
|
||||||
{SYSTEM_EVENT_STA_CONNECTED, system_event_sta_connected_handle_default},
|
{SYSTEM_EVENT_STA_CONNECTED, system_event_sta_connected_handle_default},
|
||||||
{SYSTEM_EVENT_STA_DISCONNECTED, system_event_sta_disconnected_handle_default},
|
{SYSTEM_EVENT_STA_DISCONNECTED, system_event_sta_disconnected_handle_default},
|
||||||
{SYSTEM_EVENT_STA_AUTHMODE_CHANGE, NULL},
|
{SYSTEM_EVENT_STA_AUTHMODE_CHANGE, NULL},
|
||||||
{SYSTEM_EVENT_STA_GOTIP, system_event_sta_gotip_default},
|
{SYSTEM_EVENT_STA_GOT_IP, system_event_sta_gotip_default},
|
||||||
{SYSTEM_EVENT_AP_START, system_event_ap_start_handle_default},
|
{SYSTEM_EVENT_AP_START, system_event_ap_start_handle_default},
|
||||||
{SYSTEM_EVENT_AP_STOP, system_event_ap_stop_handle_default},
|
{SYSTEM_EVENT_AP_STOP, system_event_ap_stop_handle_default},
|
||||||
{SYSTEM_EVENT_AP_STACONNECTED, NULL},
|
{SYSTEM_EVENT_AP_STACONNECTED, NULL},
|
||||||
|
@ -150,7 +150,7 @@ esp_err_t system_event_sta_connected_handle_default(system_event_t *event)
|
||||||
system_event_t evt;
|
system_event_t evt;
|
||||||
|
|
||||||
//notify event
|
//notify event
|
||||||
evt.event_id = SYSTEM_EVENT_STA_GOTIP;
|
evt.event_id = SYSTEM_EVENT_STA_GOT_IP;
|
||||||
memcpy(&evt.event_info.got_ip.ip_info, &sta_ip, sizeof(tcpip_adapter_ip_info_t));
|
memcpy(&evt.event_info.got_ip.ip_info, &sta_ip, sizeof(tcpip_adapter_ip_info_t));
|
||||||
|
|
||||||
esp_event_send(&evt);
|
esp_event_send(&evt);
|
||||||
|
@ -234,7 +234,7 @@ static esp_err_t esp_system_event_debug(system_event_t *event)
|
||||||
WIFI_DEBUG("SYSTEM_EVENT_STA_AUTHMODE_CHNAGE\nold_mode:%d, new_mode:%d\n", auth_change->old_mode, auth_change->new_mode);
|
WIFI_DEBUG("SYSTEM_EVENT_STA_AUTHMODE_CHNAGE\nold_mode:%d, new_mode:%d\n", auth_change->old_mode, auth_change->new_mode);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SYSTEM_EVENT_STA_GOTIP:
|
case SYSTEM_EVENT_STA_GOT_IP:
|
||||||
{
|
{
|
||||||
system_event_sta_got_ip_t *got_ip;
|
system_event_sta_got_ip_t *got_ip;
|
||||||
got_ip = &event->event_info.got_ip;
|
got_ip = &event->event_info.got_ip;
|
||||||
|
|
39
components/esp32/include/esp_event.h
Executable file → Normal file
39
components/esp32/include/esp_event.h
Executable file → Normal file
|
@ -28,24 +28,24 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
SYSTEM_EVENT_WIFI_READY = 0, /**< ESP32 wifi ready */
|
SYSTEM_EVENT_WIFI_READY = 0, /**< ESP32 WiFi ready */
|
||||||
SYSTEM_EVENT_SCAN_DONE, /**< ESP32 finish scanning AP */
|
SYSTEM_EVENT_SCAN_DONE, /**< ESP32 finish scanning AP */
|
||||||
SYSTEM_EVENT_STA_START, /**< ESP32 station start */
|
SYSTEM_EVENT_STA_START, /**< ESP32 station start */
|
||||||
SYSTEM_EVENT_STA_STOP, /**< ESP32 station start */
|
SYSTEM_EVENT_STA_STOP, /**< ESP32 station stop */
|
||||||
SYSTEM_EVENT_STA_CONNECTED, /**< ESP32 station connected to AP */
|
SYSTEM_EVENT_STA_CONNECTED, /**< ESP32 station connected to AP */
|
||||||
SYSTEM_EVENT_STA_DISCONNECTED, /**< ESP32 station disconnected to AP */
|
SYSTEM_EVENT_STA_DISCONNECTED, /**< ESP32 station disconnected from AP */
|
||||||
SYSTEM_EVENT_STA_AUTHMODE_CHANGE, /**< the auth mode of AP connected by ESP32 station changed */
|
SYSTEM_EVENT_STA_AUTHMODE_CHANGE, /**< the auth mode of AP connected by ESP32 station changed */
|
||||||
SYSTEM_EVENT_STA_GOTIP, /**< ESP32 station received IP address */
|
SYSTEM_EVENT_STA_GOT_IP, /**< ESP32 station got IP from connected AP */
|
||||||
SYSTEM_EVENT_AP_START, /**< ESP32 softap start */
|
SYSTEM_EVENT_AP_START, /**< ESP32 soft-AP start */
|
||||||
SYSTEM_EVENT_AP_STOP, /**< ESP32 softap start */
|
SYSTEM_EVENT_AP_STOP, /**< ESP32 soft-AP stop */
|
||||||
SYSTEM_EVENT_AP_STACONNECTED, /**< a station connected to ESP32 soft-AP */
|
SYSTEM_EVENT_AP_STACONNECTED, /**< a station connected to ESP32 soft-AP */
|
||||||
SYSTEM_EVENT_AP_STADISCONNECTED, /**< a station disconnected to ESP32 soft-AP */
|
SYSTEM_EVENT_AP_STADISCONNECTED, /**< a station disconnected from ESP32 soft-AP */
|
||||||
SYSTEM_EVENT_AP_PROBEREQRECVED, /**< Receive probe request packet in soft-AP interface */
|
SYSTEM_EVENT_AP_PROBEREQRECVED, /**< Receive probe request packet in soft-AP interface */
|
||||||
SYSTEM_EVENT_MAX
|
SYSTEM_EVENT_MAX
|
||||||
} system_event_id_t;
|
} system_event_id_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint32_t status; /**< status of scanning APs*/
|
uint32_t status; /**< status of scanning APs */
|
||||||
uint8_t number;
|
uint8_t number;
|
||||||
uint8_t scan_id;
|
uint8_t scan_id;
|
||||||
} system_event_sta_scan_done_t;
|
} system_event_sta_scan_done_t;
|
||||||
|
@ -94,10 +94,10 @@ typedef union {
|
||||||
system_event_sta_disconnected_t disconnected; /**< ESP32 station disconnected to AP */
|
system_event_sta_disconnected_t disconnected; /**< ESP32 station disconnected to AP */
|
||||||
system_event_sta_scan_done_t scan_done; /**< ESP32 station scan (APs) done */
|
system_event_sta_scan_done_t scan_done; /**< ESP32 station scan (APs) done */
|
||||||
system_event_sta_authmode_change_t auth_change; /**< the auth mode of AP ESP32 station connected to changed */
|
system_event_sta_authmode_change_t auth_change; /**< the auth mode of AP ESP32 station connected to changed */
|
||||||
system_event_sta_got_ip_t got_ip;
|
system_event_sta_got_ip_t got_ip; /**< ESP32 station got IP */
|
||||||
system_event_ap_staconnected_t sta_connected; /**< a station connected to ESP32 soft-AP */
|
system_event_ap_staconnected_t sta_connected; /**< a station connected to ESP32 soft-AP */
|
||||||
system_event_ap_stadisconnected_t sta_disconnected; /**< a station disconnected to ESP32 soft-AP */
|
system_event_ap_stadisconnected_t sta_disconnected; /**< a station disconnected to ESP32 soft-AP */
|
||||||
system_event_ap_probe_req_rx_t ap_probereqrecved; /**< ESP32 softAP receive probe request packet */
|
system_event_ap_probe_req_rx_t ap_probereqrecved; /**< ESP32 soft-AP receive probe request packet */
|
||||||
} system_event_info_t;
|
} system_event_info_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -118,8 +118,8 @@ typedef esp_err_t (*system_event_cb_t)(system_event_t *event);
|
||||||
/**
|
/**
|
||||||
* @brief Set application specified event callback function
|
* @brief Set application specified event callback function
|
||||||
*
|
*
|
||||||
* @attention 1. If cb is NULL, means application don't need to handle
|
* @attention 1. If cb is NULL, means application don't need to handle
|
||||||
* If cb is not NULL, it will be call when a event is received, after the default event callback is completed
|
* If cb is not NULL, it will be call when an event is received, after the default event callback is completed
|
||||||
*
|
*
|
||||||
* @param system_event_cb_t cb : callback
|
* @param system_event_cb_t cb : callback
|
||||||
*
|
*
|
||||||
|
@ -131,28 +131,27 @@ system_event_cb_t esp_event_set_cb(system_event_cb_t cb);
|
||||||
/**
|
/**
|
||||||
* @brief Send a event to event task
|
* @brief Send a event to event task
|
||||||
*
|
*
|
||||||
* @attention 1. Other task/module, such as TCPIP modudle, can call this API to send a event to event task
|
* @attention 1. Other task/modules, such as the TCPIP module, can call this API to send an event to event task
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @param system_event_t * event : event
|
* @param system_event_t * event : event
|
||||||
*
|
*
|
||||||
* @return ESP_OK : succeed
|
* @return ESP_OK : succeed
|
||||||
* @return others : fail
|
* @return others : fail
|
||||||
*/
|
*/
|
||||||
esp_err_t esp_event_send(system_event_t * event);
|
esp_err_t esp_event_send(system_event_t *event);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get the event handler
|
* @brief Get the event handler
|
||||||
*
|
*
|
||||||
* @attention : currently this API returns event queue handler, generally this handler is used to
|
* @attention : currently this API returns event queue handler, generally this handler is used to
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @param null
|
* @param null
|
||||||
*
|
*
|
||||||
* @return void* : event queue pointer
|
* @return void* : event queue pointer
|
||||||
*/
|
*/
|
||||||
void* esp_event_get_handler(void);
|
void *esp_event_get_handler(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Init the event module
|
* @brief Init the event module
|
||||||
|
|
164
components/esp32/include/esp_wifi.h
Executable file → Normal file
164
components/esp32/include/esp_wifi.h
Executable file → Normal file
|
@ -15,13 +15,13 @@
|
||||||
|
|
||||||
/* Notes about WiFi Programming
|
/* 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
|
* default handler user handler
|
||||||
* ------------- --------------- ---------------
|
* ------------- --------------- ---------------
|
||||||
* | | event | | callback or | |
|
* | | event | | callback or | |
|
||||||
* | tcpip | ---------> | event | ----------> | application |
|
* | tcpip | ---------> | event | ----------> | application |
|
||||||
* | stack | | task | event | task |
|
* | stack | | task | event | task |
|
||||||
* |-----------| |-------------| |-------------|
|
* |-----------| |-------------| |-------------|
|
||||||
* /|\ |
|
* /|\ |
|
||||||
|
@ -35,23 +35,23 @@
|
||||||
* | |\ API call
|
* | |\ API call
|
||||||
* | |
|
* | |
|
||||||
* |-------------|
|
* |-------------|
|
||||||
*
|
*
|
||||||
* The wifi driver can be consider as black box, it knows nothing about the high layer code, such as
|
* 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
|
* 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 initilized by API esp_wifi_init().
|
* 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
|
* 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,
|
* 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
|
* 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
|
* 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 don't want to excute the callback
|
* function will be called after the default callback. Also, if application doesn't want to execute the callback
|
||||||
* in event task, what it need to do is to post the related event to application task in the application callback function.
|
* 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 mix all these thing together, it call APIs to init the system/wifi and
|
* The application task (code) generally mixes all these thing together, it calls APIs to init the system/WiFi and
|
||||||
* handle the events when necessary.
|
* handle the events when necessary.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __ESP_WIFI_H__
|
#ifndef __ESP_WIFI_H__
|
||||||
|
@ -85,7 +85,7 @@ typedef enum {
|
||||||
WIFI_COUNTRY_CN = 0, /**< country China, channel range [1, 14] */
|
WIFI_COUNTRY_CN = 0, /**< country China, channel range [1, 14] */
|
||||||
WIFI_COUNTRY_JP, /**< country Japan, channel range [1, 14] */
|
WIFI_COUNTRY_JP, /**< country Japan, channel range [1, 14] */
|
||||||
WIFI_COUNTRY_US, /**< country USA, channel range [1, 11] */
|
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_MAX
|
||||||
} wifi_country_t;
|
} wifi_country_t;
|
||||||
|
|
||||||
|
@ -137,12 +137,12 @@ typedef enum {
|
||||||
} wifi_second_chan_t;
|
} 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 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,
|
* @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
|
* such as, set the WiFi mode, register the event callback, set AP SSID etc before
|
||||||
* wifi is startup
|
* WiFi is startup
|
||||||
* @attention 3. Avoid to create application task in the callback, otherwise you may get wrong behavior
|
* @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 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
|
* @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);
|
void esp_wifi_startup(wifi_startup_cb_t cb);
|
||||||
|
|
||||||
typedef struct {
|
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 rx_ba_win; /**< TBC */
|
||||||
uint8_t tx_ba_win; /**< TBC */
|
uint8_t tx_ba_win; /**< TBC */
|
||||||
uint8_t rx_buf_cnt; /**< TBC */
|
uint8_t rx_buf_cnt; /**< TBC */
|
||||||
|
@ -165,29 +165,29 @@ typedef struct {
|
||||||
} wifi_init_config_t;
|
} wifi_init_config_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Init wifi
|
* @brief Init WiFi
|
||||||
* Alloc resource for wifi driver, such as wifi control structure, rx/tx buffer,
|
* Alloc resource for WiFi driver, such as WiFi control structure, RX/TX buffer,
|
||||||
* wifi nvs structure etc, this wifi also start wifi task
|
* 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 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
|
* @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
|
* to this queue when event happens, such as, when station connects to WiFi, WiFi driver
|
||||||
* will post sta connected event to this queue. If the queue is not initialized, wifi
|
* will post station connected event to this queue. If the queue is not initialized, WiFi
|
||||||
* will not post any events
|
* 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 ESP_OK : succeed
|
||||||
* @return others : fail
|
* @return others : fail
|
||||||
*/
|
*/
|
||||||
esp_err_t esp_wifi_init(wifi_init_config_t *config);
|
esp_err_t esp_wifi_init(wifi_init_config_t *config);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Deinit wifi
|
* @brief Deinit WiFi
|
||||||
* Free all resource allocated in esp_wifi_init and stop wifi task
|
* 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 ESP_OK : succeed
|
||||||
* @return others : fail
|
* @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
|
* @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 ESP_OK : succeed
|
||||||
* @return others : fail
|
* @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);
|
esp_err_t esp_wifi_get_mode(wifi_mode_t *mode);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Start wifi according to current configuration
|
* @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_STA, it create station control block and start station
|
||||||
* If mode is WIFI_MODE_AP, it create ap control block and start ap
|
* If mode is WIFI_MODE_AP, it create soft-AP control block and start soft-AP
|
||||||
* If mode is WIFI_MODE_APSTA, it create apd and sta control block and start ap and sta
|
* If mode is WIFI_MODE_APSTA, it create soft-AP and station control block and start soft-AP and station
|
||||||
*
|
*
|
||||||
* @param null
|
* @param null
|
||||||
*
|
*
|
||||||
|
@ -231,10 +231,10 @@ esp_err_t esp_wifi_get_mode(wifi_mode_t *mode);
|
||||||
esp_err_t esp_wifi_start(void);
|
esp_err_t esp_wifi_start(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Stop wifi
|
* @brief Stop WiFi
|
||||||
If mode is WIFI_MODE_STA, it stop sta and free sta control block
|
If mode is WIFI_MODE_STA, it stop station and free station control block
|
||||||
* If mode is WIFI_MODE_AP, it stop ap and free ap 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 sta/ap and free sta/ap control block
|
* If mode is WIFI_MODE_APSTA, it stop station/soft-AP and free station/soft-AP control block
|
||||||
*
|
*
|
||||||
* @param null
|
* @param null
|
||||||
*
|
*
|
||||||
|
@ -244,7 +244,7 @@ esp_err_t esp_wifi_start(void);
|
||||||
esp_err_t esp_wifi_stop(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 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.
|
* @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);
|
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
|
* @param null
|
||||||
*
|
*
|
||||||
|
@ -277,9 +277,9 @@ esp_err_t esp_wifi_disconnect(void);
|
||||||
esp_err_t esp_wifi_clear_fast_connect(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 ESP_OK : succeed
|
||||||
* @return others : fail
|
* @return others : fail
|
||||||
|
@ -296,13 +296,13 @@ typedef struct {
|
||||||
/**
|
/**
|
||||||
* @brief Scan all available APs.
|
* @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
|
* 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
|
* the memory to be freed once the scan is done
|
||||||
*
|
*
|
||||||
* @param struct scan_config *config : configuration of scanning
|
* @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
|
* @param bool block : if block is true, this API will block the caller until the scan is done, otherwise
|
||||||
* it will return immeidately
|
* it will return immediately
|
||||||
*
|
*
|
||||||
* @return ESP_OK : succeed
|
* @return ESP_OK : succeed
|
||||||
* @return others : fail
|
* @return others : fail
|
||||||
|
@ -335,9 +335,9 @@ typedef struct {
|
||||||
uint8_t ssid[32]; /**< SSID of AP */
|
uint8_t ssid[32]; /**< SSID of AP */
|
||||||
uint8_t primary; /**< channel of AP */
|
uint8_t primary; /**< channel of AP */
|
||||||
wifi_second_chan_t second; /**< second 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_auth_mode_t authmode; /**< authmode of AP */
|
||||||
}wifi_ap_list_t;
|
} wifi_ap_list_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get AP list found in last scan
|
* @brief Get AP list found in last scan
|
||||||
|
@ -359,7 +359,7 @@ typedef enum {
|
||||||
} wifi_ps_type_t;
|
} 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
|
* @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)
|
* 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
|
* @attention Currently we only support 802.11b or 802.11bg or 802.11bgn mode
|
||||||
*
|
*
|
||||||
* @param wifi_interface_t ifx : interfaces
|
* @param wifi_interface_t ifx : interfaces
|
||||||
* @param uint8_t protocol : wifi protocol bitmap
|
* @param uint8_t protocol : WiFi protocol bitmap
|
||||||
*
|
*
|
||||||
* @return ESP_OK : succeed
|
* @return ESP_OK : succeed
|
||||||
* @return others : fail
|
* @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
|
* @brief Get the current protocol bitmap of specified ifx
|
||||||
*
|
*
|
||||||
* @param wifi_interface_t ifx : interfaces
|
* @param wifi_interface_t ifx : interfaces
|
||||||
* @param uint8_t protocol : store current wifi protocol bitmap of interface ifx
|
* @param uint8_t protocol : store current WiFi protocol bitmap of interface ifx
|
||||||
*
|
*
|
||||||
* @return ESP_OK : succeed
|
* @return ESP_OK : succeed
|
||||||
* @return others : fail
|
* @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
|
* - 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".
|
* 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.
|
* @param uint8 mac[6]: the MAC address.
|
||||||
*
|
*
|
||||||
* @return true : succeed
|
* @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.
|
* Each time a packet is received, the callback function will be called.
|
||||||
*
|
*
|
||||||
* @param uint8 *buf : the data received
|
* @param void *buf : the data received
|
||||||
* @param uint16 len : data length
|
* @param uint16_t len : data length
|
||||||
*
|
*
|
||||||
* @return ESP_OK : succeed
|
* @return ESP_OK : succeed
|
||||||
* @return others : fail
|
* @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.
|
* @brief Enable the promiscuous mode.
|
||||||
*
|
*
|
||||||
* @param uint8 promiscuous : 0 - disable / 1 - enable
|
* @param uint8 promiscuous : 0 - disable / 1 - enable
|
||||||
*
|
*
|
||||||
* @return ESP_OK : succeed
|
* @return ESP_OK : succeed
|
||||||
* @return others : fail
|
* @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 */
|
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 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 */
|
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;
|
} wifi_ap_config_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -583,13 +583,13 @@ typedef union {
|
||||||
/**
|
/**
|
||||||
* @brief Set the configuration of the ESP32 STA or AP
|
* @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 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 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
|
* @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.
|
* the channel of the ESP32 station.
|
||||||
*
|
*
|
||||||
* @param wifi_interface_t ifx : interface
|
* @param wifi_interface_t ifx : interface
|
||||||
* @param wifi_config_t *conf : sta or ap configuration
|
* @param wifi_config_t *conf : station or soft-AP configuration
|
||||||
*
|
*
|
||||||
* @return ESP_OK : succeed
|
* @return ESP_OK : succeed
|
||||||
* @return others : fail
|
* @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
|
* @brief Get configuration of specified interface
|
||||||
*
|
*
|
||||||
* @param wifi_interface_t ifx : interface
|
* @param wifi_interface_t ifx : interface
|
||||||
* @param wifi_config_t *conf : sta or ap configuration
|
* @param wifi_config_t *conf : station or soft-AP configuration
|
||||||
*
|
*
|
||||||
* @return ESP_OK : succeed
|
* @return ESP_OK : succeed
|
||||||
* @return others : fail
|
* @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
|
* @attention SSC only API
|
||||||
*
|
*
|
||||||
* @param struct station_info **station : sta list
|
* @param struct station_info **station : station list
|
||||||
*
|
*
|
||||||
* @return ESP_OK : succeed
|
* @return ESP_OK : succeed
|
||||||
* @return others : fail
|
* @return others : fail
|
||||||
|
@ -632,7 +632,7 @@ typedef enum {
|
||||||
} wifi_storage_t;
|
} 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
|
* @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);
|
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_interface_t ifx : interface
|
||||||
* @param wifi_rxcb_t fn : wifi rx callback
|
* @param wifi_rxcb_t fn : WiFi RX callback
|
||||||
*
|
*
|
||||||
* @return ESP_OK : succeed
|
* @return ESP_OK : succeed
|
||||||
* @return others : fail
|
* @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);
|
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
|
* The default value is true
|
||||||
*
|
*
|
||||||
* @attention 1.
|
* @attention 1.
|
||||||
*
|
*
|
||||||
* @param bool en : true - enable auto connect / false - disable auto connect
|
* @param bool en : true - enable auto connect / false - disable auto connect
|
||||||
*
|
*
|
||||||
|
|
|
@ -454,7 +454,7 @@ static void tcpip_adapter_dhcpc_cb(void)
|
||||||
ip4_addr_set(&ip_info->gw, ip_2_ip4(&netif->gw));
|
ip4_addr_set(&ip_info->gw, ip_2_ip4(&netif->gw));
|
||||||
|
|
||||||
//notify event
|
//notify event
|
||||||
evt.event_id = SYSTEM_EVENT_STA_GOTIP;
|
evt.event_id = SYSTEM_EVENT_STA_GOT_IP;
|
||||||
memcpy(&evt.event_info.got_ip.ip_info, ip_info, sizeof(tcpip_adapter_ip_info_t));
|
memcpy(&evt.event_info.got_ip.ip_info, ip_info, sizeof(tcpip_adapter_ip_info_t));
|
||||||
|
|
||||||
esp_event_send(&evt);
|
esp_event_send(&evt);
|
||||||
|
|
Loading…
Reference in a new issue