Page 1 of 1

Can't get or set hostname on netif

Posted: Fri Oct 06, 2023 8:40 am
by rpoelvogels
Hi,

I'm trying to set the hostname for the ethernet interface.
But `esp_netif_set_hostname()` always returns `ESP_ERR_ESP_NETIF_IF_NOT_READY`.
`esp_netif_get_hostname()` also always only returns `ESP_ERR_ESP_NETIF_IF_NOT_READY`.

I've checked the source code of these functions and they look like:

Code: Select all

#if LWIP_NETIF_HOSTNAME
//Useful code
#else
    return ESP_ERR_ESP_NETIF_IF_NOT_READY;
#endif
`LWIP_NETIF_HOSTNAME` is defined as '0', so the useful code is removed.

How and where can I make sure that `LWIP_NETIF_HOSTNAME` is properly defined?

I'm using ESP-IDF 4.4.

Thanks in advance.

Kind regards,

Remco Poelstra

Re: Can't get or set hostname on netif

Posted: Tue Mar 19, 2024 4:17 pm
by chegewara
When you init ethernet netif with this or similar API:

Code: Select all

ethernetif_init()
you can use thi API w/o issues

Code: Select all

esp_netif_set_hostname(esp_netif, name)