mirror of
https://github.com/esphome/esphome.git
synced 2025-02-21 20:38:16 +00: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
@ -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
|
// WiFiClass::mode above calls esp_netif_create_default_wifi_sta() and
|
||||||
// esp_netif_create_default_wifi_ap(), which creates the interfaces.
|
// esp_netif_create_default_wifi_ap(), which creates the interfaces.
|
||||||
if (set_sta)
|
// s_sta_netif handle is set during ESPHOME_EVENT_ID_WIFI_STA_START event
|
||||||
s_sta_netif = esp_netif_get_handle_from_ifkey("WIFI_STA_DEF");
|
|
||||||
#ifdef USE_WIFI_AP
|
#ifdef USE_WIFI_AP
|
||||||
if (set_ap)
|
if (set_ap)
|
||||||
s_ap_netif = esp_netif_get_handle_from_ifkey("WIFI_AP_DEF");
|
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: {
|
case ESPHOME_EVENT_ID_WIFI_STA_START: {
|
||||||
ESP_LOGV(TAG, "Event: WiFi STA start");
|
ESP_LOGV(TAG, "Event: WiFi STA start");
|
||||||
// apply hostname
|
// 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());
|
esp_err_t err = esp_netif_set_hostname(s_sta_netif, App.get_name().c_str());
|
||||||
if (err != ERR_OK) {
|
if (err != ERR_OK) {
|
||||||
ESP_LOGW(TAG, "esp_netif_set_hostname failed: %s", esp_err_to_name(err));
|
ESP_LOGW(TAG, "esp_netif_set_hostname failed: %s", esp_err_to_name(err));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user