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