Chat freely about anything...

User avatar
By kingfisher
#3303 if you want to give a name to your device...

in lwip/core/dhcp.c
add this function

Code: Select all#include "user_interface.h"

char* hostname()
{
        //the name is your SSID... eventually here you can return any string
        // return "ESP8266";

   static struct softap_config apConfig;
   wifi_softap_get_config(&apConfig);
   return apConfig.ssid;
}


and in functions dhcp_select modify, dhcp_renew, dhcp_rebind

change this
Code: Select all#if LWIP_NETIF_HOSTNAME
    if (netif->hostname != NULL) {
      const char *p = (const char*)netif->hostname;
      u8_t namelen = (u8_t)strlen(p);
      if (namelen > 0) {
        LWIP_ASSERT("DHCP: hostname is too long!", namelen < 255);
        dhcp_option(dhcp, DHCP_OPTION_HOSTNAME, namelen);
        while (*p) {
          dhcp_option_byte(dhcp, *p++);
        }
      }
    }
#endif /* LWIP_NETIF_HOSTNAME */

into this
Code: Select all      const char *name = hostname();
      u8_t namelen = (u8_t)strlen(name);
      if (namelen > 0) {
        LWIP_ASSERT("DHCP: hostname is too long!", namelen < 255);
        dhcp_option(dhcp, DHCP_OPTION_HOSTNAME, namelen);
        while (*name) {
          dhcp_option_byte(dhcp, *name++);
        }
      }
User avatar
By mano1979
#55935 Will this code also add the ability to connect (through local network) from one esp8266 to other esp8266's with a hostname instead of ip?