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?
How can I get local IP?
Re: How can I get local IP?
I am not certain if this is the "recommended" way, but I usually do this.
You will need to include
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);
.#include <tcpip_adapter.h>
Who is online
Users browsing this forum: No registered users and 114 guests