As the title says... Chat on...

User avatar
By Alexsander Magalhães
#75354 Hello everyone.
Im reposting this as I didnt see my last post come online.

Im making it simple this time. I'm facing dificulties when trying to reconfigure "on the fly" my wifi module.
As a project restraint, I cannot use end user configuration and I must use lua.

No problem at all, I've managed to receive local router info from my custom app UI using Json and TCP.
The thing is: Its done via ESP's AP using wifi.setmode(wifi.STATIONAP) but when I receive the ssid and password info, I just want to pass it to my Station module, using wifi.sta.config(station_cfg) and connect to my local router without losing the former AP connection with the user.

It is necessary so I can tell the user if a connection has been stablished to that router and also give the ESP's IP back to the user via the AP connection (wich is polled from time to time during the configuration until the ESP say its all good).

When this phase is done, I want to change my wifi module mode of operation to wifi.setmode(wifi.STATION) so it will consume less energy.

I thought this was simple. But for some reason when I call "wifi.sta.config(station_cfg)" I got a PANIC error... as if I didnt "declare" wifi.sta somewhere in the code.
I dont know what Im missing about those modules, but I thought they were global and accessible whenever I enabled them using wifi.setmode.

So: Is there a catch when reconfiguring the wifi modules without reseting the ESP and using Lua?

Can you guys help me understand why I'm getting this PANIC behavior?
Thanks