-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Description
PirSettings pirSettings;Hello,
seems like that put and get doesn't work well.
I have this code:
define PIR_CONFIG 20 //there is nothing writting after byte 20 in eeprom
typedef struct {
String notificationURL;
String smtp;
String smtpUserName;
String smtpPassword;
String subject;
String message;
} PirSettings;
PirSettings pirSettings;
void loadDataFromEeprom() {
EEPROM.get(PIR_CONFIG, pirSettings);
}
void setup() {
Serial.begin(115200);
Serial.println("Starting...");
EEPROM.begin(512);
loadDataFromEeprom();
}
//is called in the webserver method handler
void handle_deviceCfgConfigure() {
pirSettings.notificationURL = server.arg("pirURL");
pirSettings.smtp = server.arg("srv");
pirSettings.smtpUserName = server.arg("usr");
pirSettings.smtpPassword = server.arg("pwd");
pirSettings.subject = server.arg("sbj");
pirSettings.message = server.arg("msg");
EEPROM.put(PIR_CONFIG, pirSettings);
EEPROM.commit();
server.send(200, F("text/html"), getStartPageWithMenu() + F("
Device configured.
") + getEndPage());}
When I did this, after power off power on, the data in the pirSettings are completely wrong - it is tee like data.
Am I doing something wrong? Or is there a bug in the EEPROM library???