Updates MQTT example

pull/8/head
Hieromon Ikasamo 7 years ago
parent ddcf3c3112
commit 35409445ec
  1. 22
      docs/advancedusage/index.html
  2. 35
      docs/examples/index.html
  3. 18
      docs/search/search_index.json
  4. 20
      docs/sitemap.xml
  5. 14
      mkdocs/advancedusage.md
  6. 31
      mkdocs/examples.md

@ -465,8 +465,8 @@
</li> </li>
<li class="md-nav__item"> <li class="md-nav__item">
<a href="#static-ip-assignment" title=" Static IP assignment" class="md-nav__link"> <a href="#static-ip-assignment-1" title=" Static IP assignment 1" class="md-nav__link">
Static IP assignment Static IP assignment 1
</a> </a>
</li> </li>
@ -678,8 +678,8 @@
</li> </li>
<li class="md-nav__item"> <li class="md-nav__item">
<a href="#static-ip-assignment" title=" Static IP assignment" class="md-nav__link"> <a href="#static-ip-assignment-1" title=" Static IP assignment 1" class="md-nav__link">
Static IP assignment Static IP assignment 1
</a> </a>
</li> </li>
@ -891,9 +891,17 @@
<div class="codehilite"><pre><span></span><span class="cp">#define AUTOCONNECT_URI &quot;/_ac&quot;</span> <div class="codehilite"><pre><span></span><span class="cp">#define AUTOCONNECT_URI &quot;/_ac&quot;</span>
</pre></div> </pre></div>
<h3 id="static-ip-assignment"><i class="fa fa-caret-right"></i> Static IP assignment<a class="headerlink" href="#static-ip-assignment" title="Permanent link">&para;</a></h3> <h3 id="static-ip-assignment-1"><i class="fa fa-caret-right"></i> Static IP assignment <sup id="fnref:1"><a class="footnote-ref" href="#fn:1" rel="footnote">1</a></sup><a class="headerlink" href="#static-ip-assignment-1" title="Permanent link">&para;</a></h3>
<p>It is also possible to assign static IP Address to ESP8266 in STA mode. By default DHCP is enabled and it becomes the IP address assigned by the DHCP server with <em>WiFi.begin</em>.<sup id="fnref:1"><a class="footnote-ref" href="#fn:1" rel="footnote">1</a></sup></p> <p>It is also possible to assign static IP Address to ESP8266 in STA mode. By default DHCP is enabled and it becomes the IP address assigned by the DHCP server with <em>WiFi.begin</em>.</p>
<p>To assign a static IP Address, specify it in the <a href="../api/index.html#staip">AutoConnectConfig parameter</a>. In the case of assigning a static IP Address, specify the gateway, subnet mask, and DNS server is needed.</p> <p>To assign a static IP to ESP8266 with WIFI_MODE_STA, the following parameters are required:</p>
<ul>
<li>IP address.</li>
<li>Gateway address.</li>
<li>Subnet mask.</li>
<li>Primary DNS server.</li>
<li>Secondary DNS server. (optional)</li>
</ul>
<p>The above parameters must be executed before <em>AutoConnect::begin</em> as <a href="../api/index.html#staip">arguments of AutoConnectConfig</a>.</p>
<div class="codehilite"><pre><span></span><span class="n">AutoConnect</span> <span class="n">portal</span><span class="p">;</span> <div class="codehilite"><pre><span></span><span class="n">AutoConnect</span> <span class="n">portal</span><span class="p">;</span>
<span class="n">AutoConnectConfig</span> <span class="n">Config</span><span class="p">;</span> <span class="n">AutoConnectConfig</span> <span class="n">Config</span><span class="p">;</span>
<span class="n">Config</span><span class="p">.</span><span class="n">staip</span> <span class="o">=</span> <span class="nf">IPAddress</span><span class="p">(</span><span class="mi">192</span><span class="p">,</span><span class="mi">168</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">10</span><span class="p">);</span> <span class="n">Config</span><span class="p">.</span><span class="n">staip</span> <span class="o">=</span> <span class="nf">IPAddress</span><span class="p">(</span><span class="mi">192</span><span class="p">,</span><span class="mi">168</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">10</span><span class="p">);</span>

@ -683,7 +683,7 @@
<p>Declare only AutoConnect, performs handleClient.</p> <p>Declare only AutoConnect, performs handleClient.</p>
<p><img src="../images/handlePortal.svg" /></p> <p><img src="../images/handlePortal.svg" /></p>
<h2 id="used-with-mqtt-as-a-client-application">Used with MQTT as a client application<a class="headerlink" href="#used-with-mqtt-as-a-client-application" title="Permanent link">&para;</a></h2> <h2 id="used-with-mqtt-as-a-client-application">Used with MQTT as a client application<a class="headerlink" href="#used-with-mqtt-as-a-client-application" title="Permanent link">&para;</a></h2>
<p>The effect of AutoConnect is not only for ESP8266 as the Web server. It has a benefit for something WiFi client too. AutoConnect is effective too when publishing with MQTT from various measurement points. Even if the SSID is different for each measurement point, it is no need to modify the sketch.</p> <p>The effect of AutoConnect is not only for ESP8266 as the Web server. It has advantages for something WiFi client as well. For example, AutoConnect is also effective for publishing MQTT messages from various measurement points. Even if the SSID is different for each measurement point, it is not necessary to modify the sketch.</p>
<p>This example tries to publish the WiFi signal strength of ESP8266 with MQTT. It uses the <a href="https://thingspeak.com/">ThingSpeak</a> for MQTT broker. ESP8266 publishes the RSSI value to the channel created on ThingSpeak as <a href="https://github.com/knolleary/pubsubclient">MQTT client</a>. This example is well suited to demonstrate the usefulness of AutoConnect, as RSSI values are measured at each access point usually. Just adding a few lines of code makes it unnecessary to upload sketches with the different SSIDs rewrite for each access point.</p> <p>This example tries to publish the WiFi signal strength of ESP8266 with MQTT. It uses the <a href="https://thingspeak.com/">ThingSpeak</a> for MQTT broker. ESP8266 publishes the RSSI value to the channel created on ThingSpeak as <a href="https://github.com/knolleary/pubsubclient">MQTT client</a>. This example is well suited to demonstrate the usefulness of AutoConnect, as RSSI values are measured at each access point usually. Just adding a few lines of code makes it unnecessary to upload sketches with the different SSIDs rewrite for each access point.</p>
<p><img src="../images/ChannelStatus.png" width="70%"/></p> <p><img src="../images/ChannelStatus.png" width="70%"/></p>
<h3 id="advance-procedures">Advance procedures<a class="headerlink" href="#advance-procedures" title="Permanent link">&para;</a></h3> <h3 id="advance-procedures">Advance procedures<a class="headerlink" href="#advance-procedures" title="Permanent link">&para;</a></h3>
@ -726,22 +726,32 @@
<p>For the client sketches, the code required to connect to WiFi is the following four parts only.</p> <p>For the client sketches, the code required to connect to WiFi is the following four parts only.</p>
<ol> <ol>
<li> <li>
<p>#include directive<sup id="fnref:3"><a class="footnote-ref" href="#fn:3" rel="footnote">3</a></sup><br /> <p>#include directive<sup id="fnref:3"><a class="footnote-ref" href="#fn:3" rel="footnote">3</a></sup></p>
<img src="../images/include.png" width="55%"/></p> <p>Include <code class="codehilite">AutoConnect.h</code> header file behind the include of <code class="codehilite">ESP8266WiFi.h</code>.</p>
<p><img src="../images/include.png" width="55%"/></p>
</li> </li>
<li> <li>
<p>Declare AutoConnect<br /> <p>Declare AutoConnect</p>
<img src="../images/declare.png" width="55%"/></p> <p>The declaration of the <a href="../api/index.html#autoconnect"><strong>AutoConnect variable</strong></a> is not accompanied by ESP8266WebServer.</p>
<p><img src="../images/declare.png" width="55%"/></p>
</li> </li>
<li> <li>
<p>Invokes "begin()"<br /> <p>Invokes "begin()"</p>
<img src="../images/begin.png" width="55%"/></p> <p>Call <a href="../api/index.html#begin"><strong>AutoConnec::begin</strong></a>. If you need to assign a static IP address, executes <a href="../api/index.html#autoconnectconfig-api"><strong>AutoConnectConfig</strong></a> before that. </p>
<p><img src="../images/begin.png" width="55%"/></p>
</li> </li>
<li> <li>
<p>Performs "handleClent()" in "loop()"<br /> <p>Performs "handleClent()" in "loop()"</p>
<img src="../images/handleClient.png" width="55%"/></p> <p>Invokes <a href="../api/index.html#handleclient"><strong>AutoConnect::handleClient()</strong></a> at inside <code class="codehilite">loop()</code> to enable the AutoConnect menu.</p>
<p><img src="../images/handleClient.png" width="55%"/></p>
</li> </li>
</ol> </ol>
<script>
window.onload = function() {
Gifffer();
}
</script>
<div class="footnote"> <div class="footnote">
<hr /> <hr />
<ol> <ol>
@ -752,12 +762,7 @@
<p>'454951' in the example above, but your channel ID should be different.&#160;<a class="footnote-backref" href="#fnref:2" rev="footnote" title="Jump back to footnote 2 in the text">&#8617;</a></p> <p>'454951' in the example above, but your channel ID should be different.&#160;<a class="footnote-backref" href="#fnref:2" rev="footnote" title="Jump back to footnote 2 in the text">&#8617;</a></p>
</li> </li>
<li id="fn:3"> <li id="fn:3">
<p><code class="codehilite"><span class="cp">#include</span> <span class="cpf">&lt;ESP8266WebServer.h&gt;</span><span class="cp"></span></code> does not necessary for uses only client. <p><code class="codehilite"><span class="cp">#include</span> <span class="cpf">&lt;ESP8266WebServer.h&gt;</span><span class="cp"></span></code> does not necessary for uses only client.&#160;<a class="footnote-backref" href="#fnref:3" rev="footnote" title="Jump back to footnote 3 in the text">&#8617;</a></p>
<script>
window.onload = function() {
Gifffer();
}
</script>&#160;<a class="footnote-backref" href="#fnref:3" rev="footnote" title="Jump back to footnote 3 in the text">&#8617;</a></p>
</li> </li>
</ol> </ol>
</div> </div>

File diff suppressed because one or more lines are too long

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

@ -218,11 +218,19 @@ A home path of AutoConnect is **/\_ac** by default. You can access from the brow
#define AUTOCONNECT_URI "/_ac" #define AUTOCONNECT_URI "/_ac"
``` ```
### <i class="fa fa-caret-right"></i> Static IP assignment ### <i class="fa fa-caret-right"></i> Static IP assignment [^1]
It is also possible to assign static IP Address to ESP8266 in STA mode. By default DHCP is enabled and it becomes the IP address assigned by the DHCP server with *WiFi.begin*.[^1] It is also possible to assign static IP Address to ESP8266 in STA mode. By default DHCP is enabled and it becomes the IP address assigned by the DHCP server with *WiFi.begin*.
To assign a static IP Address, specify it in the [AutoConnectConfig parameter](api.md#staip). In the case of assigning a static IP Address, specify the gateway, subnet mask, and DNS server is needed. To assign a static IP to ESP8266 with WIFI\_MODE\_STA, the following parameters are required:
- IP address.
- Gateway address.
- Subnet mask.
- Primary DNS server.
- Secondary DNS server. (optional)
The above parameters must be executed before *AutoConnect::begin* as [arguments of AutoConnectConfig](api.md#staip).
```arduino ```arduino
AutoConnect portal; AutoConnect portal;

@ -31,7 +31,7 @@ Declare only AutoConnect, performs handleClient.
## Used with MQTT as a client application ## Used with MQTT as a client application
The effect of AutoConnect is not only for ESP8266 as the Web server. It has a benefit for something WiFi client too. AutoConnect is effective too when publishing with MQTT from various measurement points. Even if the SSID is different for each measurement point, it is no need to modify the sketch. The effect of AutoConnect is not only for ESP8266 as the Web server. It has advantages for something WiFi client as well. For example, AutoConnect is also effective for publishing MQTT messages from various measurement points. Even if the SSID is different for each measurement point, it is not necessary to modify the sketch.
This example tries to publish the WiFi signal strength of ESP8266 with MQTT. It uses the [ThingSpeak](https://thingspeak.com/) for MQTT broker. ESP8266 publishes the RSSI value to the channel created on ThingSpeak as [MQTT client](https://github.com/knolleary/pubsubclient). This example is well suited to demonstrate the usefulness of AutoConnect, as RSSI values are measured at each access point usually. Just adding a few lines of code makes it unnecessary to upload sketches with the different SSIDs rewrite for each access point. This example tries to publish the WiFi signal strength of ESP8266 with MQTT. It uses the [ThingSpeak](https://thingspeak.com/) for MQTT broker. ESP8266 publishes the RSSI value to the channel created on ThingSpeak as [MQTT client](https://github.com/knolleary/pubsubclient). This example is well suited to demonstrate the usefulness of AutoConnect, as RSSI values are measured at each access point usually. Just adding a few lines of code makes it unnecessary to upload sketches with the different SSIDs rewrite for each access point.
@ -96,19 +96,32 @@ After upload and reboot complete, the message publishing will start via the acce
For the client sketches, the code required to connect to WiFi is the following four parts only. For the client sketches, the code required to connect to WiFi is the following four parts only.
1. \#include directive[^3] 1. \#include directive[^3]
<img src="../images/include.png" width="55%"/>
Include ```AutoConnect.h``` header file behind the include of ```ESP8266WiFi.h```.
2. Declare AutoConnect <img src="../images/include.png" width="55%"/>
<img src="../images/declare.png" width="55%"/>
3. Invokes "begin()" 2. Declare AutoConnect
<img src="../images/begin.png" width="55%"/>
The declaration of the [**AutoConnect variable**](api.md#autoconnect) is not accompanied by ESP8266WebServer.
4. Performs "handleClent()" in "loop()" <img src="../images/declare.png" width="55%"/>
<img src="../images/handleClient.png" width="55%"/>
3. Invokes "begin()"
Call [**AutoConnec::begin**](api.md#begin). If you need to assign a static IP address, executes [**AutoConnectConfig**](api.md#autoconnectconfig-api) before that.
<img src="../images/begin.png" width="55%"/>
4. Performs "handleClent()" in "loop()"
Invokes [**AutoConnect::handleClient()**](api.md#handleclient) at inside ```loop()``` to enable the AutoConnect menu.
<img src="../images/handleClient.png" width="55%"/>
[^3]:```#include <ESP8266WebServer.h>``` does not necessary for uses only client. [^3]:```#include <ESP8266WebServer.h>``` does not necessary for uses only client.
<script> <script>
window.onload = function() { window.onload = function() {
Gifffer(); Gifffer();

Loading…
Cancel
Save