How can I get local IP?

Cannon Wang
Posts: 2
Joined: Thu Oct 12, 2017 10:42 am

How can I get local IP?

Postby Cannon Wang » Tue Nov 07, 2017 2:10 am

Hi,
I'm using ESP32 as station mode, once connect to an AP I need to send my local IP to a remote server.
One way to do this is storing the IP in a global variable manually when SYSTEM_EVENT_STA_GOT_IP happend. While, how to get local IP in a recommended way?

bbemister
Posts: 1
Joined: Fri Feb 02, 2018 7:23 pm

Re: How can I get local IP?

Postby bbemister » Fri Feb 02, 2018 7:33 pm

I am not certain if this is the "recommended" way, but I usually do this.

Code: Select all

tcpip_adapter_ip_info_t if_info;
tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_STA, &if_info);
ip4addr_ntoa_r(&(if_info.ip), ipv4_str, buflen);
You will need to include
#include <tcpip_adapter.h>
.

Who is online

Users browsing this forum: No registered users and 112 guests