mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'bugfix/netif_default_sta_init_v5.1' into 'release/v5.1'
wifi: Fix default wifi-netif creation to assert if no event loop (v5.1) See merge request espressif/esp-idf!25344
This commit is contained in:
commit
4fc363546e
@ -325,6 +325,7 @@ TEST(esp_netif, create_destroy_default_wifi)
|
||||
// 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();
|
||||
@ -352,6 +353,7 @@ TEST(esp_netif, create_destroy_default_wifi)
|
||||
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());
|
||||
}
|
||||
|
||||
TEST(esp_netif, get_set_hostname)
|
||||
|
@ -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
|
||||
*/
|
||||
@ -73,7 +73,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
|
||||
*/
|
||||
@ -83,7 +85,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
|
||||
*/
|
||||
@ -93,7 +97,8 @@ esp_netif_t* esp_netif_create_default_wifi_sta(void);
|
||||
* @brief Creates default WIFI NAN. 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.
|
||||
* (Note that the default event loop needs to be created prior to calling this API)
|
||||
*
|
||||
* @return pointer to esp-netif instance
|
||||
*/
|
||||
|
@ -373,8 +373,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
|
||||
@ -387,8 +387,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