Chat freely about anything...

User avatar
By JannikJung0
#8779 Hello everybody,
I'm trying to get the ip address once the esp is connect to the network.
That's my code, but I always get 255.255.255.255

Code: Select allvoid getIP() {
   struct ip_info pTempIp;
   int8_t len;
   char ipTemp[64];

   wifi_get_ip_info(0x01, &pTempIp);
   pTempIp.ip.addr = ipaddr_addr(ipTemp);

   ets_uart_printf("IP: %d.%d.%d.%d\r\n", IP2STR(&pTempIp.ip));
}
User avatar
By aaronneal
#8790 The offset should be 0x00 for station mode and 0x01 for AP mode.
this works for me in Station mode

Code: Select allvoid getIP(char *buf)
{
   struct ip_info pTempIp;
   wifi_get_ip_info(0x00, &pTempIp);
   os_sprintf(buf, "%d.%d.%d.%d",IP2STR(&pTempIp.ip));
}


where it is called as such:

Code: Select allchar ip[64];
getIP(ip);