Skip to content

EEPROM library - put and get doesn't work well #449

@robertgregor

Description

@robertgregor

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???

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions