Seeedawg
Seeedawg

Reputation: 1

How to retrieve remote client IP address esp32 soft AP mode

My goal is to retrieve the IP address of client connected to an esp32 in soft Access Point mode WITHOUT client sending a request.

So far calling "remoteIP()" method from "client" object seems to be the only way I can successfully retrieve connected client IP is when an HTTP request is made.

If I call "client.remoteIP()" before the remote client sends an HTTP request I get All zeros, yikes.

Currently I'm polling the "softAPgetStationNum()" method from "WiFi" object and I'm alerted as soon as a device is connected or disconnected. I would like to get the client IP along with the new connection alert.

My advanced apologies for not including my code hopefully my description has enough clarity to properly relay my intended objective. Thanks

Ps- if I could get guidance on retrieving MAC of remote client too that would be dope!

Upvotes: 0

Views: 1995

Answers (1)

Tarmo
Tarmo

Reputation: 4772

I don't know what interface Arduino has built on top of Espressif's framework, but the underlying ESP IDF v4.3 has functions esp_wifi_ap_get_sta_list() which gives you a list of all connected stations (including MACs) and esp_netif_get_sta_list() which maps this list of clients to their IP addresses.

Upvotes: 1

Related Questions