Adds getEEPROMUsedSize description

pull/248/head
Hieromon Ikasamo 4 years ago
parent 756c9c28ea
commit f86ec77f48
  1. 32
      mkdocs/advancedusage.md
  2. 16
      mkdocs/api.md

@ -729,6 +729,38 @@ The [**boundaryOffset**](apiconfig.md#boundaryoffset) in [AutoConnectConfig](api
!!! info "The boundaryOffset ignored with AutoConnect v1.0.0 later on ESP32 arduino core 1.0.3 later"
For ESP32 arduino core 1.0.3 and later, AutoConnect will store credentials to Preferences in the nvs. Since it is defined as the namespace dedicated to AutoConnect and separated from the area used for user sketches. Therefore, the [boundaryOffset](apiconfig.md#boundaryoffset) is ignored with the combination of AutoConnect v1.0.0 or later and the arduino-esp32 1.0.3 or later.
The [*AutoConnectConfig::boundaryOffset*](apiconfig.md#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.
The EEPROM library for ESP8266 erases the entire flash sector when it writes to any part of the sector. Therefore, when writing data to EEPROM with a sketch that handles the custom data, it is necessary to call `EEPROM.begin` using a total amount of a custom data size and the saved credentials size.
The following code shows how to use the [*AutoConnect::getEEPROMUsedSize*](api.md#geteepromusedsize) function to store custom configuration settings in EEPROM without conflicting with AutoConnect's use of that storage.
```cpp hl_lines="13 21"
AutoConnect portal;
AutoConnectConfig config;
// Defines the custom data should be stored in EEPROM.
typedef struct {
char data1[8];
char data2[8];
char data3[8];
} EEPROM_CONFIG_t;
EEPROM_CONFIG_t eepromConfig;
...
// Declares to reserve the EEPROM_CONFIG_t area for a Sketch using.
config.boundaryOffset = sizeof(eepromConfig);
portal.config(config);
...
strcpy(eepromComfig.data1, "data1");
strcpy(eepromComfig.data2, "data2");
strcpy(eepromComfig.data3, "data3");
// Use getEEPROMUsedSize to access the EEPROM with the appropriate region size.
EEPROM.begin(portal.getEEPROMUsedSize());
EEPROM.put<EEPROM_CONFIG_t>(0, eepromConfig);
EEPROM.commit();
EEPROM.end();
...
```
### <i class="fa fa-caret-right"></i> Relocate the AutoConnect home path
A home path of AutoConnect is **/\_ac** by default. You can access from the browser with http://IPADDRESS/\_ac. You can change the home path by revising [**AUTOCONNECT_URI**](https://github.com/Hieromon/AutoConnect/blob/master/src/AutoConnectDefs.h#L69) macro in the include header file as [AutoConnectDefs.h](https://github.com/Hieromon/AutoConnect/blob/master/src/AutoConnectDefs.h).

@ -166,7 +166,6 @@ Stops AutoConnect captive portal service. Release ESP8266WebServer/WebServer and
!!! warning "Attention to end"
The end function releases the instance of ESP8266WebServer/WebServer and DNSServer. It can not process them after the end function.
### <i class="fa fa-caret-right"></i> disableMenu
```cpp
@ -179,6 +178,21 @@ Disable the [AutoConnect menu](menu.md) items specified by the items parameter w
<dd><span class="apidef">items</span><span class="apidesc">Specify the combined value of **AC_MENUITEM_t** of the items deleting from the AutoConnect menu. It provides the value calculated from the **logical OR** by the AC_MENUITEM_t value of each item. Refer to the [enableMenu](#enablemenu) about AC_MENUITEM_t.</span></dd>
</dl>
### <i class="fa fa-caret-right"></i> getEEPROMUsedSize
```cpp
uint16_t getEEPROMUsedSize(void)
```
Returns the total amount of memory required to hold the AutoConnect credentials and any custom configuration settings stored in EEPROM. The Sketch that writes its own custom data to the EEPROM must call `EEPROM.begin` with this value.
<dl class="apidl">
<dt>**Return value**</dt>
<dd>Total amount size of saved AutoConnect credentials and custom data.</dd>
</dl>
!!! note "The getEEPROMUsedSize is available for only ESP8266 use"
It is available for only ESP8266 use and will return 0 when used with ESP32.
### <i class="fa fa-caret-right"></i> handleClient
```cpp

Loading…
Cancel
Save