Arranged the composition

pull/57/head
Hieromon Ikasamo 6 years ago
parent ebde883dce
commit a987caf498
  1. 113
      mkdocs/credit.md

@ -1,10 +1,8 @@
## Saved credential in EEPROM ## Saved credential in EEPROM
AutoConnect saves the established WiFi connection to the EEPROM area of the ESP8266/ESP32 module and equips a class for accessing the credentials. You can use the class to access the credentials individually. AutoConnect stores the established WiFi connection in the EEPROM of the ESP8266/ESP32 module and equips the class to access it from the sketch. You can read, write or erase the credentials using this class individually. It's [**AutoConnectCredential**](#autoconnectcredential) class which provides the access method to the saved credentials in EEPROM.
Make some sketches for erasing the EEPROM area, or some erasing utility is needed. You can prepare the sketch to erase the saved credential with *AutoConnectCredential*. The *AutoConnectCrendential* class provides the access method to the saved credential in EEPROM and library source file is including it. ## AutoConnectCredential
A class description of AutoConnectCredential is follows.
### <i class="fa fa-code"></i> Include header ### <i class="fa fa-code"></i> Include header
@ -12,41 +10,101 @@ A class description of AutoConnectCredential is follows.
#include <AutoConnectCredential.h> #include <AutoConnectCredential.h>
``` ```
### <i class="fa fa-code"></i> Constructor ### <i class="fa fa-code"></i> Constructors
```cpp ```cpp
AutoConnectCredential(); AutoConnectCredential();
``` ```
AutoConnectCredential default constructor. The default offset value is 0. If the offset value is 0, the credential storage area starts from the top of the EEPROM. AutoConnect sometimes overwrites data when using this area with user sketch. AutoConnectCredential default constructor. The default offset value is 0. If the offset value is 0, the credential area starts from the top of the EEPROM. AutoConnect sometimes overwrites data when using this area with user sketch.
```cpp ```cpp
AutoConnectCredential(uint16_t offset); AutoConnectCredential(uint16_t offset);
``` ```
<dl class="apidl">
Specify offset from the top of the EEPROM for the credential storage area together. The offset value is from 0 to the flash sector size. <dt>**Parameter**</dt>
<dd><span class="apidef">offset</span><span class="apidesc">Species offset from the top of the EEPROM for the credential area together. The offset value is from 0 to the flash sector size.</span></dd>
</dl>
### <i class="fa fa-code"></i> Public member functions ### <i class="fa fa-code"></i> Public member functions
- uint8_t **entries()** #### <i class="fa fa-caret-right"></i> entries
Returns number of entries as contained credentials.
```cpp
uint8_t entries(void)
```
Returns number of entries as contained credentials.
<dl class="apidl">
<dt>**Return value**</dt>
<dd>Number of entries as contained credentials.</dd>
</dl>
#### <i class="fa fa-caret-right"></i> load
```cpp
int8_t load(const char* ssid, struct station_config* config)
```
Load a credential entry and store to **config**.
<dl class="apidl">
<dt>**Parameters**</dt>
<dd><span class="apidef">ssid</span><span class="apidesc">SSID to be loaded.</span></dd>
<dd><span class="apidef">config</span><span class="apidesc">station_config</span></dd>
<dt>**Return value**</dt>
<dd>Save the specified SSID's credential entry to station_config pointed to by the parameter as **config**. -1 is returned if the SSID is not saved. </dd>
</dl>
#### <i class="fa fa-caret-right"></i> load
- int8_t **load(const char\* _ssid_, struct station_config\* _config_)** ```cpp
Load a credential entry specified *ssid* to *config*. Returns -1 as unsuccessfully loaded. bool load(int8_t entry, struct station_config* config)
```
Load a credential entry and store to **config**.
<dl class="apidl">
<dt>**Parameters**</dt>
<dd><span class="apidef">entry</span><span class="apidesc">Specifies the index number based 0 to be loaded.</span></dd>
<dd><span class="apidef">config</span><span class="apidesc">station_config</span></dd>
<dt>**Return value**</dt>
<dd>Save the specified credential entry to station_config pointed to by the parameter as **config**. -1 is returned if specified number is not saved. </dd>
</dl>
#### <i class="fa fa-caret-right"></i> save
```cpp
bool save(const struct station_config* config)
```
Save a credentail entry.
<dl class="apidl">
<dt>**Parameter**</dt>
<dd><span class="apidef">config</span><span class="apidesc">station_config to be saved.</span></dd>
<dt>**Return value**</dt>
<dd><span class="apidef">true</span><span class="apidesc">Successfully saved.</span></dd>
<dd><span class="apidef">false</span><span class="apidesc">Failed to save.</span></dd>
</dl>
#### <i class="fa fa-caret-right"></i> del
- bool **load(int8_t _entry_, struct station_config\* _config_)** ```cpp
Load a credential entry to *config*. The *entry* parameter specify to index of the entry. bool del(const char* ssid)
```
- bool **save(const struct station_config\* _config_)** Delete a credential the specified SSID.
Save a credential entry stored in *config* to EEPROM. Returns the true as succeeded. <dl class="apidl">
<dt>**Parameter**</dt>
<dd><span class="apidef">ssid</span><span class="apidesc">SSID to be deleted.</span></dd>
<dt>**Return value**</dt>
<dd><span class="apidef">true</span><span class="apidesc">Successfully deleted.</span></dd>
<dd><span class="apidef">false</span><span class="apidesc">Failed to delete.</span></dd>
</dl>
- bool **del(const char\* _ssid_)** ## The data structures
Delete a credential entry specified *ssid*. Returns the true as successfully deleted.
### <i class="fa fa-code"></i> Data structures ### <i class="fa fa-code"></i> station_config
- station_config A structure is included in the ESP8266 SDK. You can use it in the sketch like as follows:
A structure is included in the ESP8266 SDK. You can use it in the sketch like as follows.
```cpp ```cpp
extern "C" { extern "C" {
@ -56,15 +114,16 @@ extern "C" {
```cpp ```cpp
struct station_config { struct station_config {
uint8 ssid[32]; uint8 ssid[32];
uint8 password[64]; uint8 password[64];
uint8 bssid_set; uint8 bssid_set;
uint8 bssid[6]; uint8 bssid[6];
}; };
``` ```
- EEPROM data structure ### <i class="fa fa-code"></i> The credential entry
A data structure of the credential saving area in EEPROM as the below. [^1]
A data structure of the credential saving area in EEPROM as the below. [^1]
[^1]: [^1]:
There may be 0xff as an invalid data in the credential saving area. The 0xff area would be reused. There may be 0xff as an invalid data in the credential saving area. The 0xff area would be reused.

Loading…
Cancel
Save