Skip to content

Instantly share code, notes, and snippets.

@msraynsford
Created February 28, 2018 20:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save msraynsford/ccd22623b5ac8fe69d5a8c080f77b54c to your computer and use it in GitHub Desktop.
Save msraynsford/ccd22623b5ac8fe69d5a8c080f77b54c to your computer and use it in GitHub Desktop.
// If the passwords match we can update the config with the new settings
// Check to see if there is a new value (also doubles to check the length of the new value is long enough)
if(webServer.arg("newpassword").length() > 7)
webServer.arg("newpassword").toCharArray(config.password, sizeof(config.password));
if(webServer.arg("newssid").length() > 7)
webServer.arg("newssid").toCharArray(config.ssid, sizeof(config.ssid));
// Store the new settings to EEPROM
EEPROM_writeAnything(0, config);
EEPROM.commit();
// Construct a message to tell the user that the change worked
message = "New settings will take effect after restart";
Serial.println(message);
// Reply with a web page to indicate success or failure
message = "<html><head><meta http-equiv='refresh' content='5;url=/' /></head><body><h1>" + message;
message += "<br/>Redirecting in 5 seconds...</h1></body></html>";
webServer.send(200, "text/html", message);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment