ESP8266 - getting the SSID of the running AP server in AP mode

How does one get the current SSID of the running softAP in AP mode on an ESP8266?

When I use WiFi.SSID, this returns the last network router SSID to which the ESP was connected in client mode rather than the SSID of the currently running AP? There seems to be no call in the library for something like WiFi.softAPSSID. It seems odd that I can get other running details such as the IP address, mac address, connected stations, but not the running softAP SSID?

After digging around in the ESP8266 library, I found the following public declaration in ESP8266WiFiAP.h:

String softAPSSID() const;

This call however seems to be omitted from the official documentation and did not appear to be mentioned in any tutorial that I came across. Sure enough, I found that the following will return the current softAP SSID name:

String APssid;

APssid = WiFi.softAPSSID();

It would appear that WiFi.SSID() is reserved for obtaining the SSID of the WiFi network to which the ESP is connected in client mode only.

1 Like