assigning a hostname

113 views
Skip to first unread message

EMI11

unread,
Apr 17, 2017, 10:17:48 AM4/17/17
to esp-open-rtos mailing list
I think everybody who has multiple ESP8266 moduls wants to assign a distinct hostname to it.
Of course there are the possibility to edit the DHCP server configuration and map a
hostname to the MAC address of the modul.
However there is a simpler possibility. Just add a few lines to lwip/esp_interface.c
ie expand the function ethernetif_init:
...
err_t ethernetif_init(struct netif *netif)
{
  LWIP_ASSERT("netif != NULL", (netif != NULL));

#if LWIP_NETIF_HOSTNAME
  /* Initialize interface hostname */
#ifdef ESP8266_HOSTNAME
  netif->hostname = ESP8266_HOSTNAME;
#else
  netif->hostname = "ESP8266";
#endif
#endif /* LWIP_NETIF_HOSTNAME */
....

and in your Makefile just add at the end
.....
include ../../common.mk

CFLAGS += -DLWIP_NETIF_HOSTNAME=1 -DESP8266_HOSTNAME=\"ESP8266-MYNAME\"

Now you can assign a specific  hostname to every project you write
 
Reply all
Reply to author
Forward
0 new messages