I used one of examples. If I give the new name to device for example "ESP8266fs2" and click Save, device restarts. There is config file with ssid "YOUR_DEFAULT_WIFI_SSID" and "YOUR_DEFAULT_WIFI_PASSWD". This way device after restarting looks for such a ssid. Maybe it would be better to check if ssid is changed and then do connection as station.
Like this: If ssid == "YOUR_DEFAULT_WIFI_SSID" no not make restart as STATION - make restart as AP
I used one of examples. If I give the new name to device for example "ESP8266fs2" and click Save, device restarts. There is config file with ssid "YOUR_DEFAULT_WIFI_SSID" and "YOUR_DEFAULT_WIFI_PASSWD". This way device after restarting looks for such a ssid. Maybe it would be better to check if ssid is changed and then do connection as station.
Like this: If ssid == "YOUR_DEFAULT_WIFI_SSID" no not make restart as STATION - make restart as AP