← index #9203PR #18956
Duplicate · high · value 1.019
QUERY · ISSUE

port/ESP32/network.AP_IF: get IP addresses from connected stations

openby MeckPommERopened 2022-09-03updated 2026-03-19
enhancementport-esp32

Hello and thanks for your time!

When the ESP32 is working as an access point, it is possible get a MAC list of connected stations via ap.status('stations'). But there is (i've found) no way to find the IP, which the ESP32 has assigned to the corresponding station.

I my case, the ESP32 is working as a mobile accesspoint and webserver, handling the communication between robots and browsers. To configure the robot controlling HTML pages, i need the corrent IP addresses. I am at a point where I know, which robot is connected from a dictionary, where I store the MAC and other info, but i am unable to find the needed IP.

An extension of the station list to include the IP entry (if assigned) would be very helpful.

Thanks in advance.

CANDIDATE · PULL REQUEST

esp32/network_wlan: Look up IP addresses for the stations list.

openby agattiopened 2026-03-20updated 2026-03-20
port-esp32

Summary

This PR extends the output of WLAN.status('stations') to also include the IP address of WiFi stations connected to the device if in AP mode.

The ESP32 port is brought up to parity with most ports in this regard (primarily with the ESP8266). This functionality depends on the DHCP server provided by ESP-IDF, which is automatically run on the WiFi interface if the device is put in AP mode. Currently the ESP32 port cannot run with said DHCP server disabled, so if a device does not request a static IP it may either have the wrong IP address returned (since the DHCP server assigned an address which is then discarded by the client), or it won't have any (ie. "0.0.0.0"). In the latter case None will be returned as the station's address instead.

This implements #9203.

<hr>

ESP-IDF was probably always able to pull this off by performing the manual MAC→IP match via LWIP's DHCPS functions, but I guess that was not done to save on code space.

ESP-IDF 5.0 introduced a function that performs just that with little code (esp_wifi_ap_get_sta_list_with_ip), so now this can be safely added.

Testing

This was tested on an ESP32C3 running on git master and ESP-IDF 5.5.1, by connecting and disconnecting several devices to the device put in AP mode beforehand.

The original behaviour (returning a tuple with just the MAC address) is preserved for boards that use WiFi hosted mode (namely the ESP32P4). I do not have one of those boards myself so I wasn't able to test that specific use case, although the ifdef guards seem to be properly placed at least.

Trade-offs and Alternatives

There is currently no provision for the ESP32 port to run without DHCPS on the WiFi interface when put in AP mode, so I have no idea on the effective behaviour of a client connection without a DHCP server being present.

Generative AI

I did not use generative AI tools when creating this PR.

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied