Wi-Fi Service
Wi-Fi 服务 (Wi-Fi service) 提供了网络配置和网络管理的功能。配置网络支持 SmartConfig、BluFi 和 AirKiss。
应用示例
以下示例展示了该 API 的实现方式。
Header File
Functions
-
periph_service_handle_t wifi_service_create(wifi_service_config_t *config)
-
esp_err_t wifi_service_destroy(periph_service_handle_t handle)
-
esp_err_t wifi_service_register_setting_handle(periph_service_handle_t handle, esp_wifi_setting_handle_t setting, int *out_index)
-
esp_err_t wifi_service_setting_start(periph_service_handle_t handle, int index)
-
esp_err_t wifi_service_update_sta_info(periph_service_handle_t handle, wifi_config_t *wifi_conf)
-
esp_err_t wifi_service_setting_stop(periph_service_handle_t handle, int index)
-
esp_err_t wifi_service_connect(periph_service_handle_t handle)
-
esp_err_t wifi_service_disconnect(periph_service_handle_t handle)
-
esp_err_t wifi_service_set_sta_info(periph_service_handle_t handle, wifi_config_t *info)
-
periph_service_state_t wifi_service_state_get(periph_service_handle_t handle)
-
wifi_service_disconnect_reason_t wifi_service_disconnect_reason_get(periph_service_handle_t handle)
-
esp_err_t wifi_service_erase_ssid_manager_info(periph_service_handle_t handle)
-
esp_err_t wifi_service_get_last_ssid_cfg(periph_service_handle_t handle, wifi_config_t *wifi_cfg)
Structures
-
struct wifi_service_config_t
WiFi service configurations.
Public Members
-
int task_stack
>0 Service task stack; =0 with out task created
-
int task_prio
Service task priority (based on freeRTOS priority)
-
int task_core
Service task running in core (0 or 1)
-
bool extern_stack
Task stack allocate on the extern ram
-
periph_service_cb evt_cb
Service callback function
-
void *cb_ctx
Callback context
-
char *user_data
User data
-
int setting_timeout_s
Timeout of setting WiFi
-
int max_retry_time
Maximum times of reconnection
-
int max_prov_retry_time
Maximum times of reconnection after wifi provision
-
uint8_t max_ssid_num
Maximum ssid that can be stored
-
int task_stack
Macros
-
WIFI_SERVICE_DEFAULT_CONFIG()
Enumerations
-
enum wifi_service_event_t
WiFi STA service status.
Values:
-
enumerator WIFI_SERV_EVENT_UNKNOWN
-
enumerator WIFI_SERV_EVENT_CONNECTING
-
enumerator WIFI_SERV_EVENT_CONNECTED
-
enumerator WIFI_SERV_EVENT_DISCONNECTED
-
enumerator WIFI_SERV_EVENT_SETTING_TIMEOUT
-
enumerator WIFI_SERV_EVENT_SETTING_FAILED
-
enumerator WIFI_SERV_EVENT_SETTING_FINISHED
-
enumerator WIFI_SERV_EVENT_UNKNOWN
Header File
Functions
-
esp_wifi_setting_handle_t esp_wifi_setting_create(const char *tag)
brief Create wifi setting handle instance
- 参数
tag – Tag of the wifi setting handle
- 返回
NULL, Fail
Others, Success
-
esp_err_t esp_wifi_setting_destroy(esp_wifi_setting_handle_t handle)
brief Destroy wifi setting handle instance
- 参数
handle – The wifi setting handle instance
- 返回
ESP_OK
ESP_FAIL
-
esp_err_t esp_wifi_setting_register_function(esp_wifi_setting_handle_t handle, wifi_setting_func start, wifi_setting_func stop, wifi_setting_teardown_func teardown)
Register the wifi setting execute functions.
- 参数
handle – The wifi setting handle instance
start – The start wifi setting
stop – The stop
teardown – The destroy
- 返回
ESP_OK
ESP_FAIL
-
esp_err_t esp_wifi_setting_register_notify_handle(esp_wifi_setting_handle_t handle, void *on_handle)
Register the notify execute handle.
- 参数
handle – The peripheral handle
on_handle – The notify execute handle
- 返回
ESP_OK
ESP_FAIL
-
esp_err_t esp_wifi_setting_info_notify(esp_wifi_setting_handle_t handle, wifi_config_t *info)
Call this to notify the
wifi_config_t
toon_handle
- 参数
handle – The wifi setting handle instance
info – The
wifi_config_t
- 返回
ESP_OK
ESP_FAIL
-
esp_err_t esp_wifi_setting_set_data(esp_wifi_setting_handle_t handle, void *data)
Set the user data.
备注
Make sure the
data
lifetime is sufficient, this function does not copy all data, it only stores the data pointer- 参数
handle – [in] The wifi setting handle instance
data – The user data
- 返回
ESP_OK
ESP_FAIL
-
void *esp_wifi_setting_get_data(esp_wifi_setting_handle_t handle)
Get the user data stored on
handle
- 参数
handle – [in] The wifi setting handle instance
- 返回
user data pointer
-
esp_err_t esp_wifi_setting_start(esp_wifi_setting_handle_t handle)
Call this to execute
start
function of wifi setting instance.- 参数
handle – The wifi setting handle instance
- 返回
ESP_OK
ESP_FAIL
-
esp_err_t esp_wifi_setting_stop(esp_wifi_setting_handle_t handle)
Call this to execute
stop
function of wifi setting instance.- 参数
handle – The wifi setting handle instance
- 返回
ESP_OK
ESP_FAIL
-
esp_err_t esp_wifi_setting_teardown(esp_wifi_setting_handle_t handle, wifi_config_t *info)
Call this to execute
teardown
function of wifi setting instance.- 参数
handle – The wifi setting handle instance
info – The
wifi_config_t
- 返回
ESP_OK
ESP_FAIL
Type Definitions
-
typedef struct esp_wifi_setting *esp_wifi_setting_handle_t
-
typedef esp_err_t (*wifi_setting_func)(esp_wifi_setting_handle_t handle)
-
typedef esp_err_t (*wifi_setting_teardown_func)(esp_wifi_setting_handle_t handle, wifi_config_t *info)
Header File
Functions
-
esp_wifi_setting_handle_t smart_config_create(smart_config_info_t *info)
brief Create smartconfig setting handle instance
- 参数
info – Configuration of the smartconfig
- 返回
NULL, Fail
Others, Success
Structures
Macros
-
SMART_CONFIG_INFO_DEFAULT()
Header File
Functions
-
esp_wifi_setting_handle_t blufi_config_create(void *info)
Create blufi setting handle instance.
- 参数
info – [in] A pointer to void
- 返回
NULL, Fail
Others, Success
-
esp_err_t blufi_set_sta_connected_flag(esp_wifi_setting_handle_t handle, bool flag)
Set flag to judge whether the station has connected to the AP.
- 参数
handle – [in] Wifi setting handle
flag – [in] bool type of station connection state
- 返回
NULL, Fail
Others, Success
-
esp_err_t blufi_set_customized_data(esp_wifi_setting_handle_t handle, char *data, int data_len)
Set customized data to be sent after configurate wifi successfully.
- 参数
handle – [in] Wifi setting handle
data – [in] Customized data
data_len – [in] Customized data length
- 返回
ESP_FAIL, Fail
ESP_OK, Success
-
esp_err_t blufi_send_customized_data(esp_wifi_setting_handle_t handle)
Send customized data that be set before.
- 参数
handle – [in] Wifi setting handle
- 返回
ESP_FAIL, Fail
ESP_OK, Success
Header File
Functions
-
esp_wifi_setting_handle_t airkiss_config_create(airkiss_config_info_t *info)
brief Create airkiss setting handle instance
- 参数
info – Configuration of the airkiss
- 返回
NULL, Fail
Others, Success
Structures
-
struct airkiss_lan_pack_param_t
airkiss lan data pack
-
struct airkiss_config_info_t
airkiss configurations
Public Members
-
airkiss_lan_pack_param_t lan_pack
User lan pack parameter
-
bool ssdp_notify_enable
Notify enable flag
-
char *aes_key
Airkiss aes key data
-
airkiss_lan_pack_param_t lan_pack
Macros
-
AIRKISS_CONFIG_INFO_DEFAULT()
Header File
Functions
-
wifi_ssid_manager_handle_t wifi_ssid_manager_create(uint8_t max_ssid_num)
-
esp_err_t wifi_ssid_manager_get_latest_config(wifi_ssid_manager_handle_t handle, wifi_config_t *config)
-
esp_err_t wifi_ssid_manager_save(wifi_ssid_manager_handle_t handle, const char *ssid, const char *pwd)
-
esp_err_t wifi_ssid_manager_get_best_config(wifi_ssid_manager_handle_t handle, wifi_config_t *config)
-
int wifi_ssid_manager_get_ssid_num(wifi_ssid_manager_handle_t handle)
-
esp_err_t wifi_ssid_manager_list_show(wifi_ssid_manager_handle_t handle)
-
esp_err_t wifi_ssid_manager_erase_all(wifi_ssid_manager_handle_t handle)
-
esp_err_t wifi_ssid_manager_destroy(wifi_ssid_manager_handle_t handle)
Type Definitions
-
typedef struct wifi_ssid_manager *wifi_ssid_manager_handle_t