From 506bc832b0384d6aa0efa57b46e96c3947c9a622 Mon Sep 17 00:00:00 2001 From: Hieromon Ikasamo Date: Tue, 15 Oct 2019 14:34:31 +0900 Subject: [PATCH] Added a description for static IP configuration --- mkdocs/changelog.md | 3 ++ mkdocs/credit.md | 84 ++++++++++++++++++++------------- mkdocs/faq.md | 7 +++ mkdocs/gettingstarted.md | 3 ++ mkdocs/images/process_begin.svg | 69 +++++++++++++++++++-------- mkdocs/menu.md | 10 +++- 6 files changed, 124 insertions(+), 52 deletions(-) diff --git a/mkdocs/changelog.md b/mkdocs/changelog.md index 8300cf5..25a35b4 100644 --- a/mkdocs/changelog.md +++ b/mkdocs/changelog.md @@ -1,3 +1,6 @@ +#### [1.1.0] Oct. 15, 2019 +- Supports static IPs with the [**Configure new AP**](menu.md#configure-new-ap) menu. + #### [1.0.3] Sept. 30, 2019 - Fixed a return of AutoConnectCredential::entries(). diff --git a/mkdocs/credit.md b/mkdocs/credit.md index 53a4ed3..10d8b26 100644 --- a/mkdocs/credit.md +++ b/mkdocs/credit.md @@ -79,43 +79,43 @@ Returns number of entries as contained credentials. #### load ```cpp -int8_t load(const char* ssid, struct station_config* config) +int8_t load(const char* ssid, station_config_t* config) ``` Load a credential entry and store to **config**.
**Parameters**
ssidSSID to be loaded.
-
configstation_config
+
configstation_config_t
**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.
+
Save the specified SSID's credential entry to station_config_t pointed to by the parameter as **config**. -1 is returned if the SSID is not saved.
#### load ```cpp -bool load(int8_t entry, struct station_config* config) +bool load(int8_t entry, station_config_t* config) ``` Load a credential entry and store to **config**.
**Parameters**
entrySpecifies the index number based 0 to be loaded.
-
configstation_config
+
configstation_config_t
**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 the specified credential entry to station_config_t 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) +bool save(const station_config_t* config) ``` Save a credential entry.
**Parameter**
-
configstation_config to be saved.
+
configstation_config_t to be saved.
**Return value**
trueSuccessfully saved.
falseFailed to save.
@@ -142,7 +142,7 @@ Delete a credential the specified SSID. ```cpp void deleteAllCredentials(void) { AutoConnectCredential credential; - struct station_config config; + station_config_t config; uint8_t ent = credential.entries(); while (ent--) { @@ -154,24 +154,31 @@ Delete a credential the specified SSID. ## The data structures -### station_config +### station_config_t -A structure is included in the ESP8266 SDK. You can use it in the sketch like as follows: +The saved credential structure is defined as stato_config_t in the AcutoConnectCredential header file. ```cpp -extern "C" { -#include -} +typedef struct { + uint8_t ssid[32]; + uint8_t password[64]; + uint8_t bssid[6]; + uint8_t dhcp; /**< 0:DHCP, 1:Static IP */ + union _config { + uint32_t addr[5]; + struct _sta { + uint32_t ip; + uint32_t gateway; + uint32_t netmask; + uint32_t dns1; + uint32_t dns2; + } sta; + } config; +} station_config_t; ``` -```cpp -struct station_config { - uint8 ssid[32]; - uint8 password[64]; - uint8 bssid_set; - uint8 bssid[6]; -}; -``` +!!! note "The byte size of station_config_t in program memory and stored credentials is different" + There is a gap byte for boundary alignment between the `dhcp` member and the static IP members of the above station_config_t. Its gap byte will be removed with saved credentials on the flash. ### The credential entry @@ -180,13 +187,26 @@ A data structure of the credential saving area in EEPROM as the below. [^4] [^4]: There may be 0xff as an invalid data in the credential saving area. The 0xff area would be reused. -| Byte offset | Length | Value | -|-------------|----------|---------------------------------------------------------------------| -| 0 | 8 | AC_CREDT | -| 8 | 1 | Number of contained entries (uint8_t) | -| 9 | 2 | Container size, excluding size of AC_CREDT and size of the number of entries(width for uint16_t type). | -| 11 | variable | SSID terminated by 0x00. Max length is 32 bytes. | -| variable | variable | Password plain text terminated by 0x00. Max length is 64 bytes. | -| variable | 6 | BSSID | -| variable | | Contained the next entries. (Continuation SSID+Password+BSSID) | -| variable | 1 | 0x00. End of container. | +| byte offset | Length | Value | +|------------- |--------|-------| +| 0 | 8 | AC_CREDT | +| 8 | 1 | Number of contained entries (uint8_t) | +| 9 | 2 | Container size, excluding size of AC_CREDT and size of the number of entries(width for uint16_t type). | +| 11 | variable | SSID terminated by 0x00. Max length is 32 bytes. | +| variable | variable | Password plain text terminated by 0x00. Max length is 64 bytes. | +| variable | 6 | BSSID | +| variable | 1 | Flag for DHCP or Static IP (0:DHCP, 1:Static IP) | +| The following IP address entries are stored only for static IPs. +| variable(1) | 4 | Station IP address (uint32_t) | +| variable(5) | 4 | Gateway address (uint32_t) | +| variable(9) | 4 | Netmask (uint32_t) | +| variable(13) | 4 | Primary DNS address (uint32_t) | +| variable(17) | 4 | Secondary IP address (uint32_t) | +| variable | variable | Contained the next entries. (Continuation SSID+Password+BSSID+DHCP flag+Static IPs(if exists)) | +| variable | 1 | 0x00. End of container. | + +!!! note "AutoConnectCredential has changed" + It was lost AutoConnectCredential backward compatibility. Credentials saved by AutoConnect v1.0.3 (or earlier) will not work properly with AutoConnect v1.1.0. You need to erase the flash of the ESP module using the esptool before the sketch uploading. + ``` + esptool -c esp8266 (or esp32) - p [COM_PORT] erase_flash + ``` diff --git a/mkdocs/faq.md b/mkdocs/faq.md index 32dab11..96cd9ac 100644 --- a/mkdocs/faq.md +++ b/mkdocs/faq.md @@ -180,6 +180,13 @@ Because AutoConnect does not send a login success response to the captive portal If the sketch is correct, a JSON syntax error may have occurred. In this case, activate the [AC_DEBUG](faq.md#3-turn-on-the-debug-log-options) and rerun. If you take the message of JSON syntax error, the [Json Assistant](https://arduinojson.org/v5/assistant/) helps syntax checking. This online tool is provided by the author of ArduinoJson and is most consistent for the AutoConnect. +## Saved credentials are wrong or lost. + +A structure of AutoConnect saved credentials have changed in two times throughout enhancement with v1.0.3 and v1.1.0. Especially in v1.1.0 enhancements, there is no backward compatibility of AutoConnectCredential structures to the earlier versions. To save the credentials correctly in v110, you must erase the flash of the ESP module using the esptool completely. +``` +esptool -c esp8266 (or esp32) -p [COM_PORT] erase_flash +``` + ## Submit element in a custom Web page does not react. Is there the AutoConnectElements element named **SUBMIT** in the custom Web page? (case sensitive ignored) AutoConnect does not rely on the `input type=submit` element for the form submission and uses [HTML form element submit](https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/submit) function instead. So, the submit function will fail if there is an element named 'submit' in the form. You can not use **SUBMIT** as the element name of AutoConnectElements in a custom Web page that declares the AutoConnectSubmit element. diff --git a/mkdocs/gettingstarted.md b/mkdocs/gettingstarted.md index 038085b..ff6a13a 100644 --- a/mkdocs/gettingstarted.md +++ b/mkdocs/gettingstarted.md @@ -50,6 +50,9 @@ Here, tap *"Configure new AP"* to connect the new access point then the SSID con +!!! info "Can be configured with static IP" + Since v1.1.0, [**Configure new AP**](menu.md#configure-new-ap) menu can configure for WIFI_STA with static IP. + ### Connection establishment After connection established, the current status screen will appear. It is already connected to WLAN with WiFi mode as WIFI\_AP\_STA and the IP connection status is displayed there including the SSID. Then at this screen, you have two options for the next step. diff --git a/mkdocs/images/process_begin.svg b/mkdocs/images/process_begin.svg index ab1e19a..b9224a9 100644 --- a/mkdocs/images/process_begin.svg +++ b/mkdocs/images/process_begin.svg @@ -9,9 +9,9 @@ xmlns="http://www.w3.org/2000/svg" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - width="99.499031mm" + width="109mm" height="371.83472mm" - viewBox="0 0 99.499031 371.83471" + viewBox="0 0 108.99999 371.83472" version="1.1" id="svg8776" inkscape:version="0.92.2 (5c3e80d, 2017-08-06)" @@ -248,8 +248,8 @@ inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:zoom="1.4142136" - inkscape:cx="182.89588" - inkscape:cy="1285.7123" + inkscape:cx="259.43725" + inkscape:cy="1200.0696" inkscape:document-units="mm" inkscape:current-layer="layer1" showgrid="false" @@ -264,11 +264,11 @@ inkscape:bbox-nodes="true" inkscape:snap-bbox-edge-midpoints="true" inkscape:snap-bbox-midpoints="true" - inkscape:window-width="1920" - inkscape:window-height="1029" - inkscape:window-x="1272" - inkscape:window-y="-8" - inkscape:window-maximized="1" + inkscape:window-width="1571" + inkscape:window-height="1013" + inkscape:window-x="1376" + inkscape:window-y="0" + inkscape:window-maximized="0" fit-margin-top="0" fit-margin-left="0" fit-margin-right="0" @@ -277,7 +277,7 @@ type="xygrid" id="grid9104" originx="-23.664512" - originy="15.544299" /> + originy="15.544259" /> @@ -295,7 +295,7 @@ inkscape:label="レイヤー 1" inkscape:groupmode="layer" id="layer1" - transform="translate(-23.664512,59.290408)"> + transform="translate(-23.664512,59.290411)"> WiFi.config (STA) + id="g1141"> Load current config + x="42.740284" + y="-30.225767">Load current config YES + Loads saved credentials from the flashthat matches the last SSID stored inthe ESP module. + If that credential has a static IP,restore it. diff --git a/mkdocs/menu.md b/mkdocs/menu.md index f1a10fa..151e8de 100644 --- a/mkdocs/menu.md +++ b/mkdocs/menu.md @@ -29,7 +29,9 @@ Enter SSID and Passphrase and tap "**Apply**" to starts WiFi connection. -If you want to configure with static IP, uncheck "**Enable DHCP**". Once the WiFi connection is established, the entered static IP configuration is saved in the credentials and restored to the station configuration via the [Open SSIDs](#open-ssids) menu. +If you want to configure with static IP, uncheck "**Enable DHCP**". Once the WiFi connection is established, the entered static IP[^1] configuration is saved in the credentials and restored to the station configuration via the [Open SSIDs](#open-ssids) menu. + +[^1]: AutoConnect will not check the syntax and validity of the entered IP address. If the entered static IPs are incorrect, it cannot connect to the access point. @@ -39,6 +41,12 @@ Once it was established WiFi connection, its SSID and password will be saved in +!!! note "Saved credentials data structure has changed" + A structure of AutoConnect saved credentials have changed in v1.1.0 and was lost backward compatibility. Credentials saved by AutoConnect v1.0.3 (or earlier) will not display properly with AutoConnect v1.1.0. You need to erase the flash of the ESP module using the esptool before the sketch uploading. + ``` + esptool -c esp8266 (or esp32) - p [COM_PORT] erase_flash + ``` + ## Disconnect Disconnect ESP8266/ESP32 from the current connection. It can also reset the ESP8266/ESP32 automatically after disconnection by instructing with using [API](api.md#autoreset) in the sketch.