@@ -76,10 +76,8 @@ void ConfigManager::setup() {
7676}
7777
7878void ConfigManager::loop () {
79-
8079 if (this ->getMode () == ap) {
81- if (apTimeout > 0 &&
82- ((millis () - apStart) / 1000 ) > (uint16_t )apTimeout) {
80+ if (apTimeout > 0 && ((millis () - apStart) / 1000 ) > (uint16_t )apTimeout) {
8381 ESP.restart ();
8482 }
8583
@@ -234,8 +232,7 @@ bool ConfigManager::wifiConnect(char* ssid, char* password) {
234232 return connected;
235233}
236234
237- void ConfigManager::storeWifiSettings (String ssid,
238- String password) {
235+ void ConfigManager::storeWifiSettings (String ssid, String password) {
239236 char ssidChar[SSID_LENGTH];
240237 char passwordChar[PASSWORD_LENGTH];
241238
@@ -380,6 +377,7 @@ void ConfigManager::writeConfig() {
380377 }
381378 this ->commitChanges ();
382379}
380+
383381void ConfigManager::save () {
384382 this ->writeConfig ();
385383}
@@ -461,7 +459,7 @@ void ConfigManager::streamFile(const char* file, const char mime[]) {
461459 f = SPIFFS.open (file, " r" );
462460 } else {
463461 size_t len = strlen (file);
464- char filepath[len+ 1 ];
462+ char filepath[len + 1 ];
465463 strcpy (filepath, " /" );
466464 strcat (filepath, file);
467465 f = SPIFFS.open (filepath, " r" );
@@ -475,7 +473,6 @@ void ConfigManager::streamFile(const char* file, const char mime[]) {
475473 DebugPrintln (file);
476474 handleNotFound ();
477475 }
478-
479476}
480477
481478void ConfigManager::handleAPGet () {
@@ -505,9 +502,13 @@ void ConfigManager::handleAPPost() {
505502 }
506503
507504 storeWifiSettings (ssid, password);
505+ if (this ->getMode () != station) {
506+ this ->writeConfig ();
507+ }
508508
509509 server->send (204 , FPSTR (mimePlain), F (" Saved. Will attempt to reboot." ));
510- delay (500 ); // Allow enough time for the response to be sent before restarting.
510+ // Allow enough time for the response to be sent before restarting.
511+ delay (500 );
511512
512513 ESP.restart ();
513514}
0 commit comments