Re: EEPROM Lost after reboot/power off
Posted:
Sat Jan 23, 2016 12:18 pm
by pomelo
martinayotte wrote:Strange ...
Did you choose proper Flash size corresponding for your module in the IDE menu ?
HI yes, tried changing that in the IDE (
https://github.com/esp8266/Arduino/issues/1486) and nothing helps.
I suspect this can be caused by Mac OSX as i had difficulties from the start to set this all up..
Re: EEPROM Lost after reboot/power off
Posted:
Sat Jan 23, 2016 12:27 pm
by martinayotte
I don't see the relation between Mac OS X and EEPROM.
If your sketch is uploaded and running.
BTW, in your above, why is there a yield() function call ?
Re: EEPROM Lost after reboot/power off
Posted:
Sat Jan 23, 2016 12:30 pm
by pomelo
martinayotte wrote:I don't see the relation between Mac OS X and EEPROM.
If your sketch is uploaded and running.
BTW, in your above, why is there a yield() function call ?
It was just a test to see if it helps - that i found somewhere in other sketch. However it's not there anymore, still i can save until rebooted.
Code: Select allvoid CSense::LoadConfig(tConfig& rtConfig)
{
EEPROM.begin(512);
delay(250);
//
rtConfig.m_strWiFiSSID = "";
rtConfig.m_strWiFiPassword = "";
rtConfig.m_strDescription = "";
for(int i = 0; i < 512; i++)
{
char a = char(EEPROM.read(i));
Serial.print("EEPROM ADDRESS: "+String(i)+" VALUE: ");
Serial.println(a);
}
Serial.print("\n");
// Laod SSID First
for (int i = 0; i < m_iMaxSSIDLength; i++)
{
rtConfig.m_strWiFiSSID += char(EEPROM.read(i));
}
// Load PASS
for (int i = 0; i < m_iMaxPasswordLength; i++)
{
rtConfig.m_strWiFiPassword += char(EEPROM.read(m_iMaxSSIDLength+i));
}
// Load Description
for (int i = 0; i < m_iMaxDescriptionLength; i++)
{
rtConfig.m_strDescription += char(EEPROM.read(m_iMaxSSIDLength+m_iMaxPasswordLength+i));
}
EEPROM.end();
delay(250);
}
void CSense::SaveConfig(const tConfig& rtConfig)
{
EEPROM.begin(512);
delay(250);
// Clear EEPROM
for(int a = 0; a < 512;a++)
{
EEPROM.write(a, 0);
}
// Save SSID
for (int i = 0; i < m_iMaxSSIDLength; i++)
{
if(i < rtConfig.m_strWiFiSSID.length())
EEPROM.write(i, rtConfig.m_strWiFiSSID[i]);
}
// Save Password
for (int i = 0; i < m_iMaxPasswordLength; i++)
{
if(i < rtConfig.m_strWiFiPassword.length())
EEPROM.write(i + m_iMaxSSIDLength, rtConfig.m_strWiFiPassword[i]);
}
// Save Description
for (int i = 0; i < m_iMaxDescriptionLength; i++)
{
if(i < rtConfig.m_strDescription.length())
EEPROM.write(i + m_iMaxSSIDLength + m_iMaxPasswordLength, rtConfig.m_strDescription[i]);
}
if(EEPROM.commit() == true)
{
Serial.println("EEPROM.COMMIT == TRUE");
}
else
Serial.println("EEPROM.COMMIT == FALSE");
delay(250);
}
Re: EEPROM Lost after reboot/power off
Posted:
Sat Jan 23, 2016 12:31 pm
by pomelo
pomelo wrote:martinayotte wrote:I don't see the relation between Mac OS X and EEPROM.
If your sketch is uploaded and running.
BTW, in your above, why is there a yield() function call ?
It was just a test to see if it helps - that i found somewhere in other sketch. However it's not there anymore, still i can save until rebooted.
Code: Select allvoid CSense::LoadConfig(tConfig& rtConfig)
{
EEPROM.begin(512);
delay(250);
//
rtConfig.m_strWiFiSSID = "";
rtConfig.m_strWiFiPassword = "";
rtConfig.m_strDescription = "";
for(int i = 0; i < 512; i++)
{
char a = char(EEPROM.read(i));
Serial.print("EEPROM ADDRESS: "+String(i)+" VALUE: ");
Serial.println(a);
}
Serial.print("\n");
// Laod SSID First
for (int i = 0; i < m_iMaxSSIDLength; i++)
{
rtConfig.m_strWiFiSSID += char(EEPROM.read(i));
}
// Load PASS
for (int i = 0; i < m_iMaxPasswordLength; i++)
{
rtConfig.m_strWiFiPassword += char(EEPROM.read(m_iMaxSSIDLength+i));
}
// Load Description
for (int i = 0; i < m_iMaxDescriptionLength; i++)
{
rtConfig.m_strDescription += char(EEPROM.read(m_iMaxSSIDLength+m_iMaxPasswordLength+i));
}
EEPROM.end();
delay(250);
}
void CSense::SaveConfig(const tConfig& rtConfig)
{
EEPROM.begin(512);
delay(250);
// Clear EEPROM
for(int a = 0; a < 512;a++)
{
EEPROM.write(a, 0);
}
// Save SSID
for (int i = 0; i < m_iMaxSSIDLength; i++)
{
if(i < rtConfig.m_strWiFiSSID.length())
EEPROM.write(i, rtConfig.m_strWiFiSSID[i]);
}
// Save Password
for (int i = 0; i < m_iMaxPasswordLength; i++)
{
if(i < rtConfig.m_strWiFiPassword.length())
EEPROM.write(i + m_iMaxSSIDLength, rtConfig.m_strWiFiPassword[i]);
}
// Save Description
for (int i = 0; i < m_iMaxDescriptionLength; i++)
{
if(i < rtConfig.m_strDescription.length())
EEPROM.write(i + m_iMaxSSIDLength + m_iMaxPasswordLength, rtConfig.m_strDescription[i]);
}
if(EEPROM.commit() == true)
{
Serial.println("EEPROM.COMMIT == TRUE");
}
else
Serial.println("EEPROM.COMMIT == FALSE");
delay(250);
}
On calling Save i get EEPROM.COMMIT == FALSE, meaning .commit() returns false;