cotestatnt / esp-fs-webserver

ESP32/ESP8266 webserver, WiFi manager and web editor Arduino library
MIT License
105 stars 27 forks source link

switch to different wifi #17

Closed PatrickMons closed 1 year ago

PatrickMons commented 1 year ago

when you setup a connection to wifi everithing is fine but if you need to switch to another wifi end the name of new wifi is shorter than the previous one there is a problem because the last part of previous name is attacced to new one example: first ssid name "abcdefghilmn" sec. ssid name "123456" the secon ssid name will be: "123456ghilmn" so the result is no wifi found and go again on ap mode

cotestatnt commented 1 year ago

Thanks @PatrickMons for your feedback. I will check for a solution as soon as possible.

PatrickMons commented 1 year ago

I solved clearing the config before writing new value as this: file esp-fs-webserver.cpp line303:

                           #if defined(ESP8266)
            struct station_config stationConf;
            wifi_station_get_config_default(&stationConf);

                           //devo azzerare la configurazione prima di salvarla di nuovo                 
            memset(&stationConf, 0, sizeof(stationConf));

            os_memcpy(&stationConf.ssid, ssid.c_str(), ssid.length());
            os_memcpy(&stationConf.password, pass.c_str(), pass.length());
            wifi_set_opmode( STATION_MODE );
            wifi_station_set_config(&stationConf);