Changed a structure of documents

pull/8/head
Hieromon Ikasamo 6 years ago
parent b24220edb2
commit 896f69c541
  1. 51
      docs/404.html
  2. 399
      docs/advancedusage/index.html
  3. 56
      docs/api/index.html
  4. 903
      docs/basicusage/index.html
  5. 51
      docs/examples/index.html
  6. 57
      docs/faq/index.html
  7. 51
      docs/gettingstarted/index.html
  8. 51
      docs/index.html
  9. 51
      docs/license/index.html
  10. 55
      docs/menu/index.html
  11. 79
      docs/search/search_index.json
  12. 26
      docs/sitemap.xml
  13. 4
      mkdocs.yml
  14. 106
      mkdocs/advancedusage.md
  15. 106
      mkdocs/basicusage.md
  16. 4
      mkdocs/faq.md

@ -212,6 +212,17 @@
<li class="md-tabs__item">
<a href="/AutoConnect/basicusage/index.html" title="Usage the library" class="md-tabs__link">
Usage the library
</a>
</li>
@ -307,12 +318,48 @@
<li class="md-nav__item">
<a href="/AutoConnect/usage/index.html" title="Usage the library" class="md-nav__link">
<li class="md-nav__item md-nav__item--nested">
<input class="md-toggle md-nav__toggle" data-md-toggle="nav-4" type="checkbox" id="nav-4">
<label class="md-nav__link" for="nav-4">
Usage the library
</label>
<nav class="md-nav" data-md-component="collapsible" data-md-level="1">
<label class="md-nav__title" for="nav-4">
Usage the library
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="/AutoConnect/basicusage/index.html" title="Basic usage" class="md-nav__link">
Basic usage
</a>
</li>
<li class="md-nav__item">
<a href="/AutoConnect/advancedusage/index.html" title="Advanced usage" class="md-nav__link">
Advanced usage
</a>
</li>
</ul>
</nav>
</li>

@ -13,7 +13,7 @@
<meta name="description" content="ESP8266 WLAN configuration at run time with web interface">
<link rel="canonical" href="https://Hieromon.github.io/AutoConnect/usage/index.html">
<link rel="canonical" href="https://Hieromon.github.io/AutoConnect/advancedusage/index.html">
<meta name="author" content="Hieromon Ikasamo">
@ -42,7 +42,7 @@
<title>Usage the library - AutoConnect for ESP8266</title>
<title>Advanced usage - AutoConnect for ESP8266</title>
@ -101,7 +101,7 @@
<input class="md-toggle" data-md-toggle="search" type="checkbox" id="search">
<label class="md-overlay" data-md-component="overlay" for="drawer"></label>
<a href="#simple-usage" tabindex="1" class="md-skip">
<a href="#advanced-usage" tabindex="1" class="md-skip">
Skip to content
</a>
@ -127,7 +127,7 @@
AutoConnect for ESP8266
</span>
<span class="md-header-nav__topic">
Usage the library
Advanced usage
</span>
@ -199,14 +199,16 @@
<nav class="md-tabs" data-md-component="tabs">
<nav class="md-tabs md-tabs--active" data-md-component="tabs">
<div class="md-tabs__inner md-grid">
<ul class="md-tabs__list">
<li class="md-tabs__item">
<a href="../index.html" title="Overview" class="md-tabs__link md-tabs__link--active">
<a href="../index.html" title="Overview" class="md-tabs__link">
Overview
</a>
@ -218,6 +220,17 @@
<li class="md-tabs__item">
<a href="../basicusage/index.html" title="Usage the library" class="md-tabs__link md-tabs__link--active">
Usage the library
</a>
</li>
@ -315,17 +328,50 @@
<li class="md-nav__item md-nav__item--active md-nav__item--nested">
<input class="md-toggle md-nav__toggle" data-md-toggle="nav-4" type="checkbox" id="nav-4" checked>
<label class="md-nav__link" for="nav-4">
Usage the library
</label>
<nav class="md-nav" data-md-component="collapsible" data-md-level="1">
<label class="md-nav__title" for="nav-4">
Usage the library
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../basicusage/index.html" title="Basic usage" class="md-nav__link">
Basic usage
</a>
</li>
<li class="md-nav__item md-nav__item--active">
<input class="md-toggle md-nav__toggle" data-md-toggle="toc" type="checkbox" id="toc">
<label class="md-nav__link md-nav__link--active" for="toc">
Usage the library
Advanced usage
</label>
<a href="index.html" title="Usage the library" class="md-nav__link md-nav__link--active">
Usage the library
<a href="index.html" title="Advanced usage" class="md-nav__link md-nav__link--active">
Advanced usage
</a>
@ -336,108 +382,6 @@
<label class="md-nav__title" for="toc">Table of contents</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="#simple-usage" title="Simple usage" class="md-nav__link">
Simple usage
</a>
<nav class="md-nav">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#embed-to-the-sketches" title=" Embed to the sketches" class="md-nav__link">
Embed to the sketches
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#basic-usage" title="Basic usage" class="md-nav__link">
Basic usage
</a>
<nav class="md-nav">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#basic-logic-sequence-for-the-user-sketches" title=" Basic logic sequence for the user sketches" class="md-nav__link">
Basic logic sequence for the user sketches
</a>
<nav class="md-nav">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#1-a-typical-logic-sequence" title="1. A typical logic sequence" class="md-nav__link">
1. A typical logic sequence
</a>
</li>
<li class="md-nav__item">
<a href="#2-declare-autoconnect-object" title="2. Declare AutoConnect object" class="md-nav__link">
2. Declare AutoConnect object
</a>
</li>
<li class="md-nav__item">
<a href="#3-no-need-wifibegin" title="3. No need WiFI.begin(...)" class="md-nav__link">
3. No need WiFI.begin(...)
</a>
</li>
<li class="md-nav__item">
<a href="#4-alternate-esp8266webserverbegin" title="4. Alternate ESP8266WebServer::begin()" class="md-nav__link">
4. Alternate ESP8266WebServer::begin()
</a>
</li>
<li class="md-nav__item">
<a href="#5-autoconnectbegin-with-ssid-and-password" title="5. AutoConnect::begin with SSID and Password" class="md-nav__link">
5. AutoConnect::begin with SSID and Password
</a>
</li>
<li class="md-nav__item">
<a href="#6-use-esp8266webserveron-to-handle-url" title="6. Use ESP8266WebServer::on to handle URL" class="md-nav__link">
6. Use ESP8266WebServer::on to handle URL
</a>
</li>
<li class="md-nav__item">
<a href="#7-use-either-esp8266webserverhandleclient-or-autoconnecthandleclient" title="7. Use either ESP8266WebServer::handleClient() or AutoConnect::handleClient()" class="md-nav__link">
7. Use either ESP8266WebServer::handleClient() or AutoConnect::handleClient()
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#esp8266webserver-hosted-or-parasitic" title=" ESP8266WebServer hosted or parasitic" class="md-nav__link">
ESP8266WebServer hosted or parasitic
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#advanced-usage" title="Advanced usage" class="md-nav__link">
Advanced usage
@ -565,6 +509,11 @@
</li>
</ul>
</nav>
</li>
@ -632,108 +581,6 @@
<label class="md-nav__title" for="toc">Table of contents</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="#simple-usage" title="Simple usage" class="md-nav__link">
Simple usage
</a>
<nav class="md-nav">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#embed-to-the-sketches" title=" Embed to the sketches" class="md-nav__link">
Embed to the sketches
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#basic-usage" title="Basic usage" class="md-nav__link">
Basic usage
</a>
<nav class="md-nav">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#basic-logic-sequence-for-the-user-sketches" title=" Basic logic sequence for the user sketches" class="md-nav__link">
Basic logic sequence for the user sketches
</a>
<nav class="md-nav">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#1-a-typical-logic-sequence" title="1. A typical logic sequence" class="md-nav__link">
1. A typical logic sequence
</a>
</li>
<li class="md-nav__item">
<a href="#2-declare-autoconnect-object" title="2. Declare AutoConnect object" class="md-nav__link">
2. Declare AutoConnect object
</a>
</li>
<li class="md-nav__item">
<a href="#3-no-need-wifibegin" title="3. No need WiFI.begin(...)" class="md-nav__link">
3. No need WiFI.begin(...)
</a>
</li>
<li class="md-nav__item">
<a href="#4-alternate-esp8266webserverbegin" title="4. Alternate ESP8266WebServer::begin()" class="md-nav__link">
4. Alternate ESP8266WebServer::begin()
</a>
</li>
<li class="md-nav__item">
<a href="#5-autoconnectbegin-with-ssid-and-password" title="5. AutoConnect::begin with SSID and Password" class="md-nav__link">
5. AutoConnect::begin with SSID and Password
</a>
</li>
<li class="md-nav__item">
<a href="#6-use-esp8266webserveron-to-handle-url" title="6. Use ESP8266WebServer::on to handle URL" class="md-nav__link">
6. Use ESP8266WebServer::on to handle URL
</a>
</li>
<li class="md-nav__item">
<a href="#7-use-either-esp8266webserverhandleclient-or-autoconnecthandleclient" title="7. Use either ESP8266WebServer::handleClient() or AutoConnect::handleClient()" class="md-nav__link">
7. Use either ESP8266WebServer::handleClient() or AutoConnect::handleClient()
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#esp8266webserver-hosted-or-parasitic" title=" ESP8266WebServer hosted or parasitic" class="md-nav__link">
ESP8266WebServer hosted or parasitic
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#advanced-usage" title="Advanced usage" class="md-nav__link">
Advanced usage
@ -868,112 +715,9 @@
<h1>Usage the library</h1>
<h1>Advanced usage</h1>
<h2 id="simple-usage">Simple usage<a class="headerlink" href="#simple-usage" title="Permanent link">&para;</a></h2>
<h3 id="embed-to-the-sketches"><i class="fa fa-edit"></i> Embed to the sketches<a class="headerlink" href="#embed-to-the-sketches" title="Permanent link">&para;</a></h3>
<p>How embed the AutoConnect to the sketches you have. Most simple approach to applying AutoConnect for the existing sketches, follow the below steps.</p>
<p><img src="../images/BeforeAfter.svg" /></p>
<ul class="ulsty-edit" style="list-style:none;">
<li>Insert <code class="codehilite"><span class="cp">#include</span> <span class="cpf">&lt;AutoConnect.h&gt;</span></code> to behind of <code class="codehilite"><span class="cp">#include</span> <span class="cpf">&lt;ESP8266WebServer.h&gt;</span></code>.</li>
<li>Insert <code class="codehilite"><span class="na">AutoConnect</span> <em>PORTAL(WEBSERVER);</em></code> to behind of <code class="codehilite"><span class="na">ESP8266WebServer</span> <em>WEBSERVER;</em></code> declaration.<sup id="fnref:1"><a class="footnote-ref" href="#fn:1" rel="footnote">1</a></sup></li>
<li>Remove <code class="codehilite">WiFi.<span class="na">begin</span>(<em>SSID</em>,<em>PSK</em>)</code> and the subsequent logic for the connection status check.</li>
<li>Replace <code class="codehilite"><em>WEBSERVER</em>.<span class="na">begin</span><span class="p">()</span></code> to <code class="codehilite"><em>PORTAL</em>.<span class="na">begin</span><span class="p">()</span></code>.<sup id="fnref:2"><a class="footnote-ref" href="#fn:2" rel="footnote">2</a></sup></li>
<li>Replace <code class="codehilite"><em>WEBSERVER</em>.<span class="na">handleClient</span><span class="p">()</span></code> to <code class="codehilite"><em>PORTAL</em>.<span class="na">handleClient</span><span class="p">()</span></code>.<sup id="fnref:3"><a class="footnote-ref" href="#fn:3" rel="footnote">3</a></sup></li>
<li>If the connection checks logic is needed, you can check the return value according to <code class="codehilite"><em>PORTAL</em>.<span class="na">begin</span><span class="p">()</span></code> with <code class="codehilite">true</code> or <code class="codehilite">false</code>.</li>
</ul>
<h2 id="basic-usage">Basic usage<a class="headerlink" href="#basic-usage" title="Permanent link">&para;</a></h2>
<h3 id="basic-logic-sequence-for-the-user-sketches"><i class="fa fa-caret-right"></i> Basic logic sequence for the user sketches<a class="headerlink" href="#basic-logic-sequence-for-the-user-sketches" title="Permanent link">&para;</a></h3>
<h4 id="1-a-typical-logic-sequence">1. A typical logic sequence<a class="headerlink" href="#1-a-typical-logic-sequence" title="Permanent link">&para;</a></h4>
<div class="admonition note">
<ol>
<li><strong>Include headers,</strong> <code class="codehilite">ESP8266WebServer.h</code> and <code class="codehilite">AutoConnect.h</code> </li>
<li><strong>Declare ESP8266WebServer variable.</strong> </li>
<li><strong>Declare AutoConnect variable.</strong> </li>
<li><strong>Implements the URL handler <em>function()</em>.</strong> </li>
<li><strong>setup()</strong><br />
5.1 <strong>Sets URL handler <em>function()</em> to ESP8266WebServer by</strong><code class="codehilite">ESP8266WebServer::on</code><strong>.</strong><br />
5.2 <strong>Starts </strong><code class="codehilite">AutoConnect::begin()</code><strong>.</strong><br />
5.3 <strong>Check connection status.</strong> </li>
<li><strong>loop()</strong><br />
6.1 <strong>Invokes </strong><code class="codehilite">AutoConnect::handleClient()</code><strong>,<br>or invokes </strong><code class="codehilite">ESP8266WebServer::handleClient()</code><strong> then </strong><code class="codehilite">AutoConnect::handleRequest()</code><strong>.</strong><br />
6.2 <strong>Do the process for actual sketch.</strong> </li>
</ol>
</div>
<h4 id="2-declare-autoconnect-object">2. Declare AutoConnect object<a class="headerlink" href="#2-declare-autoconnect-object" title="Permanent link">&para;</a></h4>
<p><a href="#esp8266webserver-hosted-or-parasitic">Two options</a> are available for <a href="../api/index.html#constructors">AutoConnect constructor</a>.</p>
<p><div class="codehilite"><pre><span></span><span class="n">AutoConnect</span> <span class="nf">VARIABLE</span><span class="p">(</span><span class="o">&amp;</span><span class="n">ESP8266WebServer</span><span class="p">);</span>
</pre></div>
or</p>
<div class="codehilite"><pre><span></span><span class="n">AutoConnect</span> <span class="n">VARIABLE</span><span class="p">;</span>
</pre></div>
<ul>
<li>
<p><strong>Parameter with ESP8266WebServer variable:</strong> An ESP8266WebServer object variable must be declared in the sketch. AutoConnect uses its variable for handling the <a href="../menu/index.html">AutoConnect menu</a>.</p>
</li>
<li>
<p><strong>With no parameter:</strong> The sketch does not declare ESP8266WebServer object. In this case, AutoConnect allocates an instance of the ESP8266WebServer internally and the logic sequence of the sketch is somewhat different as the above. To register a URL handler function by <em>ESP8266WebServer::on</em> should be performed after <a href="../api/index.html#begin"><em>AutoConnect::begin</em></a>.</p>
</li>
</ul>
<h4 id="3-no-need-wifibegin">3. No need WiFI.begin(...)<a class="headerlink" href="#3-no-need-wifibegin" title="Permanent link">&para;</a></h4>
<p>AutoConnect performs <em>WiFi.begin</em> for establishing a connection with WLAN internally. There is no need for a general process to establish a connection with <em>WiFi.begin</em> in a sketch.</p>
<h4 id="4-alternate-esp8266webserverbegin">4. Alternate ESP8266WebServer::begin()<a class="headerlink" href="#4-alternate-esp8266webserverbegin" title="Permanent link">&para;</a></h4>
<p><a href="../api/index.html#begin"><em>AutoConnect::begin</em></a> internally executes <em>ESP8266WebServer::begin</em> too and it starts DNS server to behave as a captive portal. So the sketch does not need to call <em>ESP8266WebServer::begin</em>.</p>
<div class="admonition info">
<p class="admonition-title">Why DNS Server Starts</p>
<p>AutoConnect traps the detection of captive portals and directs them to the AutoConnect menu to achieve a connection with the WLAN interactively. In order to trap, it temporarily responds SoftAP address to all DNS queries. When the connection with the WLAN is successfully established, the DNS server will stop.</p>
</div>
<h4 id="5-autoconnectbegin-with-ssid-and-password">5. AutoConnect::begin with SSID and Password<a class="headerlink" href="#5-autoconnectbegin-with-ssid-and-password" title="Permanent link">&para;</a></h4>
<p>SSID and Password can also specify by <a href="../api.me#begin"><em>AutoConnect::begin</em></a>. ESP8266 uses provided SSID and Password explicitly. If the connection false with specified SSID with Password then a captive portal is activated. SSID and Password are not present, ESP8266 SDK will attempt to connect using the still effectual SSID and password. Usually, it succeeds.</p>
<h4 id="6-use-esp8266webserveron-to-handle-url">6. Use ESP8266WebServer::on to handle URL<a class="headerlink" href="#6-use-esp8266webserveron-to-handle-url" title="Permanent link">&para;</a></h4>
<p>AutoConnect is designed to coexist with the process for handling the web pages by user sketches. The page processing function which will send an HTML to the client invoked by the "<em>on::ESP8266WebServer</em>" function is the same as when using ESP8266WebServer natively.</p>
<h4 id="7-use-either-esp8266webserverhandleclient-or-autoconnecthandleclient">7. Use either ESP8266WebServer::handleClient() or AutoConnect::handleClient()<a class="headerlink" href="#7-use-either-esp8266webserverhandleclient-or-autoconnecthandleclient" title="Permanent link">&para;</a></h4>
<p>Both classes member function name is the same: <em>handleClient</em>, but behavior is different. Using the AutoConnect embedded along with ESP8266WebServer::handleClient has limitations. Refer to the below section for details. </p>
<h3 id="esp8266webserver-hosted-or-parasitic"><i class="fa fa-caret-right"></i> ESP8266WebServer hosted or parasitic<a class="headerlink" href="#esp8266webserver-hosted-or-parasitic" title="Permanent link">&para;</a></h3>
<p>The interoperable process with an ESP8266WebServer depends on the parameters of the <a href="../api/index.html#constructors">AutoConnect constructor</a>.</p>
<table>
<thead>
<tr>
<th>Declaration parameter</th>
<th>Use ESP8266WebServer::handleClient</th>
<th>Use AutoConnect::handleClient</th>
</tr>
</thead>
<tbody>
<tr>
<td>None</td>
<td>AutoConnect menu not available.<br>host() is needed.</td>
<td>AutoConnect menu available.<br>host() is needed.</td>
</tr>
<tr>
<td>Reference to ESP8266WebServer</td>
<td>AutoConnect menu not available.<br>host() not necessary.</td>
<td>AutoConnect menu available.<br>host() not necessary.</td>
</tr>
</tbody>
</table>
<ul>
<li>
<p><strong>By declaration for the AutoConnect variable with no parameter</strong>: The ESP8266WebServer instance is hosted by AutoConnect automatically then the sketches use <a href="../api/index.html#host"><em>AutoConnect::host</em></a> as API to get it after <a href="../api/index.html#begin"><em>AutoConnect::begin</em></a> performed.</p>
</li>
<li>
<p><strong>By declaration for the AutoConnect variable with the reference of ESP8266WebServer</strong>: AutoConnect will use it. The sketch can use it is too.</p>
</li>
<li>
<p><strong>In use ESP8266WebServer::handleClient()</strong>: AutoConnect menu can be dispatched but not works normally. It is necessary to call <a href="../api/index.html#void-handlerequest"><em>AutoConnect::handleRequest</em></a> after <em>ESP8255WebServer::handleClient</em> invoking.</p>
</li>
<li>
<p><strong>In use <a href="../api/index.html#void-handleclient">AutoConnect::handleClient()</a></strong>: The handleClient() process and the AutoConnect menu is available without calling <em>ESP8266WebServer::handleClient</em>.</p>
</li>
</ul>
<div class="admonition info">
<p class="admonition-title">Why AutoConnect::handleRequest is needed when using ESP8266::handleClient</p>
<p>The AutoConnect menu function may affect WiFi connection state. It follows that the menu process must execute outside <em>ESP8266WebServer::handleClient</em>.<br />
<a href="../api/index.html#void-handleclient"><em>AutoConnect::handleClient</em></a> is equivalent <em>ESP8266WebServer::handleClient</em> included <a href="../api/index.html#void-handlerequest"><em>AutoConnect::handleRequest</em></a>.</p>
</div>
<h2 id="advanced-usage">Advanced usage<a class="headerlink" href="#advanced-usage" title="Permanent link">&para;</a></h2>
<h2 id="advanced-usage">Advanced usage<a class="headerlink" href="#advanced-usage" title="Permanent link">&para;</a></h2>
<h3 id="404-handler"><i class="fa fa-caret-right"></i> 404 handler<a class="headerlink" href="#404-handler" title="Permanent link">&para;</a></h3>
<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 <a href="../api/index.html#onnotfound"><em>AutoConnect::onNotFound</em></a>.</p>
<h3 id="auto-save-credential"><i class="fa fa-caret-right"></i> Auto save Credential<a class="headerlink" href="#auto-save-credential" title="Permanent link">&para;</a></h3>
@ -1155,21 +899,6 @@ or</p>
<p>A home path of AutoConnect is <strong>_ac</strong> by default. You can access from the browser with http://IPADDRESS/_ac. You can change the home path by revising <a href="https://github.com/Hieromon/AutoConnect/blob/master/src/AutoConnect.h#L58"><strong>AUTOCONNECT_URI</strong></a> macro in the include header file as <a href="https://github.com/Hieromon/AutoConnect/blob/master/src/AutoConnect.h">AutoConnect.h</a>.</p>
<div class="codehilite"><pre><span></span><span class="cp">#define AUTOCONNECT_URI &quot;/_ac&quot;</span>
</pre></div>
<div class="footnote">
<hr />
<ol>
<li id="fn:1">
<p>Each <em>VARIABLE</em> conforms to the actual declaration in the sketches.&#160;<a class="footnote-backref" href="#fnref:1" rev="footnote" title="Jump back to footnote 1 in the text">&#8617;</a></p>
</li>
<li id="fn:2">
<p>WiFi SSID and Password can be specified AutoConnect::begin() too.&#160;<a class="footnote-backref" href="#fnref:2" rev="footnote" title="Jump back to footnote 2 in the text">&#8617;</a></p>
</li>
<li id="fn:3">
<p>Replacement the <strong>handleClient</strong> method is not indispensable. AutoConnect can still connect with the captive portal as it is ESP8266WebServer::handleClient. But it can <strong>not valid AutoConnect menu</strong>.&#160;<a class="footnote-backref" href="#fnref:3" rev="footnote" title="Jump back to footnote 3 in the text">&#8617;</a></p>
</li>
</ol>
</div>
@ -1188,7 +917,7 @@ or</p>
<div class="md-footer-nav">
<nav class="md-footer-nav__inner md-grid">
<a href="../menu/index.html" title="AutoConnect menu" class="md-flex md-footer-nav__link md-footer-nav__link--prev" rel="prev">
<a href="../basicusage/index.html" title="Basic usage" class="md-flex md-footer-nav__link md-footer-nav__link--prev" rel="prev">
<div class="md-flex__cell md-flex__cell--shrink">
<i class="md-icon md-icon--arrow-back md-footer-nav__button"></i>
</div>
@ -1197,7 +926,7 @@ or</p>
<span class="md-footer-nav__direction">
Previous
</span>
AutoConnect menu
Basic usage
</span>
</div>
</a>

@ -218,6 +218,17 @@
<li class="md-tabs__item">
<a href="../basicusage/index.html" title="Usage the library" class="md-tabs__link">
Usage the library
</a>
</li>
@ -313,12 +324,48 @@
<li class="md-nav__item">
<a href="../usage/index.html" title="Usage the library" class="md-nav__link">
<li class="md-nav__item md-nav__item--nested">
<input class="md-toggle md-nav__toggle" data-md-toggle="nav-4" type="checkbox" id="nav-4">
<label class="md-nav__link" for="nav-4">
Usage the library
</label>
<nav class="md-nav" data-md-component="collapsible" data-md-level="1">
<label class="md-nav__title" for="nav-4">
Usage the library
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../basicusage/index.html" title="Basic usage" class="md-nav__link">
Basic usage
</a>
</li>
<li class="md-nav__item">
<a href="../advancedusage/index.html" title="Advanced usage" class="md-nav__link">
Advanced usage
</a>
</li>
</ul>
</nav>
</li>
@ -1016,6 +1063,7 @@
<span class="cp">#define AUTOCONNECT_AP_GW 0x01F4A8C0 </span><span class="c1">// Default SoftAP Gateway IP</span>
<span class="cp">#define AUTOCONNECT_AP_NM 0x00FFFFFF </span><span class="c1">// Default subnet mask</span>
<span class="cp">#define AUTOCONNECT_DNSPORT 53 </span><span class="c1">// Default DNS port at captive portal</span>
<span class="cp">#define AUTOCONNECT_HTTPPORT 80 </span><span class="c1">// Default HTTP</span>
<span class="cp">#define AUTOCONNECT_MENU_TITLE &quot;AutoConnect&quot; </span><span class="c1">// Default AutoConnect menu title</span>
<span class="cp">#define AUTOCONNECT_STARTUPTIME 10 </span><span class="c1">// Default waiting time[s] for after reset</span>
<span class="cp">#define AUTOCONNECT_URI &quot;/_ac&quot; </span><span class="c1">// Default AutoConnect root path</span>
@ -1309,7 +1357,7 @@ The default value is 0.
<div class="md-footer-nav">
<nav class="md-footer-nav__inner md-grid">
<a href="../usage/index.html" title="Usage the library" class="md-flex md-footer-nav__link md-footer-nav__link--prev" rel="prev">
<a href="../advancedusage/index.html" title="Advanced usage" class="md-flex md-footer-nav__link md-footer-nav__link--prev" rel="prev">
<div class="md-flex__cell md-flex__cell--shrink">
<i class="md-icon md-icon--arrow-back md-footer-nav__button"></i>
</div>
@ -1318,7 +1366,7 @@ The default value is 0.
<span class="md-footer-nav__direction">
Previous
</span>
Usage the library
Advanced usage
</span>
</div>
</a>

@ -0,0 +1,903 @@
<!DOCTYPE html>
<html lang="en" class="no-js">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="description" content="ESP8266 WLAN configuration at run time with web interface">
<link rel="canonical" href="https://Hieromon.github.io/AutoConnect/basicusage/index.html">
<meta name="author" content="Hieromon Ikasamo">
<meta name="lang:clipboard.copy" content="Copy to clipboard">
<meta name="lang:clipboard.copied" content="Copied to clipboard">
<meta name="lang:search.language" content="en">
<meta name="lang:search.pipeline.stopwords" content="True">
<meta name="lang:search.pipeline.trimmer" content="True">
<meta name="lang:search.result.none" content="No matching documents">
<meta name="lang:search.result.one" content="1 matching document">
<meta name="lang:search.result.other" content="# matching documents">
<meta name="lang:search.tokenizer" content="[\s\-]+">
<link rel="shortcut icon" href="../assets/images/favicon.png">
<meta name="generator" content="mkdocs-0.17.3, mkdocs-material-2.7.0">
<title>Basic usage - AutoConnect for ESP8266</title>
<link rel="stylesheet" href="../assets/stylesheets/application.78aab2dc.css">
<link rel="stylesheet" href="../assets/stylesheets/application-palette.6079476c.css">
<script src="../assets/javascripts/modernizr.1aa3b519.js"></script>
<link href="https://fonts.gstatic.com" rel="preconnect" crossorigin>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,400i,700|Roboto+Mono">
<style>body,input{font-family:"Roboto","Helvetica Neue",Helvetica,Arial,sans-serif}code,kbd,pre{font-family:"Roboto Mono","Courier New",Courier,monospace}</style>
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="../css/paragraph.css">
</head>
<body dir="ltr" data-md-color-primary="indigo" data-md-color-accent="indigo">
<svg class="md-svg">
<defs>
<svg xmlns="http://www.w3.org/2000/svg" width="416" height="448"
viewBox="0 0 416 448" id="github">
<path fill="currentColor" d="M160 304q0 10-3.125 20.5t-10.75 19-18.125
8.5-18.125-8.5-10.75-19-3.125-20.5 3.125-20.5 10.75-19 18.125-8.5
18.125 8.5 10.75 19 3.125 20.5zM320 304q0 10-3.125 20.5t-10.75
19-18.125 8.5-18.125-8.5-10.75-19-3.125-20.5 3.125-20.5 10.75-19
18.125-8.5 18.125 8.5 10.75 19 3.125 20.5zM360
304q0-30-17.25-51t-46.75-21q-10.25 0-48.75 5.25-17.75 2.75-39.25
2.75t-39.25-2.75q-38-5.25-48.75-5.25-29.5 0-46.75 21t-17.25 51q0 22 8
38.375t20.25 25.75 30.5 15 35 7.375 37.25 1.75h42q20.5 0
37.25-1.75t35-7.375 30.5-15 20.25-25.75 8-38.375zM416 260q0 51.75-15.25
82.75-9.5 19.25-26.375 33.25t-35.25 21.5-42.5 11.875-42.875 5.5-41.75
1.125q-19.5 0-35.5-0.75t-36.875-3.125-38.125-7.5-34.25-12.875-30.25-20.25-21.5-28.75q-15.5-30.75-15.5-82.75
0-59.25 34-99-6.75-20.5-6.75-42.5 0-29 12.75-54.5 27 0 47.5 9.875t47.25
30.875q36.75-8.75 77.25-8.75 37 0 70 8 26.25-20.5
46.75-30.25t47.25-9.75q12.75 25.5 12.75 54.5 0 21.75-6.75 42 34 40 34
99.5z" />
</svg>
</defs>
</svg>
<input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="drawer">
<input class="md-toggle" data-md-toggle="search" type="checkbox" id="search">
<label class="md-overlay" data-md-component="overlay" for="drawer"></label>
<a href="#simple-usage" tabindex="1" class="md-skip">
Skip to content
</a>
<header class="md-header" data-md-component="header">
<nav class="md-header-nav md-grid">
<div class="md-flex">
<div class="md-flex__cell md-flex__cell--shrink">
<a href="https://Hieromon.github.io/AutoConnect/" title="AutoConnect for ESP8266" class="md-header-nav__button md-logo">
<img src="../images/arduino-logo.svg" width="24" height="24">
</a>
</div>
<div class="md-flex__cell md-flex__cell--shrink">
<label class="md-icon md-icon--menu md-header-nav__button" for="drawer"></label>
</div>
<div class="md-flex__cell md-flex__cell--stretch">
<div class="md-flex__ellipsis md-header-nav__title" data-md-component="title">
<span class="md-header-nav__topic">
AutoConnect for ESP8266
</span>
<span class="md-header-nav__topic">
Basic usage
</span>
</div>
</div>
<div class="md-flex__cell md-flex__cell--shrink">
<label class="md-icon md-icon--search md-header-nav__button" for="search"></label>
<div class="md-search" data-md-component="search" role="dialog">
<label class="md-search__overlay" for="search"></label>
<div class="md-search__inner" role="search">
<form class="md-search__form" name="search">
<input type="text" class="md-search__input" name="query" placeholder="Search" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck="false" data-md-component="query" data-md-state="active">
<label class="md-icon md-search__icon" for="search"></label>
<button type="reset" class="md-icon md-search__icon" data-md-component="reset" tabindex="-1">
&#xE5CD;
</button>
</form>
<div class="md-search__output">
<div class="md-search__scrollwrap" data-md-scrollfix>
<div class="md-search-result" data-md-component="result">
<div class="md-search-result__meta">
Type to start searching
</div>
<ol class="md-search-result__list"></ol>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="md-flex__cell md-flex__cell--shrink">
<div class="md-header-nav__source">
<a href="https://github.com/Hieromon/AutoConnect" title="Go to repository" class="md-source" data-md-source="github">
<div class="md-source__icon">
<svg viewBox="0 0 24 24" width="24" height="24">
<use xlink:href="#github" width="24" height="24"></use>
</svg>
</div>
<div class="md-source__repository">
Hieromon/AutoConnect
</div>
</a>
</div>
</div>
</div>
</nav>
</header>
<div class="md-container">
<nav class="md-tabs md-tabs--active" data-md-component="tabs">
<div class="md-tabs__inner md-grid">
<ul class="md-tabs__list">
<li class="md-tabs__item">
<a href="../index.html" title="Overview" class="md-tabs__link">
Overview
</a>
</li>
<li class="md-tabs__item">
<a href="index.html" title="Usage the library" class="md-tabs__link md-tabs__link--active">
Usage the library
</a>
</li>
</ul>
</div>
</nav>
<main class="md-main">
<div class="md-main__inner md-grid" data-md-component="container">
<div class="md-sidebar md-sidebar--primary" data-md-component="navigation">
<div class="md-sidebar__scrollwrap">
<div class="md-sidebar__inner">
<nav class="md-nav md-nav--primary" data-md-level="0">
<label class="md-nav__title md-nav__title--site" for="drawer">
<span class="md-nav__button md-logo">
<img src="../images/arduino-logo.svg" width="48" height="48">
</span>
AutoConnect for ESP8266
</label>
<div class="md-nav__source">
<a href="https://github.com/Hieromon/AutoConnect" title="Go to repository" class="md-source" data-md-source="github">
<div class="md-source__icon">
<svg viewBox="0 0 24 24" width="24" height="24">
<use xlink:href="#github" width="24" height="24"></use>
</svg>
</div>
<div class="md-source__repository">
Hieromon/AutoConnect
</div>
</a>
</div>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../index.html" title="Overview" class="md-nav__link">
Overview
</a>
</li>
<li class="md-nav__item">
<a href="../gettingstarted/index.html" title="Getting started" class="md-nav__link">
Getting started
</a>
</li>
<li class="md-nav__item">
<a href="../menu/index.html" title="AutoConnect menu" class="md-nav__link">
AutoConnect menu
</a>
</li>
<li class="md-nav__item md-nav__item--active md-nav__item--nested">
<input class="md-toggle md-nav__toggle" data-md-toggle="nav-4" type="checkbox" id="nav-4" checked>
<label class="md-nav__link" for="nav-4">
Usage the library
</label>
<nav class="md-nav" data-md-component="collapsible" data-md-level="1">
<label class="md-nav__title" for="nav-4">
Usage the library
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item md-nav__item--active">
<input class="md-toggle md-nav__toggle" data-md-toggle="toc" type="checkbox" id="toc">
<label class="md-nav__link md-nav__link--active" for="toc">
Basic usage
</label>
<a href="index.html" title="Basic usage" class="md-nav__link md-nav__link--active">
Basic usage
</a>
<nav class="md-nav md-nav--secondary">
<label class="md-nav__title" for="toc">Table of contents</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="#simple-usage" title="Simple usage" class="md-nav__link">
Simple usage
</a>
<nav class="md-nav">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#embed-to-the-sketches" title=" Embed to the sketches" class="md-nav__link">
Embed to the sketches
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#basic-usage" title="Basic usage" class="md-nav__link">
Basic usage
</a>
<nav class="md-nav">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#basic-logic-sequence-for-the-user-sketches" title=" Basic logic sequence for the user sketches" class="md-nav__link">
Basic logic sequence for the user sketches
</a>
<nav class="md-nav">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#1-a-typical-logic-sequence" title="1. A typical logic sequence" class="md-nav__link">
1. A typical logic sequence
</a>
</li>
<li class="md-nav__item">
<a href="#2-declare-autoconnect-object" title="2. Declare AutoConnect object" class="md-nav__link">
2. Declare AutoConnect object
</a>
</li>
<li class="md-nav__item">
<a href="#3-no-need-wifibegin" title="3. No need WiFI.begin(...)" class="md-nav__link">
3. No need WiFI.begin(...)
</a>
</li>
<li class="md-nav__item">
<a href="#4-alternate-esp8266webserverbegin" title="4. Alternate ESP8266WebServer::begin()" class="md-nav__link">
4. Alternate ESP8266WebServer::begin()
</a>
</li>
<li class="md-nav__item">
<a href="#5-autoconnectbegin-with-ssid-and-password" title="5. AutoConnect::begin with SSID and Password" class="md-nav__link">
5. AutoConnect::begin with SSID and Password
</a>
</li>
<li class="md-nav__item">
<a href="#6-use-esp8266webserveron-to-handle-url" title="6. Use ESP8266WebServer::on to handle URL" class="md-nav__link">
6. Use ESP8266WebServer::on to handle URL
</a>
</li>
<li class="md-nav__item">
<a href="#7-use-either-esp8266webserverhandleclient-or-autoconnecthandleclient" title="7. Use either ESP8266WebServer::handleClient() or AutoConnect::handleClient()" class="md-nav__link">
7. Use either ESP8266WebServer::handleClient() or AutoConnect::handleClient()
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#esp8266webserver-hosted-or-parasitic" title=" ESP8266WebServer hosted or parasitic" class="md-nav__link">
ESP8266WebServer hosted or parasitic
</a>
</li>
</ul>
</nav>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="../advancedusage/index.html" title="Advanced usage" class="md-nav__link">
Advanced usage
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="../api/index.html" title="Library APIs" class="md-nav__link">
Library APIs
</a>
</li>
<li class="md-nav__item">
<a href="../examples/index.html" title="Examples" class="md-nav__link">
Examples
</a>
</li>
<li class="md-nav__item">
<a href="../faq/index.html" title="FAQ" class="md-nav__link">
FAQ
</a>
</li>
<li class="md-nav__item">
<a href="../license/index.html" title="License" class="md-nav__link">
License
</a>
</li>
</ul>
</nav>
</div>
</div>
</div>
<div class="md-sidebar md-sidebar--secondary" data-md-component="toc">
<div class="md-sidebar__scrollwrap">
<div class="md-sidebar__inner">
<nav class="md-nav md-nav--secondary">
<label class="md-nav__title" for="toc">Table of contents</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="#simple-usage" title="Simple usage" class="md-nav__link">
Simple usage
</a>
<nav class="md-nav">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#embed-to-the-sketches" title=" Embed to the sketches" class="md-nav__link">
Embed to the sketches
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#basic-usage" title="Basic usage" class="md-nav__link">
Basic usage
</a>
<nav class="md-nav">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#basic-logic-sequence-for-the-user-sketches" title=" Basic logic sequence for the user sketches" class="md-nav__link">
Basic logic sequence for the user sketches
</a>
<nav class="md-nav">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#1-a-typical-logic-sequence" title="1. A typical logic sequence" class="md-nav__link">
1. A typical logic sequence
</a>
</li>
<li class="md-nav__item">
<a href="#2-declare-autoconnect-object" title="2. Declare AutoConnect object" class="md-nav__link">
2. Declare AutoConnect object
</a>
</li>
<li class="md-nav__item">
<a href="#3-no-need-wifibegin" title="3. No need WiFI.begin(...)" class="md-nav__link">
3. No need WiFI.begin(...)
</a>
</li>
<li class="md-nav__item">
<a href="#4-alternate-esp8266webserverbegin" title="4. Alternate ESP8266WebServer::begin()" class="md-nav__link">
4. Alternate ESP8266WebServer::begin()
</a>
</li>
<li class="md-nav__item">
<a href="#5-autoconnectbegin-with-ssid-and-password" title="5. AutoConnect::begin with SSID and Password" class="md-nav__link">
5. AutoConnect::begin with SSID and Password
</a>
</li>
<li class="md-nav__item">
<a href="#6-use-esp8266webserveron-to-handle-url" title="6. Use ESP8266WebServer::on to handle URL" class="md-nav__link">
6. Use ESP8266WebServer::on to handle URL
</a>
</li>
<li class="md-nav__item">
<a href="#7-use-either-esp8266webserverhandleclient-or-autoconnecthandleclient" title="7. Use either ESP8266WebServer::handleClient() or AutoConnect::handleClient()" class="md-nav__link">
7. Use either ESP8266WebServer::handleClient() or AutoConnect::handleClient()
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#esp8266webserver-hosted-or-parasitic" title=" ESP8266WebServer hosted or parasitic" class="md-nav__link">
ESP8266WebServer hosted or parasitic
</a>
</li>
</ul>
</nav>
</li>
</ul>
</nav>
</div>
</div>
</div>
<div class="md-content">
<article class="md-content__inner md-typeset">
<h1>Basic usage</h1>
<h2 id="simple-usage">Simple usage<a class="headerlink" href="#simple-usage" title="Permanent link">&para;</a></h2>
<h3 id="embed-to-the-sketches"><i class="fa fa-edit"></i> Embed to the sketches<a class="headerlink" href="#embed-to-the-sketches" title="Permanent link">&para;</a></h3>
<p>How embed the AutoConnect to the sketches you have. Most simple approach to applying AutoConnect for the existing sketches, follow the below steps.</p>
<p><img src="../images/BeforeAfter.svg" /></p>
<ul class="ulsty-edit" style="list-style:none;">
<li>Insert <code class="codehilite"><span class="cp">#include</span> <span class="cpf">&lt;AutoConnect.h&gt;</span></code> to behind of <code class="codehilite"><span class="cp">#include</span> <span class="cpf">&lt;ESP8266WebServer.h&gt;</span></code>.</li>
<li>Insert <code class="codehilite"><span class="na">AutoConnect</span> <em>PORTAL(WEBSERVER);</em></code> to behind of <code class="codehilite"><span class="na">ESP8266WebServer</span> <em>WEBSERVER;</em></code> declaration.<sup id="fnref:1"><a class="footnote-ref" href="#fn:1" rel="footnote">1</a></sup></li>
<li>Remove <code class="codehilite">WiFi.<span class="na">begin</span>(<em>SSID</em>,<em>PSK</em>)</code> and the subsequent logic for the connection status check.</li>
<li>Replace <code class="codehilite"><em>WEBSERVER</em>.<span class="na">begin</span><span class="p">()</span></code> to <code class="codehilite"><em>PORTAL</em>.<span class="na">begin</span><span class="p">()</span></code>.<sup id="fnref:2"><a class="footnote-ref" href="#fn:2" rel="footnote">2</a></sup></li>
<li>Replace <code class="codehilite"><em>WEBSERVER</em>.<span class="na">handleClient</span><span class="p">()</span></code> to <code class="codehilite"><em>PORTAL</em>.<span class="na">handleClient</span><span class="p">()</span></code>.<sup id="fnref:3"><a class="footnote-ref" href="#fn:3" rel="footnote">3</a></sup></li>
<li>If the connection checks logic is needed, you can check the return value according to <code class="codehilite"><em>PORTAL</em>.<span class="na">begin</span><span class="p">()</span></code> with <code class="codehilite">true</code> or <code class="codehilite">false</code>.</li>
</ul>
<h2 id="basic-usage">Basic usage<a class="headerlink" href="#basic-usage" title="Permanent link">&para;</a></h2>
<h3 id="basic-logic-sequence-for-the-user-sketches"><i class="fa fa-caret-right"></i> Basic logic sequence for the user sketches<a class="headerlink" href="#basic-logic-sequence-for-the-user-sketches" title="Permanent link">&para;</a></h3>
<h4 id="1-a-typical-logic-sequence">1. A typical logic sequence<a class="headerlink" href="#1-a-typical-logic-sequence" title="Permanent link">&para;</a></h4>
<div class="admonition note">
<ol>
<li><strong>Include headers,</strong> <code class="codehilite">ESP8266WebServer.h</code> and <code class="codehilite">AutoConnect.h</code> </li>
<li><strong>Declare ESP8266WebServer variable.</strong> </li>
<li><strong>Declare AutoConnect variable.</strong> </li>
<li><strong>Implements the URL handler <em>function()</em>.</strong> </li>
<li><strong>setup()</strong><br />
5.1 <strong>Sets URL handler <em>function()</em> to ESP8266WebServer by</strong><code class="codehilite">ESP8266WebServer::on</code><strong>.</strong><br />
5.2 <strong>Starts </strong><code class="codehilite">AutoConnect::begin()</code><strong>.</strong><br />
5.3 <strong>Check connection status.</strong> </li>
<li><strong>loop()</strong><br />
6.1 <strong>Invokes </strong><code class="codehilite">AutoConnect::handleClient()</code><strong>,<br>or invokes </strong><code class="codehilite">ESP8266WebServer::handleClient()</code><strong> then </strong><code class="codehilite">AutoConnect::handleRequest()</code><strong>.</strong><br />
6.2 <strong>Do the process for actual sketch.</strong> </li>
</ol>
</div>
<h4 id="2-declare-autoconnect-object">2. Declare AutoConnect object<a class="headerlink" href="#2-declare-autoconnect-object" title="Permanent link">&para;</a></h4>
<p><a href="#esp8266webserver-hosted-or-parasitic">Two options</a> are available for <a href="../api/index.html#constructors">AutoConnect constructor</a>.</p>
<p><div class="codehilite"><pre><span></span><span class="n">AutoConnect</span> <span class="nf">VARIABLE</span><span class="p">(</span><span class="o">&amp;</span><span class="n">ESP8266WebServer</span><span class="p">);</span>
</pre></div>
or</p>
<div class="codehilite"><pre><span></span><span class="n">AutoConnect</span> <span class="n">VARIABLE</span><span class="p">;</span>
</pre></div>
<ul>
<li>
<p><strong>Parameter with ESP8266WebServer variable:</strong> An ESP8266WebServer object variable must be declared in the sketch. AutoConnect uses its variable for handling the <a href="../menu/index.html">AutoConnect menu</a>.</p>
</li>
<li>
<p><strong>With no parameter:</strong> The sketch does not declare ESP8266WebServer object. In this case, AutoConnect allocates an instance of the ESP8266WebServer internally and the logic sequence of the sketch is somewhat different as the above. To register a URL handler function by <em>ESP8266WebServer::on</em> should be performed after <a href="../api/index.html#begin"><em>AutoConnect::begin</em></a>.</p>
</li>
</ul>
<h4 id="3-no-need-wifibegin">3. No need WiFI.begin(...)<a class="headerlink" href="#3-no-need-wifibegin" title="Permanent link">&para;</a></h4>
<p>AutoConnect performs <em>WiFi.begin</em> for establishing a connection with WLAN internally. There is no need for a general process to establish a connection with <em>WiFi.begin</em> in a sketch.</p>
<h4 id="4-alternate-esp8266webserverbegin">4. Alternate ESP8266WebServer::begin()<a class="headerlink" href="#4-alternate-esp8266webserverbegin" title="Permanent link">&para;</a></h4>
<p><a href="../api/index.html#begin"><em>AutoConnect::begin</em></a> internally executes <em>ESP8266WebServer::begin</em> too and it starts DNS server to behave as a captive portal. So the sketch does not need to call <em>ESP8266WebServer::begin</em>.</p>
<div class="admonition info">
<p class="admonition-title">Why DNS Server Starts</p>
<p>AutoConnect traps the detection of captive portals and directs them to the AutoConnect menu to achieve a connection with the WLAN interactively. In order to trap, it temporarily responds SoftAP address to all DNS queries. When the connection with the WLAN is successfully established, the DNS server will stop.</p>
</div>
<h4 id="5-autoconnectbegin-with-ssid-and-password">5. AutoConnect::begin with SSID and Password<a class="headerlink" href="#5-autoconnectbegin-with-ssid-and-password" title="Permanent link">&para;</a></h4>
<p>SSID and Password can also specify by <a href="../api.me#begin"><em>AutoConnect::begin</em></a>. ESP8266 uses provided SSID and Password explicitly. If the connection false with specified SSID with Password then a captive portal is activated. SSID and Password are not present, ESP8266 SDK will attempt to connect using the still effectual SSID and password. Usually, it succeeds.</p>
<h4 id="6-use-esp8266webserveron-to-handle-url">6. Use ESP8266WebServer::on to handle URL<a class="headerlink" href="#6-use-esp8266webserveron-to-handle-url" title="Permanent link">&para;</a></h4>
<p>AutoConnect is designed to coexist with the process for handling the web pages by user sketches. The page processing function which will send an HTML to the client invoked by the "<em>on::ESP8266WebServer</em>" function is the same as when using ESP8266WebServer natively.</p>
<h4 id="7-use-either-esp8266webserverhandleclient-or-autoconnecthandleclient">7. Use either ESP8266WebServer::handleClient() or AutoConnect::handleClient()<a class="headerlink" href="#7-use-either-esp8266webserverhandleclient-or-autoconnecthandleclient" title="Permanent link">&para;</a></h4>
<p>Both classes member function name is the same: <em>handleClient</em>, but behavior is different. Using the AutoConnect embedded along with ESP8266WebServer::handleClient has limitations. Refer to the below section for details. </p>
<h3 id="esp8266webserver-hosted-or-parasitic"><i class="fa fa-caret-right"></i> ESP8266WebServer hosted or parasitic<a class="headerlink" href="#esp8266webserver-hosted-or-parasitic" title="Permanent link">&para;</a></h3>
<p>The interoperable process with an ESP8266WebServer depends on the parameters of the <a href="../api/index.html#constructors">AutoConnect constructor</a>.</p>
<table>
<thead>
<tr>
<th>Declaration parameter</th>
<th>Use ESP8266WebServer::handleClient</th>
<th>Use AutoConnect::handleClient</th>
</tr>
</thead>
<tbody>
<tr>
<td>None</td>
<td>AutoConnect menu not available.<br>host() is needed.</td>
<td>AutoConnect menu available.<br>host() is needed.</td>
</tr>
<tr>
<td>Reference to ESP8266WebServer</td>
<td>AutoConnect menu not available.<br>host() not necessary.</td>
<td>AutoConnect menu available.<br>host() not necessary.</td>
</tr>
</tbody>
</table>
<ul>
<li>
<p><strong>By declaration for the AutoConnect variable with no parameter</strong>: The ESP8266WebServer instance is hosted by AutoConnect automatically then the sketches use <a href="../api/index.html#host"><em>AutoConnect::host</em></a> as API to get it after <a href="../api/index.html#begin"><em>AutoConnect::begin</em></a> performed.</p>
</li>
<li>
<p><strong>By declaration for the AutoConnect variable with the reference of ESP8266WebServer</strong>: AutoConnect will use it. The sketch can use it is too.</p>
</li>
<li>
<p><strong>In use ESP8266WebServer::handleClient()</strong>: AutoConnect menu can be dispatched but not works normally. It is necessary to call <a href="../api/index.html#void-handlerequest"><em>AutoConnect::handleRequest</em></a> after <em>ESP8255WebServer::handleClient</em> invoking.</p>
</li>
<li>
<p><strong>In use <a href="../api/index.html#void-handleclient">AutoConnect::handleClient()</a></strong>: The handleClient() process and the AutoConnect menu is available without calling <em>ESP8266WebServer::handleClient</em>.</p>
</li>
</ul>
<div class="admonition info">
<p class="admonition-title">Why AutoConnect::handleRequest is needed when using ESP8266::handleClient</p>
<p>The AutoConnect menu function may affect WiFi connection state. It follows that the menu process must execute outside <em>ESP8266WebServer::handleClient</em>.<br />
<a href="../api/index.html#void-handleclient"><em>AutoConnect::handleClient</em></a> is equivalent <em>ESP8266WebServer::handleClient</em> included <a href="../api/index.html#void-handlerequest"><em>AutoConnect::handleRequest</em></a>.</p>
</div>
<div class="footnote">
<hr />
<ol>
<li id="fn:1">
<p>Each <em>VARIABLE</em> conforms to the actual declaration in the sketches.&#160;<a class="footnote-backref" href="#fnref:1" rev="footnote" title="Jump back to footnote 1 in the text">&#8617;</a></p>
</li>
<li id="fn:2">
<p>WiFi SSID and Password can be specified AutoConnect::begin() too.&#160;<a class="footnote-backref" href="#fnref:2" rev="footnote" title="Jump back to footnote 2 in the text">&#8617;</a></p>
</li>
<li id="fn:3">
<p>Replacement the <strong>handleClient</strong> method is not indispensable. AutoConnect can still connect with the captive portal as it is ESP8266WebServer::handleClient. But it can <strong>not valid AutoConnect menu</strong>.&#160;<a class="footnote-backref" href="#fnref:3" rev="footnote" title="Jump back to footnote 3 in the text">&#8617;</a></p>
</li>
</ol>
</div>
</article>
</div>
</div>
</main>
<footer class="md-footer">
<div class="md-footer-nav">
<nav class="md-footer-nav__inner md-grid">
<a href="../menu/index.html" title="AutoConnect menu" class="md-flex md-footer-nav__link md-footer-nav__link--prev" rel="prev">
<div class="md-flex__cell md-flex__cell--shrink">
<i class="md-icon md-icon--arrow-back md-footer-nav__button"></i>
</div>
<div class="md-flex__cell md-flex__cell--stretch md-footer-nav__title">
<span class="md-flex__ellipsis">
<span class="md-footer-nav__direction">
Previous
</span>
AutoConnect menu
</span>
</div>
</a>
<a href="../advancedusage/index.html" title="Advanced usage" class="md-flex md-footer-nav__link md-footer-nav__link--next" rel="next">
<div class="md-flex__cell md-flex__cell--stretch md-footer-nav__title">
<span class="md-flex__ellipsis">
<span class="md-footer-nav__direction">
Next
</span>
Advanced usage
</span>
</div>
<div class="md-flex__cell md-flex__cell--shrink">
<i class="md-icon md-icon--arrow-forward md-footer-nav__button"></i>
</div>
</a>
</nav>
</div>
<div class="md-footer-meta md-typeset">
<div class="md-footer-meta__inner md-grid">
<div class="md-footer-copyright">
<div class="md-footer-copyright__highlight">
Copyright &copy; 2018 Hieromon Ikasamo
</div>
powered by
<a href="http://www.mkdocs.org">MkDocs</a>
and
<a href="https://squidfunk.github.io/mkdocs-material/">
Material for MkDocs</a>
</div>
<div class="md-footer-social">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<a href="https://github.com/Hieromon" class="md-footer-social__link fa fa-github"></a>
<a href="https://twitter.com/hieromon" class="md-footer-social__link fa fa-twitter"></a>
</div>
</div>
</div>
</footer>
</div>
<script src="../assets/javascripts/application.8eb9be28.js"></script>
<script>app.initialize({version:"0.17.3",url:{base:".."}})</script>
<script src="../js/gifffer.min.js"></script>
<script>!function(e,a,t,n,o,c,i){e.GoogleAnalyticsObject=o,e.ga=e.ga||function(){(e.ga.q=e.ga.q||[]).push(arguments)},e.ga.l=1*new Date,c=a.createElement(t),i=a.getElementsByTagName(t)[0],c.async=1,c.src="https://www.google-analytics.com/analytics.js",i.parentNode.insertBefore(c,i)}(window,document,"script",0,"ga"),ga("create","None","auto"),ga("set","anonymizeIp",!0),ga("send","pageview");var links=document.getElementsByTagName("a");if(Array.prototype.map.call(links,function(e){e.host!=document.location.host&&e.addEventListener("click",function(){var a=e.getAttribute("data-md-action")||"follow";ga("send","event","outbound",a,e.href)})}),document.forms.search){var query=document.forms.search.query;query.addEventListener("blur",function(){if(this.value){var e=document.location.pathname;ga("send","pageview",e+"?q="+this.value)}})}</script>
</body>
</html>

@ -218,6 +218,17 @@
<li class="md-tabs__item">
<a href="../basicusage/index.html" title="Usage the library" class="md-tabs__link">
Usage the library
</a>
</li>
@ -313,12 +324,48 @@
<li class="md-nav__item">
<a href="../usage/index.html" title="Usage the library" class="md-nav__link">
<li class="md-nav__item md-nav__item--nested">
<input class="md-toggle md-nav__toggle" data-md-toggle="nav-4" type="checkbox" id="nav-4">
<label class="md-nav__link" for="nav-4">
Usage the library
</label>
<nav class="md-nav" data-md-component="collapsible" data-md-level="1">
<label class="md-nav__title" for="nav-4">
Usage the library
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../basicusage/index.html" title="Basic usage" class="md-nav__link">
Basic usage
</a>
</li>
<li class="md-nav__item">
<a href="../advancedusage/index.html" title="Advanced usage" class="md-nav__link">
Advanced usage
</a>
</li>
</ul>
</nav>
</li>

@ -218,6 +218,17 @@
<li class="md-tabs__item">
<a href="../basicusage/index.html" title="Usage the library" class="md-tabs__link">
Usage the library
</a>
</li>
@ -313,12 +324,48 @@
<li class="md-nav__item">
<a href="../usage/index.html" title="Usage the library" class="md-nav__link">
<li class="md-nav__item md-nav__item--nested">
<input class="md-toggle md-nav__toggle" data-md-toggle="nav-4" type="checkbox" id="nav-4">
<label class="md-nav__link" for="nav-4">
Usage the library
</label>
<nav class="md-nav" data-md-component="collapsible" data-md-level="1">
<label class="md-nav__title" for="nav-4">
Usage the library
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../basicusage/index.html" title="Basic usage" class="md-nav__link">
Basic usage
</a>
</li>
<li class="md-nav__item">
<a href="../advancedusage/index.html" title="Advanced usage" class="md-nav__link">
Advanced usage
</a>
</li>
</ul>
</nav>
</li>
@ -696,7 +743,7 @@ For AutoConnect menus to work properly, call <em>AutoConnect::handleRequest()</e
</pre></div>
<details class="hint"><summary>You can interactively check the WiFi state of ESP8266.</summary><p>Please try <a href="https://github.com/Hieromon/ESPShaker"><strong>ESPShaker</strong></a>. It is ESP8266 interactive serial command processor.</p><p><img src="../images/espshaker.gif" /></p></details><h2 id="does-not-response-from-95ac"><i class="fa fa-question-circle"></i> Does not response from _ac.<a class="headerlink" href="#does-not-response-from-95ac" title="Permanent link">&para;</a></h2>
<p>Probably <strong>WiFi.begin</strong> failed with the specified SSID. Activating the <a href="../usage/index.html#debug-print">debug printing</a> will help you to track down the cause.</p>
<p>Probably <strong>WiFi.begin</strong> failed with the specified SSID. Activating the <a href="../advancedusage/index.html#debug-print">debug printing</a> will help you to track down the cause.</p>
<h2 id="how-change-esp8266ap-for-ssid-name-in-captive-portal"><i class="fa fa-question-circle"></i> How change esp8266ap for SSID name in Captive portal?<a class="headerlink" href="#how-change-esp8266ap-for-ssid-name-in-captive-portal" title="Permanent link">&para;</a></h2>
<p>An <strong>esp8266</strong> is default SSID name for SoftAP of captive portal and password is <strong>12345678</strong>. You can change both by using <a href="../api/index.html#string-apid">AutoConnectConfig</a>.</p>
<h2 id="hang-up-after-reset"><i class="fa fa-question-circle"></i> Hang up after Reset?<a class="headerlink" href="#hang-up-after-reset" title="Permanent link">&para;</a></h2>
@ -710,7 +757,7 @@ wdt reset
<p>The correct boot mode for starting the sketch is <strong>(3, x)</strong>.</p>
<h2 id="how-erase-the-credentials-saved-in-eeprom"><i class="fa fa-question-circle"></i> How erase the credentials saved in EEPROM?<a class="headerlink" href="#how-erase-the-credentials-saved-in-eeprom" title="Permanent link">&para;</a></h2>
<p>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 <em>AutoConnectCredential</em>. The <em>AutoConnectCrendential</em> class provides the access method to the saved credential in EEPROM and library source file is including it.</p>
<p>A class description of AutoConnectCredentail is follows.</p>
<p>A class description of AutoConnectCredential is follows.</p>
<h3 id="constructor">Constructor<a class="headerlink" href="#constructor" title="Permanent link">&para;</a></h3>
<div class="codehilite"><pre><span></span><span class="cp">#include</span> <span class="cpf">&lt;AutoConnectCredential.h&gt;</span><span class="cp"></span>
@ -824,7 +871,7 @@ wdt reset
<h2 id="how-much-memory-consumption-is-autoconnect"><i class="fa fa-question-circle"></i> How much memory consumption is AutoConnect?<a class="headerlink" href="#how-much-memory-consumption-is-autoconnect" title="Permanent link">&para;</a></h2>
<h3 id="sketch-size">Sketch size<a class="headerlink" href="#sketch-size" title="Permanent link">&para;</a></h3>
<p>It increases about 57K bytes compared to the case without AutoConnect. A sketch size of the most simple example introduced at the Getting started is about 330K bytes. (270K byte without AutoConnect)</p>
<p>It increases about 53K bytes compared to the case without AutoConnect. A sketch size of the most simple example introduced at the Getting started is about 330K bytes. (270K byte without AutoConnect)</p>
<h3 id="heap-size">Heap size<a class="headerlink" href="#heap-size" title="Permanent link">&para;</a></h3>
<p>It consumes about 2K bytes in the static and about 12K bytes are consumed at the moment when menu executed.</p>
<h2 id="i-cannot-complete-to-wi-fi-login-from-smartphone"><i class="fa fa-question-circle"></i> I cannot complete to Wi-Fi login from smartphone.<a class="headerlink" href="#i-cannot-complete-to-wi-fi-login-from-smartphone" title="Permanent link">&para;</a></h2>

@ -218,6 +218,17 @@
<li class="md-tabs__item">
<a href="../basicusage/index.html" title="Usage the library" class="md-tabs__link">
Usage the library
</a>
</li>
@ -381,12 +392,48 @@
<li class="md-nav__item">
<a href="../usage/index.html" title="Usage the library" class="md-nav__link">
<li class="md-nav__item md-nav__item--nested">
<input class="md-toggle md-nav__toggle" data-md-toggle="nav-4" type="checkbox" id="nav-4">
<label class="md-nav__link" for="nav-4">
Usage the library
</label>
<nav class="md-nav" data-md-component="collapsible" data-md-level="1">
<label class="md-nav__title" for="nav-4">
Usage the library
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../basicusage/index.html" title="Basic usage" class="md-nav__link">
Basic usage
</a>
</li>
<li class="md-nav__item">
<a href="../advancedusage/index.html" title="Advanced usage" class="md-nav__link">
Advanced usage
</a>
</li>
</ul>
</nav>
</li>

@ -218,6 +218,17 @@
<li class="md-tabs__item">
<a href="basicusage/index.html" title="Usage the library" class="md-tabs__link">
Usage the library
</a>
</li>
@ -439,12 +450,48 @@
<li class="md-nav__item">
<a href="usage/index.html" title="Usage the library" class="md-nav__link">
<li class="md-nav__item md-nav__item--nested">
<input class="md-toggle md-nav__toggle" data-md-toggle="nav-4" type="checkbox" id="nav-4">
<label class="md-nav__link" for="nav-4">
Usage the library
</label>
<nav class="md-nav" data-md-component="collapsible" data-md-level="1">
<label class="md-nav__title" for="nav-4">
Usage the library
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="basicusage/index.html" title="Basic usage" class="md-nav__link">
Basic usage
</a>
</li>
<li class="md-nav__item">
<a href="advancedusage/index.html" title="Advanced usage" class="md-nav__link">
Advanced usage
</a>
</li>
</ul>
</nav>
</li>

@ -214,6 +214,17 @@
<li class="md-tabs__item">
<a href="../basicusage/index.html" title="Usage the library" class="md-tabs__link">
Usage the library
</a>
</li>
@ -309,12 +320,48 @@
<li class="md-nav__item">
<a href="../usage/index.html" title="Usage the library" class="md-nav__link">
<li class="md-nav__item md-nav__item--nested">
<input class="md-toggle md-nav__toggle" data-md-toggle="nav-4" type="checkbox" id="nav-4">
<label class="md-nav__link" for="nav-4">
Usage the library
</label>
<nav class="md-nav" data-md-component="collapsible" data-md-level="1">
<label class="md-nav__title" for="nav-4">
Usage the library
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../basicusage/index.html" title="Basic usage" class="md-nav__link">
Basic usage
</a>
</li>
<li class="md-nav__item">
<a href="../advancedusage/index.html" title="Advanced usage" class="md-nav__link">
Advanced usage
</a>
</li>
</ul>
</nav>
</li>

@ -218,6 +218,17 @@
<li class="md-tabs__item">
<a href="../basicusage/index.html" title="Usage the library" class="md-tabs__link">
Usage the library
</a>
</li>
@ -382,12 +393,48 @@
<li class="md-nav__item">
<a href="../usage/index.html" title="Usage the library" class="md-nav__link">
<li class="md-nav__item md-nav__item--nested">
<input class="md-toggle md-nav__toggle" data-md-toggle="nav-4" type="checkbox" id="nav-4">
<label class="md-nav__link" for="nav-4">
Usage the library
</label>
<nav class="md-nav" data-md-component="collapsible" data-md-level="1">
<label class="md-nav__title" for="nav-4">
Usage the library
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../basicusage/index.html" title="Basic usage" class="md-nav__link">
Basic usage
</a>
</li>
<li class="md-nav__item">
<a href="../advancedusage/index.html" title="Advanced usage" class="md-nav__link">
Advanced usage
</a>
</li>
</ul>
</nav>
</li>
@ -588,13 +635,13 @@ Enter SSID and Passphrase and tap "<strong>apply</strong>" to try connection. </
</a>
<a href="../usage/index.html" title="Usage the library" class="md-flex md-footer-nav__link md-footer-nav__link--next" rel="next">
<a href="../basicusage/index.html" title="Basic usage" class="md-flex md-footer-nav__link md-footer-nav__link--next" rel="next">
<div class="md-flex__cell md-flex__cell--stretch md-footer-nav__title">
<span class="md-flex__ellipsis">
<span class="md-footer-nav__direction">
Next
</span>
Usage the library
Basic usage
</span>
</div>
<div class="md-flex__cell md-flex__cell--shrink">

File diff suppressed because one or more lines are too long

@ -4,7 +4,7 @@
<url>
<loc>https://Hieromon.github.io/AutoConnect//index.html</loc>
<lastmod>2018-03-14</lastmod>
<lastmod>2018-03-15</lastmod>
<changefreq>daily</changefreq>
</url>
@ -12,7 +12,7 @@
<url>
<loc>https://Hieromon.github.io/AutoConnect//gettingstarted/index.html</loc>
<lastmod>2018-03-14</lastmod>
<lastmod>2018-03-15</lastmod>
<changefreq>daily</changefreq>
</url>
@ -20,23 +20,31 @@
<url>
<loc>https://Hieromon.github.io/AutoConnect//menu/index.html</loc>
<lastmod>2018-03-14</lastmod>
<lastmod>2018-03-15</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://Hieromon.github.io/AutoConnect//usage/index.html</loc>
<lastmod>2018-03-14</lastmod>
<loc>https://Hieromon.github.io/AutoConnect//basicusage/index.html</loc>
<lastmod>2018-03-15</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://Hieromon.github.io/AutoConnect//advancedusage/index.html</loc>
<lastmod>2018-03-15</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://Hieromon.github.io/AutoConnect//api/index.html</loc>
<lastmod>2018-03-14</lastmod>
<lastmod>2018-03-15</lastmod>
<changefreq>daily</changefreq>
</url>
@ -44,7 +52,7 @@
<url>
<loc>https://Hieromon.github.io/AutoConnect//examples/index.html</loc>
<lastmod>2018-03-14</lastmod>
<lastmod>2018-03-15</lastmod>
<changefreq>daily</changefreq>
</url>
@ -52,7 +60,7 @@
<url>
<loc>https://Hieromon.github.io/AutoConnect//faq/index.html</loc>
<lastmod>2018-03-14</lastmod>
<lastmod>2018-03-15</lastmod>
<changefreq>daily</changefreq>
</url>
@ -60,7 +68,7 @@
<url>
<loc>https://Hieromon.github.io/AutoConnect//license/index.html</loc>
<lastmod>2018-03-14</lastmod>
<lastmod>2018-03-15</lastmod>
<changefreq>daily</changefreq>
</url>

@ -12,7 +12,9 @@ pages:
- 'Overview' : index.md
- 'Getting started' : gettingstarted.md
- 'AutoConnect menu' : menu.md
- 'Usage the library' : usage.md
- 'Usage the library' :
- 'Basic usage' : basicusage.md
- 'Advanced usage' : advancedusage.md
- 'Library APIs' : api.md
- 'Examples' : examples.md
- 'FAQ' : faq.md

@ -1,109 +1,3 @@
## Simple usage
### <i class="fa fa-edit"></i> Embed to the sketches
How embed the AutoConnect to the sketches you have. Most simple approach to applying AutoConnect for the existing sketches, follow the below steps.
<img src="../images/BeforeAfter.svg" />
<ul class="ulsty-edit" style="list-style:none;">
<li>Insert <code class="codehilite"><span class="cp">#include</span> <span class="cpf">&lt;AutoConnect.h&gt;</span></code> to behind of <code class="codehilite"><span class="cp">#include</span> <span class="cpf">&lt;ESP8266WebServer.h&gt;</span></code>.</li>
<li>Insert <code class="codehilite"><span class="na">AutoConnect</span> <em>PORTAL(WEBSERVER);</em></code> to behind of <code class="codehilite"><span class="na">ESP8266WebServer</span> <em>WEBSERVER;</em></code> declaration.<sup id="fnref:1"><a class="footnote-ref" href="#fn:1" rel="footnote">1</a></sup></li>
<li>Remove <code class="codehilite">WiFi.<span class="na">begin</span>(<em>SSID</em>,<em>PSK</em>)</code> and the subsequent logic for the connection status check.</li>
<li>Replace <code class="codehilite"><em>WEBSERVER</em>.<span class="na">begin</span><span class="p">()</span></code> to <code class="codehilite"><em>PORTAL</em>.<span class="na">begin</span><span class="p">()</span></code>.<sup id="fnref:2"><a class="footnote-ref" href="#fn:2" rel="footnote">2</a></sup></li>
<li>Replace <code class="codehilite"><em>WEBSERVER</em>.<span class="na">handleClient</span><span class="p">()</span></code> to <code class="codehilite"><em>PORTAL</em>.<span class="na">handleClient</span><span class="p">()</span></code>.<sup id="fnref:3"><a class="footnote-ref" href="#fn:3" rel="footnote">3</a></sup></li>
<li>If the connection checks logic is needed, you can check the return value according to <code class="codehilite"><em>PORTAL</em>.<span class="na">begin</span><span class="p">()</span></code> with <code class="codehilite">true</code> or <code class="codehilite">false</code>.</li>
</ul>
[^1]:
Each *VARIABLE* conforms to the actual declaration in the sketches.
[^2]:
WiFi SSID and Password can be specified AutoConnect::begin() too.
[^3]:
Replacement the **handleClient** method is not indispensable. AutoConnect can still connect with the captive portal as it is ESP8266WebServer::handleClient. But it can **not valid AutoConnect menu**.
## Basic usage
### <i class="fa fa-caret-right"></i> Basic logic sequence for the user sketches
#### 1. A typical logic sequence
!!! note ""
1. <strong>Include headers,</strong> `ESP8266WebServer.h` and `AutoConnect.h`
2. <strong>Declare ESP8266WebServer variable.</strong>
3. <strong>Declare AutoConnect variable.</strong>
4. <strong>Implements the URL handler *function()*.</strong>
5. <strong>setup()</strong>
5.1 <strong>Sets URL handler *function()* to ESP8266WebServer by</strong>`ESP8266WebServer::on`<strong>.</strong>
5.2 <strong>Starts </strong>`AutoConnect::begin()`<strong>.</strong>
5.3 <strong>Check connection status.</strong>
6. <strong>loop()</strong>
6.1 <strong>Invokes </strong>`AutoConnect::handleClient()`<strong>,<br>or invokes </strong>`ESP8266WebServer::handleClient()`<strong> then </strong>`AutoConnect::handleRequest()`<strong>.</strong>
6.2 <strong>Do the process for actual sketch.</strong>
#### 2. Declare AutoConnect object
[Two options](#esp8266webserver-hosted-or-parasitic) are available for [AutoConnect constructor](api.md#constructors).
```arduino
AutoConnect VARIABLE(&ESP8266WebServer);
```
or
```arduino
AutoConnect VARIABLE;
```
- **Parameter with ESP8266WebServer variable:** An ESP8266WebServer object variable must be declared in the sketch. AutoConnect uses its variable for handling the [AutoConnect menu](menu.md).
- **With no parameter:** The sketch does not declare ESP8266WebServer object. In this case, AutoConnect allocates an instance of the ESP8266WebServer internally and the logic sequence of the sketch is somewhat different as the above. To register a URL handler function by *ESP8266WebServer::on* should be performed after [*AutoConnect::begin*](api.md#begin).
#### 3. No need WiFI.begin(...)
AutoConnect performs *WiFi.begin* for establishing a connection with WLAN internally. There is no need for a general process to establish a connection with *WiFi.begin* in a sketch.
#### 4. Alternate ESP8266WebServer::begin()
[*AutoConnect::begin*](api.md#begin) internally executes *ESP8266WebServer::begin* too and it starts DNS server to behave as a captive portal. So the sketch does not need to call *ESP8266WebServer::begin*.
!!! info "Why DNS Server Starts"
AutoConnect traps the detection of captive portals and directs them to the AutoConnect menu to achieve a connection with the WLAN interactively. In order to trap, it temporarily responds SoftAP address to all DNS queries. When the connection with the WLAN is successfully established, the DNS server will stop.
#### 5. AutoConnect::begin with SSID and Password
SSID and Password can also specify by [*AutoConnect::begin*](api.me#begin). ESP8266 uses provided SSID and Password explicitly. If the connection false with specified SSID with Password then a captive portal is activated. SSID and Password are not present, ESP8266 SDK will attempt to connect using the still effectual SSID and password. Usually, it succeeds.
#### 6. Use ESP8266WebServer::on to handle URL
AutoConnect is designed to coexist with the process for handling the web pages by user sketches. The page processing function which will send an HTML to the client invoked by the "*on::ESP8266WebServer*" function is the same as when using ESP8266WebServer natively.
#### 7. Use either ESP8266WebServer::handleClient() or AutoConnect::handleClient()
Both classes member function name is the same: *handleClient*, but behavior is different. Using the AutoConnect embedded along with ESP8266WebServer::handleClient has limitations. Refer to the below section for details.
### <i class="fa fa-caret-right"></i> ESP8266WebServer hosted or parasitic
The interoperable process with an ESP8266WebServer depends on the parameters of the [AutoConnect constructor](api.md#constructors).
Declaration parameter | Use ESP8266WebServer::handleClient | Use AutoConnect::handleClient
----|----|---
None | AutoConnect menu not available.<br>host() is needed. | AutoConnect menu available.<br>host() is needed.
Reference to ESP8266WebServer | AutoConnect menu not available.<br>host() not necessary. | AutoConnect menu available.<br>host() not necessary.
- **By declaration for the AutoConnect variable with no parameter**: The ESP8266WebServer instance is hosted by AutoConnect automatically then the sketches use [*AutoConnect::host*](api.md#host) as API to get it after [*AutoConnect::begin*](api.md#begin) performed.
- **By declaration for the AutoConnect variable with the reference of ESP8266WebServer**: AutoConnect will use it. The sketch can use it is too.
- **In use ESP8266WebServer::handleClient()**: AutoConnect menu can be dispatched but not works normally. It is necessary to call [*AutoConnect::handleRequest*](api.md#void-handlerequest) after *ESP8255WebServer::handleClient* invoking.
- **In use [AutoConnect::handleClient()](api.md#void-handleclient)**: The handleClient() process and the AutoConnect menu is available without calling *ESP8266WebServer::handleClient*.
!!! info "Why AutoConnect::handleRequest is needed when using ESP8266::handleClient"
The AutoConnect menu function may affect WiFi connection state. It follows that the menu process must execute outside *ESP8266WebServer::handleClient*.
[*AutoConnect::handleClient*](api.md#void-handleclient) is equivalent *ESP8266WebServer::handleClient* included [*AutoConnect::handleRequest*](api.md#void-handlerequest).
## Advanced usage
### <i class="fa fa-caret-right"></i> 404 handler

@ -0,0 +1,106 @@
## Simple usage
### <i class="fa fa-edit"></i> Embed to the sketches
How embed the AutoConnect to the sketches you have. Most simple approach to applying AutoConnect for the existing sketches, follow the below steps.
<img src="../images/BeforeAfter.svg" />
<ul class="ulsty-edit" style="list-style:none;">
<li>Insert <code class="codehilite"><span class="cp">#include</span> <span class="cpf">&lt;AutoConnect.h&gt;</span></code> to behind of <code class="codehilite"><span class="cp">#include</span> <span class="cpf">&lt;ESP8266WebServer.h&gt;</span></code>.</li>
<li>Insert <code class="codehilite"><span class="na">AutoConnect</span> <em>PORTAL(WEBSERVER);</em></code> to behind of <code class="codehilite"><span class="na">ESP8266WebServer</span> <em>WEBSERVER;</em></code> declaration.<sup id="fnref:1"><a class="footnote-ref" href="#fn:1" rel="footnote">1</a></sup></li>
<li>Remove <code class="codehilite">WiFi.<span class="na">begin</span>(<em>SSID</em>,<em>PSK</em>)</code> and the subsequent logic for the connection status check.</li>
<li>Replace <code class="codehilite"><em>WEBSERVER</em>.<span class="na">begin</span><span class="p">()</span></code> to <code class="codehilite"><em>PORTAL</em>.<span class="na">begin</span><span class="p">()</span></code>.<sup id="fnref:2"><a class="footnote-ref" href="#fn:2" rel="footnote">2</a></sup></li>
<li>Replace <code class="codehilite"><em>WEBSERVER</em>.<span class="na">handleClient</span><span class="p">()</span></code> to <code class="codehilite"><em>PORTAL</em>.<span class="na">handleClient</span><span class="p">()</span></code>.<sup id="fnref:3"><a class="footnote-ref" href="#fn:3" rel="footnote">3</a></sup></li>
<li>If the connection checks logic is needed, you can check the return value according to <code class="codehilite"><em>PORTAL</em>.<span class="na">begin</span><span class="p">()</span></code> with <code class="codehilite">true</code> or <code class="codehilite">false</code>.</li>
</ul>
[^1]:
Each *VARIABLE* conforms to the actual declaration in the sketches.
[^2]:
WiFi SSID and Password can be specified AutoConnect::begin() too.
[^3]:
Replacement the **handleClient** method is not indispensable. AutoConnect can still connect with the captive portal as it is ESP8266WebServer::handleClient. But it can **not valid AutoConnect menu**.
## Basic usage
### <i class="fa fa-caret-right"></i> Basic logic sequence for the user sketches
#### 1. A typical logic sequence
!!! note ""
1. <strong>Include headers,</strong> `ESP8266WebServer.h` and `AutoConnect.h`
2. <strong>Declare ESP8266WebServer variable.</strong>
3. <strong>Declare AutoConnect variable.</strong>
4. <strong>Implements the URL handler *function()*.</strong>
5. <strong>setup()</strong>
5.1 <strong>Sets URL handler *function()* to ESP8266WebServer by</strong>`ESP8266WebServer::on`<strong>.</strong>
5.2 <strong>Starts </strong>`AutoConnect::begin()`<strong>.</strong>
5.3 <strong>Check connection status.</strong>
6. <strong>loop()</strong>
6.1 <strong>Invokes </strong>`AutoConnect::handleClient()`<strong>,<br>or invokes </strong>`ESP8266WebServer::handleClient()`<strong> then </strong>`AutoConnect::handleRequest()`<strong>.</strong>
6.2 <strong>Do the process for actual sketch.</strong>
#### 2. Declare AutoConnect object
[Two options](#esp8266webserver-hosted-or-parasitic) are available for [AutoConnect constructor](api.md#constructors).
```arduino
AutoConnect VARIABLE(&ESP8266WebServer);
```
or
```arduino
AutoConnect VARIABLE;
```
- **Parameter with ESP8266WebServer variable:** An ESP8266WebServer object variable must be declared in the sketch. AutoConnect uses its variable for handling the [AutoConnect menu](menu.md).
- **With no parameter:** The sketch does not declare ESP8266WebServer object. In this case, AutoConnect allocates an instance of the ESP8266WebServer internally and the logic sequence of the sketch is somewhat different as the above. To register a URL handler function by *ESP8266WebServer::on* should be performed after [*AutoConnect::begin*](api.md#begin).
#### 3. No need WiFI.begin(...)
AutoConnect performs *WiFi.begin* for establishing a connection with WLAN internally. There is no need for a general process to establish a connection with *WiFi.begin* in a sketch.
#### 4. Alternate ESP8266WebServer::begin()
[*AutoConnect::begin*](api.md#begin) internally executes *ESP8266WebServer::begin* too and it starts DNS server to behave as a captive portal. So the sketch does not need to call *ESP8266WebServer::begin*.
!!! info "Why DNS Server Starts"
AutoConnect traps the detection of captive portals and directs them to the AutoConnect menu to achieve a connection with the WLAN interactively. In order to trap, it temporarily responds SoftAP address to all DNS queries. When the connection with the WLAN is successfully established, the DNS server will stop.
#### 5. AutoConnect::begin with SSID and Password
SSID and Password can also specify by [*AutoConnect::begin*](api.me#begin). ESP8266 uses provided SSID and Password explicitly. If the connection false with specified SSID with Password then a captive portal is activated. SSID and Password are not present, ESP8266 SDK will attempt to connect using the still effectual SSID and password. Usually, it succeeds.
#### 6. Use ESP8266WebServer::on to handle URL
AutoConnect is designed to coexist with the process for handling the web pages by user sketches. The page processing function which will send an HTML to the client invoked by the "*on::ESP8266WebServer*" function is the same as when using ESP8266WebServer natively.
#### 7. Use either ESP8266WebServer::handleClient() or AutoConnect::handleClient()
Both classes member function name is the same: *handleClient*, but behavior is different. Using the AutoConnect embedded along with ESP8266WebServer::handleClient has limitations. Refer to the below section for details.
### <i class="fa fa-caret-right"></i> ESP8266WebServer hosted or parasitic
The interoperable process with an ESP8266WebServer depends on the parameters of the [AutoConnect constructor](api.md#constructors).
Declaration parameter | Use ESP8266WebServer::handleClient | Use AutoConnect::handleClient
----|----|---
None | AutoConnect menu not available.<br>host() is needed. | AutoConnect menu available.<br>host() is needed.
Reference to ESP8266WebServer | AutoConnect menu not available.<br>host() not necessary. | AutoConnect menu available.<br>host() not necessary.
- **By declaration for the AutoConnect variable with no parameter**: The ESP8266WebServer instance is hosted by AutoConnect automatically then the sketches use [*AutoConnect::host*](api.md#host) as API to get it after [*AutoConnect::begin*](api.md#begin) performed.
- **By declaration for the AutoConnect variable with the reference of ESP8266WebServer**: AutoConnect will use it. The sketch can use it is too.
- **In use ESP8266WebServer::handleClient()**: AutoConnect menu can be dispatched but not works normally. It is necessary to call [*AutoConnect::handleRequest*](api.md#void-handlerequest) after *ESP8255WebServer::handleClient* invoking.
- **In use [AutoConnect::handleClient()](api.md#void-handleclient)**: The handleClient() process and the AutoConnect menu is available without calling *ESP8266WebServer::handleClient*.
!!! info "Why AutoConnect::handleRequest is needed when using ESP8266::handleClient"
The AutoConnect menu function may affect WiFi connection state. It follows that the menu process must execute outside *ESP8266WebServer::handleClient*.
[*AutoConnect::handleClient*](api.md#void-handleclient) is equivalent *ESP8266WebServer::handleClient* included [*AutoConnect::handleRequest*](api.md#void-handlerequest).

@ -42,7 +42,7 @@ void loop() {
## <i class="fa fa-question-circle"></i> Does not response from \_ac.
Probably **WiFi.begin** failed with the specified SSID. Activating the [debug printing](usage.md#debug-print) will help you to track down the cause.
Probably **WiFi.begin** failed with the specified SSID. Activating the [debug printing](advancedusage.md#debug-print) will help you to track down the cause.
## <i class="fa fa-question-circle"></i> How change esp8266ap for SSID name in Captive portal?
@ -145,7 +145,7 @@ Link button to AutoConnect menu can be embedded into Sketch's web page. The root
### Sketch size
It increases about 57K bytes compared to the case without AutoConnect. A sketch size of the most simple example introduced at the Getting started is about 330K bytes. (270K byte without AutoConnect)
It increases about 53K bytes compared to the case without AutoConnect. A sketch size of the most simple example introduced at the Getting started is about 330K bytes. (270K byte without AutoConnect)
### Heap size

Loading…
Cancel
Save