mirror of
https://github.com/esphome/esphome.git
synced 2024-11-28 17:54:13 +01:00
[wifi] Hostname may not be set as expected on Arduino platform (#7050)
* bug #6014: workaround for not setting hostname on arduino plarform * moving handle initailisation to ESPHOME_EVENT_ID_WIFI_STA_START callback
This commit is contained in:
parent
8980996b1a
commit
659fdefccb
1 changed files with 3 additions and 2 deletions
|
@ -82,8 +82,8 @@ bool WiFiComponent::wifi_mode_(optional<bool> sta, optional<bool> ap) {
|
|||
|
||||
// WiFiClass::mode above calls esp_netif_create_default_wifi_sta() and
|
||||
// esp_netif_create_default_wifi_ap(), which creates the interfaces.
|
||||
if (set_sta)
|
||||
s_sta_netif = esp_netif_get_handle_from_ifkey("WIFI_STA_DEF");
|
||||
// s_sta_netif handle is set during ESPHOME_EVENT_ID_WIFI_STA_START event
|
||||
|
||||
#ifdef USE_WIFI_AP
|
||||
if (set_ap)
|
||||
s_ap_netif = esp_netif_get_handle_from_ifkey("WIFI_AP_DEF");
|
||||
|
@ -495,6 +495,7 @@ void WiFiComponent::wifi_event_callback_(esphome_wifi_event_id_t event, esphome_
|
|||
case ESPHOME_EVENT_ID_WIFI_STA_START: {
|
||||
ESP_LOGV(TAG, "Event: WiFi STA start");
|
||||
// apply hostname
|
||||
s_sta_netif = esp_netif_get_handle_from_ifkey("WIFI_STA_DEF");
|
||||
esp_err_t err = esp_netif_set_hostname(s_sta_netif, App.get_name().c_str());
|
||||
if (err != ERR_OK) {
|
||||
ESP_LOGW(TAG, "esp_netif_set_hostname failed: %s", esp_err_to_name(err));
|
||||
|
|
Loading…
Reference in a new issue