In an esp8266 that is in STA mode I change it to AP mode and it works fine, but when I try to change it back to STA mode it doesn't connect to Wi-Fi.
I have to restart it and put it in STA mode and then it connects without problems.
The code is fine, because I use it when I restart it and it connects.
I tried a lot of things without result.
Greetings and thank you.