@ -68,6 +68,9 @@ Full documentation is available on https://Hieromon.github.io/AutoConnect, some
## Change log
## Change log
### [0.9.4] May 5, 2018.
- Supports AutoConnectConfig::autoReconnect option, it will scan the WLAN when it can not connect to the default SSID, apply the applicable credentials if it is saved, and try reconnecting.
<p>Registering the "not found" handler is a different way than ESP8266WebServer. The <em>onNotFound</em> of ESP8266WebServer does not work with AutoConnect. AutoConnect overrides <em>ESP8266WebServer::onNotFound</em> to handle a captive portal. To register "not found" handler, use <ahref="../api/index.html#onnotfound"><em>AutoConnect::onNotFound</em></a>.</p>
<p>Registering the "not found" handler is a different way than ESP8266WebServer. The <em>onNotFound</em> of ESP8266WebServer does not work with AutoConnect. AutoConnect overrides <em>ESP8266WebServer::onNotFound</em> to handle a captive portal. To register "not found" handler, use <ahref="../api/index.html#onnotfound"><em>AutoConnect::onNotFound</em></a>.</p>
<p>When the captive portal is started, SoftAP starts and the STA is disconnected. The current SSID setting memorized in ESP8266 will be lost.<br/>
If the <ahref="../api/index.html#autoreconnect"><strong>autoReconnect</strong></a> option of the <ahref="../api/index.html#autoconnectconfig-api"><strong>AutoConnectConfig</strong></a> 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 EEPROM as AutoConnect's credentials, explicitly apply it with WiFi.begin and rerun.</p>
<p>An autoReconnect option is available to <em>AutoConnect::begin</em> without SSID and pass passphrase.</p>
<h3id="auto-save-credential"><iclass="fa fa-caret-right"></i> Auto save Credential<aclass="headerlink"href="#auto-save-credential"title="Permanent link">¶</a></h3>
<h3id="auto-save-credential"><iclass="fa fa-caret-right"></i> Auto save Credential<aclass="headerlink"href="#auto-save-credential"title="Permanent link">¶</a></h3>
<p>By default, AutoConnect saves the credentials of the established connection in EEPROM. You can disable it with the <ahref="../api/index.html#autosave"><strong>autoSave</strong></a> parameter specified by <ahref="../api/index.html#autoconnectconfig"><strong>AutoConnectConfig</strong></a>.</p>
<p>By default, AutoConnect saves the credentials of the established connection in EEPROM. You can disable it with the <ahref="../api/index.html#autosave"><strong>autoSave</strong></a> parameter specified by <ahref="../api/index.html#autoconnectconfig"><strong>AutoConnectConfig</strong></a>.</p>
<p>Process the AutoConnect menu interface. It will be processed the client request too contained in the user sketch handler by calling the host <em>handleClient::ESP8266WebServer</em> from the Autoconnect internally.</p>
<p>Process the AutoConnect menu interface. It will be processed the client request too contained in the user sketch handler by calling from inside of AutoConnect to the hosted<em>ESP8266WebServer::handleClient</em>.</p>
<p>Automatically reconnect to past established access point (BSSID) when the current configured SSID in ESP8266 could not be connected. By enabling this option, <em>AutoConnect::begin()</em> function will attempt to reconnect to a known access point using credentials stored in the EEPROM, even if the connection failed by current SSID.<br/>
If the connection fails, starts the captive portal in SoftAP + STA mode.<br/>
<dd><spanclass="apidef"style="width:230px;">false</span>Starts Captive Portal in SoftAP + STA mode without trying to reconnect. This is the default.</dd>
</dl></p>
<p>When the autoReconnect option is enabled, an automatic connection will behave if the following conditions are satisfied.</p>
<ul>
<li>Invokes <em>AutoConnect::begin</em> without user name and password parameter as <codeclass="codehilite">begin()</code>.</li>
<li>If one of the saved BSSIDs (not the SSID) of the credentials matches the BSSID detected by the network scan.</li>
<p>Reset ESP8266 module automatically after WLAN disconnected.
<p>Reset ESP8266 module automatically after WLAN disconnected.
<dlclass="apidl">
<dlclass="apidl">
@ -1395,6 +1424,7 @@ The default value is 0.
<spanclass="n">Config</span><spanclass="p">.</span><spanclass="n">apip</span><spanclass="o">=</span><spanclass="nf">IPAddress</span><spanclass="p">(</span><spanclass="mi">192</span><spanclass="p">,</span><spanclass="mi">168</span><spanclass="p">,</span><spanclass="mi">10</span><spanclass="p">,</span><spanclass="mi">101</span><spanclass="p">);</span><spanclass="c1">// Sets SoftAP IP address</span>
<spanclass="n">Config</span><spanclass="p">.</span><spanclass="n">apip</span><spanclass="o">=</span><spanclass="nf">IPAddress</span><spanclass="p">(</span><spanclass="mi">192</span><spanclass="p">,</span><spanclass="mi">168</span><spanclass="p">,</span><spanclass="mi">10</span><spanclass="p">,</span><spanclass="mi">101</span><spanclass="p">);</span><spanclass="c1">// Sets SoftAP IP address</span>
<spanclass="n">Config</span><spanclass="p">.</span><spanclass="n">gateway</span><spanclass="o">=</span><spanclass="nf">IPAddress</span><spanclass="p">(</span><spanclass="mi">192</span><spanclass="p">,</span><spanclass="mi">168</span><spanclass="p">,</span><spanclass="mi">10</span><spanclass="p">,</span><spanclass="mi">1</span><spanclass="p">);</span><spanclass="c1">// Sets WLAN router IP address</span>
<spanclass="n">Config</span><spanclass="p">.</span><spanclass="n">gateway</span><spanclass="o">=</span><spanclass="nf">IPAddress</span><spanclass="p">(</span><spanclass="mi">192</span><spanclass="p">,</span><spanclass="mi">168</span><spanclass="p">,</span><spanclass="mi">10</span><spanclass="p">,</span><spanclass="mi">1</span><spanclass="p">);</span><spanclass="c1">// Sets WLAN router IP address</span>
<spanclass="n">Config</span><spanclass="p">.</span><spanclass="n">autoSave</span><spanclass="o">=</span><spanclass="n">AC_SAVECREDENTIAL_NEVER</span><spanclass="p">;</span><spanclass="c1">// No save credential</span>
<spanclass="n">Config</span><spanclass="p">.</span><spanclass="n">autoSave</span><spanclass="o">=</span><spanclass="n">AC_SAVECREDENTIAL_NEVER</span><spanclass="p">;</span><spanclass="c1">// No save credential</span>
<spanclass="n">COnfig</span><spanclass="p">.</span><spanclass="n">boundaryOffet</span><spanclass="o">=</span><spanclass="mi">64</span><spanclass="p">;</span><spanclass="c1">// Reserve 64 bytes for the user data in EEPROM. </span>
<spanclass="n">COnfig</span><spanclass="p">.</span><spanclass="n">boundaryOffet</span><spanclass="o">=</span><spanclass="mi">64</span><spanclass="p">;</span><spanclass="c1">// Reserve 64 bytes for the user data in EEPROM. </span>
<spanclass="n">Config</span><spanclass="p">.</span><spanclass="n">homeUri</span><spanclass="o">=</span><spanclass="s">"/index.html"</span><spanclass="c1">// Sets home path of the sketch application</span>
<spanclass="n">Config</span><spanclass="p">.</span><spanclass="n">homeUri</span><spanclass="o">=</span><spanclass="s">"/index.html"</span><spanclass="c1">// Sets home path of the sketch application</span>
<labelclass="md-nav__title"for="toc">Table of contents</label>
<labelclass="md-nav__title"for="toc">Table of contents</label>
<ulclass="md-nav__list"data-md-scrollfix>
<ulclass="md-nav__list"data-md-scrollfix>
<liclass="md-nav__item">
<ahref="#094-may-5-2018"title="[0.9.4] May 5, 2018."class="md-nav__link">
[0.9.4] May 5, 2018.
</a>
</li>
<liclass="md-nav__item">
<liclass="md-nav__item">
<ahref="#093-march-23-2018"title="[0.9.3] March 23, 2018."class="md-nav__link">
<ahref="#093-march-23-2018"title="[0.9.3] March 23, 2018."class="md-nav__link">
[0.9.3] March 23, 2018.
[0.9.3] March 23, 2018.
@ -462,6 +469,13 @@
<labelclass="md-nav__title"for="toc">Table of contents</label>
<labelclass="md-nav__title"for="toc">Table of contents</label>
<ulclass="md-nav__list"data-md-scrollfix>
<ulclass="md-nav__list"data-md-scrollfix>
<liclass="md-nav__item">
<ahref="#094-may-5-2018"title="[0.9.4] May 5, 2018."class="md-nav__link">
[0.9.4] May 5, 2018.
</a>
</li>
<liclass="md-nav__item">
<liclass="md-nav__item">
<ahref="#093-march-23-2018"title="[0.9.3] March 23, 2018."class="md-nav__link">
<ahref="#093-march-23-2018"title="[0.9.3] March 23, 2018."class="md-nav__link">
[0.9.3] March 23, 2018.
[0.9.3] March 23, 2018.
@ -502,7 +516,11 @@
<h1>Change log</h1>
<h1>Change log</h1>
<h4id="093-march-23-2018">[0.9.3] March 23, 2018.<aclass="headerlink"href="#093-march-23-2018"title="Permanent link">¶</a></h4>
<h4id="094-may-5-2018">[0.9.4] May 5, 2018.<aclass="headerlink"href="#094-may-5-2018"title="Permanent link">¶</a></h4>
<ul>
<li>Supports AutoConnectConfig::autoReconnect option, it will scan the WLAN when it can not connect to the default SSID, apply the applicable credentials if it is saved, and try reconnecting.</li>
</ul>
<h4id="093-march-23-2018">[0.9.3] March 23, 2018.<aclass="headerlink"href="#093-march-23-2018"title="Permanent link">¶</a></h4>
Registering the "not found" handler is a different way than ESP8266WebServer. The *onNotFound* of ESP8266WebServer does not work with AutoConnect. AutoConnect overrides *ESP8266WebServer::onNotFound* to handle a captive portal. To register "not found" handler, use [*AutoConnect::onNotFound*](api.md#onnotfound).
Registering the "not found" handler is a different way than ESP8266WebServer. The *onNotFound* of ESP8266WebServer does not work with AutoConnect. AutoConnect overrides *ESP8266WebServer::onNotFound* to handle a captive portal. To register "not found" handler, use [*AutoConnect::onNotFound*](api.md#onnotfound).
When the captive portal is started, SoftAP starts and the STA is disconnected. The current SSID setting memorized in ESP8266 will be lost.
If the [**autoReconnect**](api.md#autoreconnect) option of the [**AutoConnectConfig**](api.md#autoconnectconfig-api) 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 EEPROM as AutoConnect's credentials, explicitly apply it with WiFi.begin and rerun.
```arduino hl_lines="3"
AutoConnect Portal;
AutoConnectConfig Config;
Config.autoReconnect = true;
Portal.config(Config);
Portal.begin();
```
An autoReconnect option is available to *AutoConnect::begin* without SSID and pass passphrase.
### <iclass="fa fa-caret-right"></i> Auto save Credential
### <iclass="fa fa-caret-right"></i> Auto save Credential
By default, AutoConnect saves the credentials of the established connection in EEPROM. You can disable it with the [**autoSave**](api.md#autosave) parameter specified by [**AutoConnectConfig**](api.md#autoconnectconfig).
By default, AutoConnect saves the credentials of the established connection in EEPROM. You can disable it with the [**autoSave**](api.md#autosave) parameter specified by [**AutoConnectConfig**](api.md#autoconnectconfig).
Process the AutoConnect menu interface. It will be processed the client request too contained in the user sketch handler by calling the host *handleClient::ESP8266WebServer* from the Autoconnect internally.
Process the AutoConnect menu interface. It will be processed the client request too contained in the user sketch handler by calling from inside of AutoConnect to the hosted*ESP8266WebServer::handleClient*.
#### handleRequest
#### handleRequest
@ -232,6 +232,23 @@ Sets IP address for Soft AP in captive portal. When AutoConnect fails the initia
<dd><spanclass="apidef"style="width:230px;">IPAddress</span>The default value is **192.168.244.1**</dd>
<dd><spanclass="apidef"style="width:230px;">IPAddress</span>The default value is **192.168.244.1**</dd>
</dl>
</dl>
#### autoReconnect
Automatically reconnect to past established access point (BSSID) when the current configured SSID in ESP8266 could not be connected. By enabling this option, *AutoConnect::begin()* function will attempt to reconnect to a known access point using credentials stored in the EEPROM, even if the connection failed by current SSID.
If the connection fails, starts the captive portal in SoftAP + STA mode.
<dd><spanclass="apidef"style="width:230px;">false</span>Starts Captive Portal in SoftAP + STA mode without trying to reconnect. This is the default.</dd>
</dl>
When the autoReconnect option is enabled, an automatic connection will behave if the following conditions are satisfied.
- Invokes *AutoConnect::begin* without user name and password parameter as ```begin()```.
- If one of the saved BSSIDs (not the SSID) of the credentials matches the BSSID detected by the network scan.
#### autoReset
#### autoReset
Reset ESP8266 module automatically after WLAN disconnected.
Reset ESP8266 module automatically after WLAN disconnected.
@ -382,6 +399,7 @@ Config.apid = ESP.hostname(); // Retrieve host name to SotAp ide
Config.apip = IPAddress(192,168,10,101); // Sets SoftAP IP address
Config.apip = IPAddress(192,168,10,101); // Sets SoftAP IP address
Config.gateway = IPAddress(192,168,10,1); // Sets WLAN router IP address
Config.gateway = IPAddress(192,168,10,1); // Sets WLAN router IP address
- Supports AutoConnectConfig::autoReconnect option, it will scan the WLAN when it can not connect to the default SSID, apply the applicable credentials if it is saved, and try reconnecting.