From a987caf4988303cefef561374c8c907514519cfd Mon Sep 17 00:00:00 2001 From: Hieromon Ikasamo Date: Sat, 13 Apr 2019 00:13:20 +0900 Subject: [PATCH] Arranged the composition --- mkdocs/credit.md | 113 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 86 insertions(+), 27 deletions(-) diff --git a/mkdocs/credit.md b/mkdocs/credit.md index 9b62e1b..e3b3431 100644 --- a/mkdocs/credit.md +++ b/mkdocs/credit.md @@ -1,10 +1,8 @@ ## 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. - -A class description of AutoConnectCredential is follows. +## AutoConnectCredential ### Include header @@ -12,41 +10,101 @@ A class description of AutoConnectCredential is follows. #include ``` -### Constructor +### Constructors ```cpp 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 AutoConnectCredential(uint16_t offset); ``` - -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. +
+
**Parameter**
+
offsetSpecies offset from the top of the EEPROM for the credential area together. The offset value is from 0 to the flash sector size.
+
### Public member functions -- uint8_t **entries()** - Returns number of entries as contained credentials. +#### entries + +```cpp +uint8_t entries(void) +``` + +Returns number of entries as contained credentials. +
+
**Return value**
+
Number of entries as contained credentials.
+
+ +#### load + +```cpp +int8_t load(const char* ssid, struct station_config* config) +``` + +Load a credential entry and store to **config**. +
+
**Parameters**
+
ssidSSID to be loaded.
+
configstation_config
+
**Return value**
+
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.
+
+ +#### load -- int8_t **load(const char\* _ssid_, struct station_config\* _config_)** - Load a credential entry specified *ssid* to *config*. Returns -1 as unsuccessfully loaded. +```cpp +bool load(int8_t entry, struct station_config* config) +``` + +Load a credential entry and store to **config**. +
+
**Parameters**
+
entrySpecifies the index number based 0 to be loaded.
+
configstation_config
+
**Return value**
+
Save the specified credential entry to station_config pointed to by the parameter as **config**. -1 is returned if specified number is not saved.
+
+ +#### save + +```cpp +bool save(const struct station_config* config) +``` + +Save a credentail entry. +
+
**Parameter**
+
configstation_config to be saved.
+
**Return value**
+
trueSuccessfully saved.
+
falseFailed to save.
+
+ +#### del -- bool **load(int8_t _entry_, struct station_config\* _config_)** - Load a credential entry to *config*. The *entry* parameter specify to index of the entry. +```cpp +bool del(const char* ssid) +``` -- bool **save(const struct station_config\* _config_)** - Save a credential entry stored in *config* to EEPROM. Returns the true as succeeded. +Delete a credential the specified SSID. +
+
**Parameter**
+
ssidSSID to be deleted.
+
**Return value**
+
trueSuccessfully deleted.
+
falseFailed to delete.
+
-- bool **del(const char\* _ssid_)** - Delete a credential entry specified *ssid*. Returns the true as successfully deleted. +## The data structures -### Data structures +### 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 extern "C" { @@ -56,15 +114,16 @@ extern "C" { ```cpp struct station_config { - uint8 ssid[32]; - uint8 password[64]; - uint8 bssid_set; - uint8 bssid[6]; + uint8 ssid[32]; + uint8 password[64]; + uint8 bssid_set; + uint8 bssid[6]; }; ``` -- EEPROM data structure - A data structure of the credential saving area in EEPROM as the below. [^1] +### The credential entry + +A data structure of the credential saving area in EEPROM as the below. [^1] [^1]: There may be 0xff as an invalid data in the credential saving area. The 0xff area would be reused.