Changed the comment to be legible #209

pull/248/head
Hieromon Ikasamo 5 years ago
parent 5716bdd0a0
commit 756c9c28ea
  1. 28
      examples/EEPROM/EEPROM.ino
  2. 5
      src/AutoConnect.cpp

@ -5,14 +5,14 @@
This software is released under the MIT License.
https://opensource.org/licenses/MIT
This example demonstrates how allocates and handles the custom
configuration for the Sketch.
When Sketch stores the own configuration data in the EEPROM, it must
avoid conflict with the credentials stored by AutoConnect.
AutoConnectConfig::boundaryOffset designation helps with the conflict,
but it is inadequate. Sketch uses AutoConnect::getCredentialSize to
get the size of the actual EEPROM area that should be handled for the
own custom data I/O.
The AutoConnectConfig::boundaryOffset setting allows AutoConnect to
write its data to EEPROM while preserving custom configuration data.
Similarly, when a Sketch writes its own data to EEPROM, it must
preserve the data written by AutoConnect.
This example demonstrates how to use the getEEPROMUsedSize() method to
store custom configuration settings in EEPROM without conflicting with
AutoConnect's use of that storage. (Note: this applies to the ESP8266
only, not the ESP32.)
*/
#ifndef ARDUINO_ARCH_ESP8266
@ -113,12 +113,7 @@ String toString(char* c, uint8_t length) {
String onEEPROM(AutoConnectAux& page, PageArgument& args) {
EEPROM_CONFIG_t eepromConfig;
// The actual area size of the EEPROM region to be given to
// EEPROM.begin is the sum of the size of the own custom data and
// the size of the currently stored AutoConnect credentials.
// eg.
// EEPROM.begin(portal.getEEPROMUsedSize())
EEPROM.begin(portal.getEEPROMUsedSize());
EEPROM.begin(sizeof(eepromConfig));
EEPROM.get<EEPROM_CONFIG_t>(0, eepromConfig);
EEPROM.end();
@ -136,6 +131,11 @@ String onEEPROMWrite(AutoConnectAux& page, PageArgument& args) {
strncpy(eepromConfig.data2, page["data2"].value.c_str(), sizeof(EEPROM_CONFIG_t::data2));
strncpy(eepromConfig.data3, page["data3"].value.c_str(), sizeof(EEPROM_CONFIG_t::data3));
// The actual area size of the EEPROM region to be given to
// EEPROM.begin is the sum of the size of the own custom data and
// the size of the currently stored AutoConnect credentials.
// eg.
// EEPROM.begin(portal.getEEPROMUsedSize())
EEPROM.begin(portal.getEEPROMUsedSize());
EEPROM.put<EEPROM_CONFIG_t>(0, eepromConfig);
EEPROM.commit();

@ -747,9 +747,10 @@ bool AutoConnect::_loadAvailCredential(const char* ssid, const AC_PRINCIPLE_t pr
}
/**
* Get current AutoConnectCredential size.
* Get the total amount of memory required to hold the AutoConnect credentials
* and any custom configuration settings stored in EEPROM.
* This function is available only for ESP8266 use.
* @return Size of the AutoConnectCredential
* @return Combined size of AutoConnect credentials and custom settings.
*/
uint16_t AutoConnect::getEEPROMUsedSize(void) {
#if defined(ARDUINO_ARCH_ESP8266)

Loading…
Cancel
Save