Accessing the variable called "ssid" inside ESP8266WiFiAPClass

Hello,

It looks like when using the ESP8266WiFi library and connecting first via and access point using a mobile phone for example that the softAP function is called and the network ssid we choose is stored inside "ssid". It seems this is public.

How do I access the value stored inside this variable?

So for example, if a user uses his phone, connects to a network via his mobile phone and the Access Point and I want to confirm via a Serial.println("You are now connected to the following network : ") and then display the network he just selected, then how would I go about doing that?

I looked inside the ESP8266WiFiAP.cpp file.

It seems the ssid passed to the AP is copied inside a structure to the variable "conf.ssid" which is part of "softap_config conf" structure.

Is there a way to access this to display it inside a Serial.println()?
If we cannot do it this way, is there another way to display the ssid we just connected to via the AP?

Thanks.

Ok, I managed to read the content of ssid inside that class and it is not the name of the network we connect to via the AP but the automatically generated name for the AP that uses something like ESP-..... So , I still need to find a way to read the AP's network we connected to.

Why do you need to read the SSID when you need the SSID to connect to WiFi in the first place?

You can run

WiFi.printDiag(Serial);

to get the SSID in the dump of data.

Thank you for the suggestion.

I thought (wrongly) that there was one network saved unde the AP configuration of the WiFi and another network saved under the STA mode. So I was trying to read the network under the AP mode to compare it to the network I had saved to under STA mode that I was using to generate a fixed IP.

I did some more testing and it turns out that once I delete my STA network settings the AP does not know which network to connect automatically to, and therefore I have to use my phone to re-enter a network. So it looks like there is one and only one network saved, be it under AP or STA mode, and if it gets deleted then it reverts back to AP + phone + manually entry, even if the AP had originally connected under a network that was different from the network I had saved for the STA mode.

Cheers.