give a name to your ESP...
Posted: Tue Nov 25, 2014 2:47 pm
if you want to give a name to your device...
in lwip/core/dhcp.c
add this function
and in functions dhcp_select modify, dhcp_renew, dhcp_rebind
change this
into this
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++);
}
}