From 8eda9af6989c3986989c6fcddf78a6deb8966a1c Mon Sep 17 00:00:00 2001 From: Hieromon Ikasamo Date: Mon, 23 Mar 2020 01:58:02 +0900 Subject: [PATCH] Supports lower RSSI limit. --- mkdocs/advancedusage.md | 13 +-- mkdocs/images/process_begin.svg | 142 ++++++++++++++++---------------- mkdocs/lsbegin.md | 8 +- 3 files changed, 83 insertions(+), 80 deletions(-) diff --git a/mkdocs/advancedusage.md b/mkdocs/advancedusage.md index eaf802a..0426239 100644 --- a/mkdocs/advancedusage.md +++ b/mkdocs/advancedusage.md @@ -14,11 +14,11 @@ AutoConnect stores the established WiFi connection in the flash of the ESP8266/E ### Automatic reconnect -When the captive portal is started, SoftAP starts and the STA is disconnected. The current SSID setting memorized in ESP8266 will be lost but then the reconnect behavior of ESP32 is somewhat different from this. +AutoConnect changes WIFI mode depending on the situation. The [AutoConnect::begin](lsbegin.md) function starts WIFI in STA mode and starts the webserver if the connection is successful by the 1st-WiFi.begin. But if the connection fails with the least recently established access point, AutoConnect will switch the WIFI mode to AP_STA and starts the DNS server to be able to launch a captive portal. -The [*WiFiSTAClass::disconnect*](https://github.com/espressif/arduino-esp32/blob/a0f0bd930cfd2d607bf3d3288f46e2d265dd2e11/libraries/WiFi/src/WiFiSTA.h#L46) function implemented in the arduino-esp32 has extended parameters than the ESP8266's arduino-core. The second parameter of WiFi.disconnect on the arduino-esp32 core that does not exist in the [ESP8266WiFiSTAClass](https://github.com/esp8266/Arduino/blob/7e1bdb225da8ab337373517e6a86a99432921a86/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp#L296) has the effect of deleting the currently connected WiFi configuration and its default value is "false". On the ESP32 platform, even if WiFi.disconnect is executed, WiFi.begin() without the parameters in the next turn will try to connect to that AP. That is, automatic reconnection is implemented in arduino-esp32 already. Although this behavior appears seemingly competent, it is rather a disadvantage in scenes where you want to change the access point each time. When explicitly disconnecting WiFi from the Disconnect menu, AutoConnect will erase the AP connection settings saved by arduino-esp32 core. AutoConnect's automatic reconnection is a mechanism independent from the automatic reconnection of the arduino-esp32 core. +When the captive portal is started, SoftAP starts and the STA is disconnected. At this point, the station configuration information that the ESP module has stored on its own (it is known as the SDK's [station_config](https://github.com/esp8266/Arduino/blob/db75d2c448bfccc6dc308bdeb9fbd3efca7927ff/tools/sdk/include/user_interface.h#L249) structure) is discarded. -If the [**autoReconnect**](apiconfig.md#autoreconnect) option of the [AutoConnectConfig](apiconfig.md) class is enabled, it automatically attempts to reconnect to the disconnected past access point. When the autoReconnect option is specified, AutoConnect will not start SoftAP immediately if the first WiFi.begin fails. It will scan WiFi signal and the same connection information as the detected BSSID is stored in the flash as AutoConnect's credentials, explicitly apply it with WiFi.begin and rerun. +AutoConnect can connect to an access point again using saved credential that has disconnected once, and its control is allowed by [**autoReconnect**](apiconfig.md#autoreconnect). [*AutoConnectConfig::autoReconnect*](apiconfig.md#autoreconnect) option specifies to attempt to reconnect to the past established access point that stored in saved credentials. AutoConnect does not start SoftAP immediately even if 1st-WiFi.begin fails when the [**autoReconnct**](apiconfig.md#autoreconnect) is enabled. It will scan the WiFi signal, and if the same BSSID as the detected BSSID is stored in flash as AutoConnect credentials, explicitly apply it and reruns WiFi.begin still WIFI_STA mode. (The autoReconnect works effectively even if the SSID is a hidden access point) ```cpp hl_lines="3" AutoConnect Portal; @@ -28,10 +28,11 @@ Portal.config(Config); Portal.begin(); ``` -An autoReconnect option is available to *AutoConnect::begin* without SSID and pass Passphrase. +An [**autoRecconect**](apiconfig.md#autoreconnect) option is only available for [*AutoConnect::begin*](api.md#begin) without SSID and PASSWORD parameter. -!!! caution "An autoReconnect will work if SSID detection succeeded" - An autoReconnect will not effect if the SSID which stored credential to be connected is a hidden access point. +!!! note "An autoReconnect is not autoreconnect" + The [*WiFiSTAClass::disconnect*](https://github.com/espressif/arduino-esp32/blob/a0f0bd930cfd2d607bf3d3288f46e2d265dd2e11/libraries/WiFi/src/WiFiSTA.h#L46) function implemented in the arduino-esp32 has extended parameters than the ESP8266's arduino-core. The second parameter of WiFi.disconnect on the arduino-esp32 core that does not exist in the [ESP8266WiFiSTAClass](https://github.com/esp8266/Arduino/blob/7e1bdb225da8ab337373517e6a86a99432921a86/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp#L296) has the effect of deleting the currently connected WiFi configuration and its default value is "false". On the ESP32 platform, even if WiFi.disconnect is executed, WiFi.begin() without the parameters in the next turn will try to connect to that AP. That is, automatic reconnection is implemented in arduino-esp32 already. Although this behavior appears seemingly competent, it is rather a disadvantage in scenes where you want to change the access point each time. When explicitly disconnecting WiFi from the Disconnect menu, AutoConnect will erase the AP connection settings saved by the arduino-esp32 core. AutoConnect's automatic reconnection is a mechanism independent from the automatic reconnection of the arduino-esp32 core. + ### Autosave Credential diff --git a/mkdocs/images/process_begin.svg b/mkdocs/images/process_begin.svg index b9224a9..acef36c 100644 --- a/mkdocs/images/process_begin.svg +++ b/mkdocs/images/process_begin.svg @@ -9,12 +9,12 @@ 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="109mm" + width="104.57415mm" height="371.83472mm" - viewBox="0 0 108.99999 371.83472" + viewBox="0 0 104.57414 371.83472" version="1.1" id="svg8776" - inkscape:version="0.92.2 (5c3e80d, 2017-08-06)" + inkscape:version="0.92.4 (5da689c313, 2019-01-14)" sodipodi:docname="process_begin.svg"> @@ -248,8 +248,8 @@ inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:zoom="1.4142136" - inkscape:cx="259.43725" - inkscape:cy="1200.0696" + inkscape:cx="305.90966" + inkscape:cy="637.13379" inkscape:document-units="mm" inkscape:current-layer="layer1" showgrid="false" @@ -261,23 +261,24 @@ inkscape:snap-smooth-nodes="true" inkscape:snap-midpoints="false" inkscape:bbox-paths="true" - inkscape:bbox-nodes="true" + inkscape:bbox-nodes="false" inkscape:snap-bbox-edge-midpoints="true" inkscape:snap-bbox-midpoints="true" - inkscape:window-width="1571" + inkscape:window-width="1920" inkscape:window-height="1013" - inkscape:window-x="1376" - inkscape:window-y="0" - inkscape:window-maximized="0" + inkscape:window-x="2551" + inkscape:window-y="-9" + inkscape:window-maximized="1" fit-margin-top="0" fit-margin-left="0" fit-margin-right="0" - fit-margin-bottom="0"> + fit-margin-bottom="0" + showguides="true"> + originx="-23.664533" + originy="15.544253" /> @@ -295,10 +296,10 @@ inkscape:label="レイヤー 1" inkscape:groupmode="layer" id="layer1" - transform="translate(-23.664512,59.290411)"> + transform="translate(-23.664535,59.290408)"> @@ -939,24 +940,24 @@ YES NO + transform="translate(-25.135403,-186.53117)"> + transform="translate(-0.22278483,28.641187)"> WiFi.config (STA) + id="g1141" + transform="translate(0,15.879204)"> + transform="translate(-30.682548,2.7829924)"> + transform="translate(-37.753577,18.181876)"> @@ -1374,55 +1376,55 @@ 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: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" x="35.828152" - y="-18.166817" + y="-2.2876122" id="text10760-5-3">NO YES Loads saved credentials from the flashLoads saved credentials from the flashthat matches the last SSID stored inthat matches the last SSID stored inthe ESP module. + x="79.343994" + y="-10.161308">the ESP module. If that credential has a static IP,If that credential has a static IP,restore it. + x="79.354843" + y="2.408726">restore it. diff --git a/mkdocs/lsbegin.md b/mkdocs/lsbegin.md index 0c63726..5c70dec 100644 --- a/mkdocs/lsbegin.md +++ b/mkdocs/lsbegin.md @@ -1,17 +1,17 @@ ## AutoConnect::begin logic sequence -Several parameters as follows of [AutoConnectConfig](apiconfig.md) affect the behavior of [AutoConnect::begin](api.md#begin) function. Each parameter affects the behaves in interacted order with the priority and apply to the logic sequence of [AutoConnect::begin](api.md#begin). +The following parameters of [AutoConnectConfig](apiconfig.md) affect the behavior of [AutoConnect::begin](api.md#begin) function and control a logic sequence. They are also evaluated on a case-by-case basis and may not be valid in all situations. The sketch must consider the role of these parameters and the conditions under which they will work as intended. You need to understand what happens when using these parameters in combination. -- [immediateStart](apiconfig.md#immediatestart) : The captive portal start immediately, without first WiFi.begin. +- [immediateStart](apiconfig.md#immediatestart) : The captive portal start immediately, without the 1st-WiFi.begin. - [autoReconenct](apiconfig.md#autoreconnect) : Attempt re-connect with past SSID by saved credential. - [portalTimeout](apiconfig.md#portaltimeout) : Time out limit for the portal. - [retainPortal](apiconfig.md#retainportal) : Keep DNS server functioning for the captive portal. -You can use these parameters in combination with sketch requirements and need to understand correctly the behavior caused by the parameters. The following chart shows the AutoConnect::begin logic sequence including the effect of these parameters. +The following chart shows the AutoConnect::begin logic sequence that contains the control flow with each parameter takes effect. -For example, [AutoConnect::begin](api.md#begin) will not exits without the [**portalTimeout**](apiconfig.md#portaltimeout) while the connection not establishes, but WebServer will start to work. A DNS server that detects the probe of the captive portal is also effective. So, your sketch may work seemingly, but it will close with inside a loop of the [AutoConnect::begin](api.md#begin) function. Especially when invoking [AutoConnect::begin](api.md#begin) in the **setup()**, execution control does not pass to the **loop()**. +For example, [AutoConnect::begin](api.md#begin) will not end without the [**portalTimeout**](apiconfig.md#portaltimeout) while the connection not establishes, but WebServer will start to work. And the DNS server also will start to make the captive portal detection to the client. The custom web page now responds correctly with the behavior of the two internally launched servers, and the sketch looks like working. But AutoConnect::begin does not end yet. Especially when invoking AutoConnect::begin in the **setup()**, control flow does not pass to the **loop()**. As different scenes, you may use the [**immediateStart**](apiconfig.md#immediatestart) effectively. Equipped the external switch to activate the captive portal with the ESP module, combined with the [**portalTime**](apiconfig.md#portaltimeout) and the [**retainPortal**](apiconfig.md#retainportal) it will become WiFi active connection feature. You can start [AutoConnect::begin](api.md#begin) at any point in the **loop()**, which allows your sketch can behave both the offline mode and the online mode.