query the WIFI IP in IDF

ihouses
Posts: 19
Joined: Sun Jul 09, 2017 1:41 pm

query the WIFI IP in IDF

Postby ihouses » Sun Jan 24, 2021 2:29 pm

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?

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: query the WIFI IP in IDF

Postby WiFive » Sun Jan 24, 2021 5:13 pm

TCPIP_ADAPTER_IF_AP != TCPIP_ADAPTER_IF_STA

ihouses
Posts: 19
Joined: Sun Jul 09, 2017 1:41 pm

Re: query the WIFI IP in IDF

Postby ihouses » Sun Jan 24, 2021 8:14 pm

Oh I see!!!

With TCPIP_ADAPTER_IF_STA the IP is as expected. :D

Thanks!

Who is online

Users browsing this forum: No registered users and 111 guests