Added a description for static IP configuration

pull/137/head
Hieromon Ikasamo 5 years ago
parent cb2a8f4972
commit 506bc832b0
  1. 3
      mkdocs/changelog.md
  2. 70
      mkdocs/credit.md
  3. 7
      mkdocs/faq.md
  4. 3
      mkdocs/gettingstarted.md
  5. 69
      mkdocs/images/process_begin.svg
  6. 10
      mkdocs/menu.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().

@ -79,43 +79,43 @@ Returns number of entries as contained credentials.
#### <i class="fa fa-caret-right"></i> 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**.
<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>
<dd><span class="apidef">config</span><span class="apidesc">station_config_t</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>
<dd>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. </dd>
</dl>
#### <i class="fa fa-caret-right"></i> 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**.
<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>
<dd><span class="apidef">config</span><span class="apidesc">station_config_t</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>
<dd>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. </dd>
</dl>
#### <i class="fa fa-caret-right"></i> save
```cpp
bool save(const struct station_config* config)
bool save(const station_config_t* config)
```
Save a credential entry.
<dl class="apidl">
<dt>**Parameter**</dt>
<dd><span class="apidef">config</span><span class="apidesc">station_config to be saved.</span></dd>
<dd><span class="apidef">config</span><span class="apidesc">station_config_t 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>
@ -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
### <i class="fa fa-code"></i> station_config
### <i class="fa fa-code"></i> 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 <user_interface.h>
}
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.
### <i class="fa fa-code"></i> 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 |
|-------------|----------|---------------------------------------------------------------------|
| 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 | Flag for DHCP or Static IP (0:DHCP, 1:Static IP) |
| <td colspan=3>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
```

@ -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.
## <i class="fa fa-question-circle"></i> 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
```
## <i class="fa fa-question-circle"></i> 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.

@ -50,6 +50,9 @@ Here, tap *"Configure new AP"* to connect the new access point then the SSID con
<img src="images/menu_login.png" style="border:1px solid lightgrey;width:280px;" /><img src="images/arrow_right.svg" style="vertical-align:top;padding-top:120px;width:48px;margin-left:30px;margin-right:30px;" /><img src="images/config_ssid.png" style="border:1px solid lightgrey;width:280px;" />
!!! 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.
### <i class="fa fa-rss"></i> 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.

@ -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" />
</sodipodi:namedview>
<metadata
id="metadata8773">
@ -295,7 +295,7 @@
inkscape:label="レイヤー 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-23.664512,59.290408)">
transform="translate(-23.664512,59.290411)">
<path
style="fill:none;stroke:#000000;stroke-width:0.26458341px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 58.208337,-11.256129 v 3.8405916"
@ -1265,27 +1265,26 @@
sodipodi:role="line">WiFi.config (STA)</tspan></text>
</g>
<g
id="g1187"
transform="translate(-46.605488,-48.241008)">
id="g1141">
<rect
ry="0.26458257"
rx="0.26458332"
y="13.168248"
x="87.615906"
y="-35.072762"
x="41.010418"
height="7.9375019"
width="34.395828"
id="rect9134-4-7-4-7-57"
style="opacity:0.66000001;vector-effect:none;fill:#e7f3ff;fill-opacity:1;stroke:#000000;stroke-width:0.26458329;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:stroke markers fill" />
<text
id="text9138-7-3-9-9-90"
y="18.015242"
x="89.345772"
y="-30.225767"
x="42.740284"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.17499995px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332"
xml:space="preserve"><tspan
id="tspan1182"
sodipodi:role="line"
x="89.345772"
y="18.015242">Load current config</tspan></text>
x="42.740284"
y="-30.225767">Load current config</tspan></text>
</g>
<path
style="fill:none;stroke:#000000;stroke-width:0.26458341px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
@ -1393,5 +1392,37 @@
x="60.096973"
y="-8.7963543"
style="stroke-width:0.26458332">YES</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.17499995px;line-height:1.25;font-family:'Times New Roman';-inkscape-font-specification:'Times New Roman, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332"
x="79.585876"
y="-32.471371"
id="text9138-7-3-9-9-90-9"><tspan
sodipodi:role="line"
id="tspan1283"
x="79.585876"
y="-32.471371">Loads saved credentials from the flash</tspan><tspan
sodipodi:role="line"
id="tspan1285"
x="79.585876"
y="-28.502621">that matches the last SSID stored in</tspan><tspan
sodipodi:role="line"
id="tspan1287"
x="79.585876"
y="-24.533871">the ESP module. </tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.17499995px;line-height:1.25;font-family:serif;-inkscape-font-specification:'serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332"
x="79.543159"
y="-14.876924"
id="text9138-7-3-9-9-90-9-7"><tspan
sodipodi:role="line"
id="tspan1289"
x="79.543159"
y="-14.876924">If that credential has a static IP,</tspan><tspan
sodipodi:role="line"
id="tspan1291"
x="79.543159"
y="-10.908174">restore it.</tspan></text>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 72 KiB

After

Width:  |  Height:  |  Size: 74 KiB

@ -29,7 +29,9 @@ Enter SSID and Passphrase and tap "**Apply**" to starts WiFi connection.
<img src="images/newap.png" style="border-style:solid;border-width:1px;border-color:lightgrey;width:280px;" />
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.
<img src="images/newap_static.png" style="border-style:solid;border-width:1px;border-color:lightgrey;width:280px;" />
@ -39,6 +41,12 @@ Once it was established WiFi connection, its SSID and password will be saved in
<img src="images/open.png" style="border-style:solid;border-width:1px;border-color:lightgrey;width:280px;" />
!!! 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
```
## <i class="fa fa-bars"></i> 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.

Loading…
Cancel
Save