mirror of
https://github.com/espressif/esp-idf
synced 2025-03-09 17:19:09 -04:00
fix(wifi): Fix default wifi-netif creation to assert if no event loop
- Added ESP_ERROR_CHECK() checks to `esp_wifi_set_default_wifi_..._handlers()` calls - Added ESP_ERROR_CHECH() to `esp_netif_attach_wifi_...()` calls - Updated documentation to reflect the changes Closes https://github.com/espressif/esp-idf/issues/11580
This commit is contained in:
parent
16aef4bbee
commit
fdbb885964
@ -335,6 +335,7 @@ TEST_CASE("esp_netif: create and destroy default wifi interfaces", "[esp_netif][
|
||||
// Helper constants to refer default STA and AP's params
|
||||
static const esp_netif_inherent_config_t default_sta_cfg = ESP_NETIF_INHERENT_DEFAULT_WIFI_STA();
|
||||
static const esp_netif_inherent_config_t default_ap_cfg = ESP_NETIF_INHERENT_DEFAULT_WIFI_AP();
|
||||
TEST_ESP_OK(esp_event_loop_create_default());
|
||||
|
||||
// create default station
|
||||
esp_netif_t *sta = esp_netif_create_default_wifi_sta();
|
||||
@ -362,6 +363,7 @@ TEST_CASE("esp_netif: create and destroy default wifi interfaces", "[esp_netif][
|
||||
sta = esp_netif_create_default_wifi_sta();
|
||||
TEST_ASSERT_NOT_NULL(sta);
|
||||
esp_netif_destroy_default_wifi(sta);
|
||||
TEST_ESP_OK(esp_event_loop_delete_default());
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2019-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -65,7 +65,9 @@ esp_err_t esp_wifi_clear_default_wifi_driver_and_handlers(void *esp_netif);
|
||||
* @brief Creates default WIFI AP. In case of any init error this API aborts.
|
||||
*
|
||||
* @note The API creates esp_netif object with default WiFi access point config,
|
||||
* attaches the netif to wifi and registers default wifi handlers.
|
||||
* attaches the netif to wifi and registers wifi handlers to the default event loop.
|
||||
* This API uses assert() to check for potential errors, so it could abort the program.
|
||||
* (Note that the default event loop needs to be created prior to calling this API)
|
||||
*
|
||||
* @return pointer to esp-netif instance
|
||||
*/
|
||||
@ -75,7 +77,9 @@ esp_netif_t* esp_netif_create_default_wifi_ap(void);
|
||||
* @brief Creates default WIFI STA. In case of any init error this API aborts.
|
||||
*
|
||||
* @note The API creates esp_netif object with default WiFi station config,
|
||||
* attaches the netif to wifi and registers default wifi handlers.
|
||||
* attaches the netif to wifi and registers wifi handlers to the default event loop.
|
||||
* This API uses assert() to check for potential errors, so it could abort the program.
|
||||
* (Note that the default event loop needs to be created prior to calling this API)
|
||||
*
|
||||
* @return pointer to esp-netif instance
|
||||
*/
|
||||
|
@ -318,8 +318,8 @@ esp_netif_t* esp_netif_create_default_wifi_ap(void)
|
||||
esp_netif_config_t cfg = ESP_NETIF_DEFAULT_WIFI_AP();
|
||||
esp_netif_t *netif = esp_netif_new(&cfg);
|
||||
assert(netif);
|
||||
esp_netif_attach_wifi_ap(netif);
|
||||
esp_wifi_set_default_wifi_ap_handlers();
|
||||
ESP_ERROR_CHECK(esp_netif_attach_wifi_ap(netif));
|
||||
ESP_ERROR_CHECK(esp_wifi_set_default_wifi_ap_handlers());
|
||||
return netif;
|
||||
}
|
||||
#endif
|
||||
@ -332,8 +332,8 @@ esp_netif_t* esp_netif_create_default_wifi_sta(void)
|
||||
esp_netif_config_t cfg = ESP_NETIF_DEFAULT_WIFI_STA();
|
||||
esp_netif_t *netif = esp_netif_new(&cfg);
|
||||
assert(netif);
|
||||
esp_netif_attach_wifi_station(netif);
|
||||
esp_wifi_set_default_wifi_sta_handlers();
|
||||
ESP_ERROR_CHECK(esp_netif_attach_wifi_station(netif));
|
||||
ESP_ERROR_CHECK(esp_wifi_set_default_wifi_sta_handlers());
|
||||
return netif;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user