Page 1 of 1

query the WIFI IP in IDF

Posted: Sun Jan 24, 2021 2:29 pm
by ihouses
Hi,

In the examples the WIFI IP is printed by executing:
LOG(LL_INFO, ("got ip:" IPSTR, IP2STR(&event->ip_info.ip)));

But I would need to ask for the WIFI IP in other parts of my code. I saw that this function is equivalent:

tcpip_adapter_ip_info_t ip;
tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_AP, &ip);

But unfortunately if I print the content of ip the value are not matching.

unsigned int val = ip.ip.addr;
printf("READ ip %d.%d.%d.%d\n", val&0xFF, (val >> 8) & 0xFF, (val >> 16) & 0xFF, (val>> 24) & 0xFF);

The first code show ip=192.168.1.63 and the second: 128.8.120.0

[1B][0;32mI (2088) esp_netif_handlers: sta ip: 192.168.1.63, mask: 255.255.255.0, gw: 192.168.1.1[1B][0m
READ ip 128.8.120.0

Any idea how to do this properly?

Re: query the WIFI IP in IDF

Posted: Sun Jan 24, 2021 5:13 pm
by WiFive
TCPIP_ADAPTER_IF_AP != TCPIP_ADAPTER_IF_STA

Re: query the WIFI IP in IDF

Posted: Sun Jan 24, 2021 8:14 pm
by ihouses
Oh I see!!!

With TCPIP_ADAPTER_IF_STA the IP is as expected. :D

Thanks!