-->
Page 1 of 1

Getting the IP Address

PostPosted: Mon Feb 02, 2015 10:48 am
by JannikJung0
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));
}

Re: Getting the IP Address

PostPosted: Mon Feb 02, 2015 1:53 pm
by aaronneal
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);