AutoConnectElements contained in AutoConnectAux object are uniquely identified by name. When adding an AutoConnectElement, if an element with the same name already exists in the AutoConnectAux, checking the type, and if it is the same, the value will be replaced. If another type of AutoConnectElement exists with the same name, that add operation will be invalid.<supid="fnref:1"><aclass="footnote-ref"href="#fn:1">1</a></sup> In the following example, AutoConnectButton <code>button</code> addition will invalid because <code>hello</code> with the same name already exists as AutoConnectText.</p>
AutoConnectElements contained in AutoConnectAux object are uniquely identified by name. When adding an AutoConnectElement, if an element with the same name already exists in the AutoConnectAux, checking the type, and if it is the same, the value will be replaced. If another type of AutoConnectElement exists with the same name, that add operation will be invalid.<supid="fnref:1"><aclass="footnote-ref"href="#fn:1">1</a></sup> In the following example, AutoConnectButton <code>button</code> addition will invalid because <code>hello</code> with the same name already exists as AutoConnectText.</p>
@ -1273,9 +1273,9 @@ AutoConnectElements contained in AutoConnectAux object are uniquely identified b
<h3id="enable-autoconnectelements-during-the-sketch-execution"><iclass="fa fa-edit"></i> Enable AutoConnectElements during the Sketch execution<aclass="headerlink"href="#enable-autoconnectelements-during-the-sketch-execution"title="Permanent link">¶</a></h3>
<h3id="enable-autoconnectelements-during-the-sketch-execution"><iclass="fa fa-edit"></i> Enable AutoConnectElements during the Sketch execution<aclass="headerlink"href="#enable-autoconnectelements-during-the-sketch-execution"title="Permanent link">¶</a></h3>
<p>AutoConnectElemets have an enable attribute to activate its own HTML generation. Sketches can change the HTMLization of their elements dynamically by setting or resetting the enable value. An element whose the enable attribute is true will generate itself HTML and place on the custom Web page. And conversely, it will not generate the HTML when the value is false.</p>
<p>AutoConnectElemets have an enable attribute to activate its own HTML generation. Sketches can change the HTMLization of their elements dynamically by setting or resetting the enable value. An element whose the enable attribute is true will generate itself HTML and place on the custom Web page. And conversely, it will not generate the HTML when the value is false.</p>
<p>For example, to enable the submit button only when the ESP module is connected to the access point in STA mode, you can sketch the following:</p>
<p>For example, to enable the submit button only when the ESP module is connected to the access point in STA mode, you can sketch the following:</p>
@ -1332,7 +1332,7 @@ AutoConnectElements contained in AutoConnectAux object are uniquely identified b
<p>To load a JSON document as AutoConnectAux use the <ahref="api.html#load"><strong>AutoConnect::load</strong></a> function and load the JSON document of each AutoConnectElement using the <ahref="apiaux.html#loadelement"><strong>AutoConnectAux::loadElement</strong></a> function. Although the functions of both are similar, the structure of the target JSON document is different.</p>
<p>To load a JSON document as AutoConnectAux use the <ahref="api.html#load"><strong>AutoConnect::load</strong></a> function and load the JSON document of each AutoConnectElement using the <ahref="apiaux.html#loadelement"><strong>AutoConnectAux::loadElement</strong></a> function. Although the functions of both are similar, the structure of the target JSON document is different.</p>
<p>The <ahref="apiaux.html#load">AutoConnect::load</a> function loads the entire AutoConnectAux and creates both the AutoConnectAux instance and each AutoConnectElement instance. A single JSON document can contain multiple custom Web pages. If you write JSON of AutoConnectAux as an array, the load function generates all the pages contained in that array. Therefore, it is necessary to supply the JSON document of AutoConnectAux as an input of the load function and must contain the elements described section <ahref="acjson.html#json-document-structure-for-autoconnectaux"><em>JSON document structure for AutoConnectAux</em></a>.</p>
<p>The <ahref="apiaux.html#load">AutoConnect::load</a> function loads the entire AutoConnectAux and creates both the AutoConnectAux instance and each AutoConnectElement instance. A single JSON document can contain multiple custom Web pages. If you write JSON of AutoConnectAux as an array, the load function generates all the pages contained in that array. Therefore, it is necessary to supply the JSON document of AutoConnectAux as an input of the load function and must contain the elements described section <ahref="acjson.html#json-document-structure-for-autoconnectaux"><em>JSON document structure for AutoConnectAux</em></a>.</p>
<p>The <ahref="apiaux.html#loadelement">AutoConnectAux::loadElement</a> function loads the elements individually into an AutoConnectAux object. The structure of its supplying JSON document is not AutoConnectAux. It must be a <ahref="acjson.html#json-object-for-autoconnectelements">JSON structure for AutoConnectElement</a>, but you can specify an array.</p>
<p>The <ahref="apiaux.html#loadelement">AutoConnectAux::loadElement</a> function loads the elements individually into an AutoConnectAux object. The structure of its supplying JSON document is not AutoConnectAux. It must be a <ahref="acjson.html#json-object-for-autoconnectelements">JSON structure for AutoConnectElement</a>, but you can specify an array.</p>
<divclass="codehilite"style="background: #272822"><prestyle="line-height: 125%"><span></span><code><spanstyle="color: #7a7a7a">// AutoConnectAux as a custom Web page.</span>
<divclass="codehilite"style="background: #272822"><prestyle="line-height: 125%"><span></span><code><spanstyle="color: #75715e">// AutoConnectAux as a custom Web page.</span>
<h3id="saving-autoconnectelements-with-json"><iclass="fa fa-download"></i> Saving AutoConnectElements with JSON<aclass="headerlink"href="#saving-autoconnectelements-with-json"title="Permanent link">¶</a></h3>
<h3id="saving-autoconnectelements-with-json"><iclass="fa fa-download"></i> Saving AutoConnectElements with JSON<aclass="headerlink"href="#saving-autoconnectelements-with-json"title="Permanent link">¶</a></h3>
<p>To save the AutoConnectAux or the AutoConnectElement as a JSON document, use the <ahref="apiaux.html#saveelement">AutoConnectAux::saveElement</a> function. It serializes the contents of the object based on the type of the AutoConnectElement. You can persist a serialized AutoConnectElements as a JSON document to a stream.</p>
<p>To save the AutoConnectAux or the AutoConnectElement as a JSON document, use the <ahref="apiaux.html#saveelement">AutoConnectAux::saveElement</a> function. It serializes the contents of the object based on the type of the AutoConnectElement. You can persist a serialized AutoConnectElements as a JSON document to a stream.</p>
<divclass="codehilite"style="background: #272822"><prestyle="line-height: 125%"><span></span><code><spanstyle="color: #7a7a7a">// Open a parameter file on the SPIFFS.</span>
<divclass="codehilite"style="background: #272822"><prestyle="line-height: 125%"><span></span><code><spanstyle="color: #75715e">// Open a parameter file on the SPIFFS.</span>
<spanstyle="color: #7a7a7a">// Close a parameter file.</span>
<spanstyle="color: #75715e">// Close a parameter file.</span>
<spanstyle="color: #f8f8f2">param.close();</span>
<spanstyle="color: #f8f8f2">param.close();</span>
<spanstyle="color: #f8f8f2">SPIFFS.end();</span>
<spanstyle="color: #f8f8f2">SPIFFS.end();</span>
</code></pre></div>
</code></pre></div>
@ -1438,9 +1438,9 @@ AutoConnectElements contained in AutoConnectAux object are uniquely identified b
<h3id="where-to-pick-up-the-values"><iclass="fa fa-desktop"></i> Where to pick up the values<aclass="headerlink"href="#where-to-pick-up-the-values"title="Permanent link">¶</a></h3>
<h3id="where-to-pick-up-the-values"><iclass="fa fa-desktop"></i> Where to pick up the values<aclass="headerlink"href="#where-to-pick-up-the-values"title="Permanent link">¶</a></h3>
<p>A sketch composed of handlers can receive the value of AutoConnectElements entered in a custom Web page after sending, but that handler is different from the page where the value was entered. It is necessary to be aware that can accept the entered values by the next page handler after the transition.</p>
<p>A sketch composed of handlers can receive the value of AutoConnectElements entered in a custom Web page after sending, but that handler is different from the page where the value was entered. It is necessary to be aware that can accept the entered values by the next page handler after the transition.</p>
<p>Usually, two ways to retrieve entered values we have. One is to use the <ahref="https://github.com/esp8266/Arduino/tree/master/libraries/ESP8266WebServer#getting-information-about-request-arguments">ESP8266WebServer::arg</a> (or WebServer::arg for ESP32) function in the <ahref="https://github.com/esp8266/Arduino/tree/master/libraries/ESP8266WebServer#client-request-handlers"><code>on handler</code></a> attached by ESP8266WebServer (WebServer w/ESP32 also).</p>
<p>Usually, two ways to retrieve entered values we have. One is to use the <ahref="https://github.com/esp8266/Arduino/tree/master/libraries/ESP8266WebServer#getting-information-about-request-arguments">ESP8266WebServer::arg</a> (or WebServer::arg for ESP32) function in the <ahref="https://github.com/esp8266/Arduino/tree/master/libraries/ESP8266WebServer#client-request-handlers"><code>on handler</code></a> attached by ESP8266WebServer (WebServer w/ESP32 also).</p>
@ -1495,9 +1495,9 @@ AutoConnectElements contained in AutoConnectAux object are uniquely identified b
<p>When you actually try the above sketch, there is no a root handler. So the URL that should be accessed first is <code>/_ac</code> concatenated with the local IP address of the esp8266 module.</p>
<p>When you actually try the above sketch, there is no a root handler. So the URL that should be accessed first is <code>/_ac</code> concatenated with the local IP address of the esp8266 module.</p>
</div>
</div>
<p>Another method is effective when custom Web pages have complicated page transitions. It is a way to straight access the AutoConnectElements member value. You can get the AutoConnectElement with the specified name using the <ahref="#get-autoconnectelement-from-the-autoconnectaux">getElement</a> function. The following sketch executes the above example with AutoConnect only, without using the function of ESP8266WebServer.</p>
<p>Another method is effective when custom Web pages have complicated page transitions. It is a way to straight access the AutoConnectElements member value. You can get the AutoConnectElement with the specified name using the <ahref="#get-autoconnectelement-from-the-autoconnectaux">getElement</a> function. The following sketch executes the above example with AutoConnect only, without using the function of ESP8266WebServer.</p>
<spanstyle="color: #7a7a7a">// Append an HTML</span>
<spanstyle="color: #75715e">// Append an HTML</span>
<spanstyle="color: #66d9ef">return</span><spanstyle="color: #f8f8f2">String(</span><spanstyle="color: #e6db74">"<p>This text has been added.</p>"</span><spanstyle="color: #f8f8f2">);</span>
<spanstyle="color: #66d9ef">return</span><spanstyle="color: #f8f8f2">String(</span><spanstyle="color: #e6db74">"<p>This text has been added.</p>"</span><spanstyle="color: #f8f8f2">);</span>
<spanstyle="color: #f8f8f2">}</span>
<spanstyle="color: #f8f8f2">}</span>
</code></pre></div>
</code></pre></div>
@ -1771,7 +1771,7 @@ ESP8266WebServer class will parse the query string and rebuilds its arguments wh
@ -1898,9 +1898,9 @@ ESP8266WebServer class will parse the query string and rebuilds its arguments wh
<h2id="transitions-of-the-custom-web-pages">Transitions of the custom Web pages<aclass="headerlink"href="#transitions-of-the-custom-web-pages"title="Permanent link">¶</a></h2>
<h2id="transitions-of-the-custom-web-pages">Transitions of the custom Web pages<aclass="headerlink"href="#transitions-of-the-custom-web-pages"title="Permanent link">¶</a></h2>
<h3id="scope-lifetime-of-autoconnectaux">Scope & Lifetime of AutoConnectAux<aclass="headerlink"href="#scope-lifetime-of-autoconnectaux"title="Permanent link">¶</a></h3>
<h3id="scope-lifetime-of-autoconnectaux">Scope & Lifetime of AutoConnectAux<aclass="headerlink"href="#scope-lifetime-of-autoconnectaux"title="Permanent link">¶</a></h3>
<p>AutoConnectAux and AutoConnectElements must live while the custom Web pages are available. The implementation of the custom Web page inherits from requestHandler driven from ESP8266WebServer (WebServer for ESP32), so the instance of AutoConnectAux and AutoConnectElements must exist for the duration of effect of handleClient. The following example is incorrect for manipulating custom Web pages. Its AutoConnectAux instance will be destructed at the exit of the setup().</p>
<p>AutoConnectAux and AutoConnectElements must live while the custom Web pages are available. The implementation of the custom Web page inherits from requestHandler driven from ESP8266WebServer (WebServer for ESP32), so the instance of AutoConnectAux and AutoConnectElements must exist for the duration of effect of handleClient. The following example is incorrect for manipulating custom Web pages. Its AutoConnectAux instance will be destructed at the exit of the setup().</p>
@ -1722,9 +1722,9 @@ An example of using each function is as follows.
<h3id="adjust-the-json-document-buffer-size"><iclass="fa fa-caret-right"></i> Adjust the JSON document buffer size<aclass="headerlink"href="#adjust-the-json-document-buffer-size"title="Permanent link">¶</a></h3>
<h3id="adjust-the-json-document-buffer-size"><iclass="fa fa-caret-right"></i> Adjust the JSON document buffer size<aclass="headerlink"href="#adjust-the-json-document-buffer-size"title="Permanent link">¶</a></h3>
<p>AutoConnect uses ArduinoJson library's dynamic buffer to parse JSON documents. Its dynamic buffer allocation scheme depends on the version 5 or version 6 of ArduinoJson library. Either version must have enough buffer to parse the custom web page's JSON document successfully. AutoConnect has the following three constants internally to complete the parsing as much as possible in both ArduinoJson version. These constants are macro defined in <ahref="https://github.com/Hieromon/AutoConnect/blob/master/src/AutoConnectDefs.h">AutoConnectDefs.h</a>.</p>
<p>AutoConnect uses ArduinoJson library's dynamic buffer to parse JSON documents. Its dynamic buffer allocation scheme depends on the version 5 or version 6 of ArduinoJson library. Either version must have enough buffer to parse the custom web page's JSON document successfully. AutoConnect has the following three constants internally to complete the parsing as much as possible in both ArduinoJson version. These constants are macro defined in <ahref="https://github.com/Hieromon/AutoConnect/blob/master/src/AutoConnectDefs.h">AutoConnectDefs.h</a>.</p>
<p>If memory insufficiency occurs during JSON document parsing, you can adjust these constants to avoid insufficiency by using the <ahref="https://arduinojson.org/v6/assistant/">JsonAssistant</a> with deriving the required buffer size in advance.</p>
<p>If memory insufficiency occurs during JSON document parsing, you can adjust these constants to avoid insufficiency by using the <ahref="https://arduinojson.org/v6/assistant/">JsonAssistant</a> with deriving the required buffer size in advance.</p>
<p>The following sketch is an example that implements the above basic steps. The <em>postUpload</em> function is the on-handler and retrieves the AutoConnectFile as named <code>upload_file</code>. You should note that this handler is <strong>not</strong> for a custom Web page placed with its AutoConnectFile element. The uploaded file should be processed by the handler for the transition destination page from the AutoConnectFile element placed page. AutoConnect built-in upload handler will save the uploaded file to the specified device before invoking the <em>postUpload</em> function.</p>
<p>The following sketch is an example that implements the above basic steps. The <em>postUpload</em> function is the on-handler and retrieves the AutoConnectFile as named <code>upload_file</code>. You should note that this handler is <strong>not</strong> for a custom Web page placed with its AutoConnectFile element. The uploaded file should be processed by the handler for the transition destination page from the AutoConnectFile element placed page. AutoConnect built-in upload handler will save the uploaded file to the specified device before invoking the <em>postUpload</em> function.</p>
<p>However, If you use uploaded files in different situations, it may be more appropriate to place the actual handling process outside the handler. It applies for the parameter file, etc. The important thing is that you do not have to sketch file reception and storing logic by using the AutoConnectFile element and the upload handler built into the AutoConnect.</p>
<p>However, If you use uploaded files in different situations, it may be more appropriate to place the actual handling process outside the handler. It applies for the parameter file, etc. The important thing is that you do not have to sketch file reception and storing logic by using the AutoConnectFile element and the upload handler built into the AutoConnect.</p>
<p>The substance of AC_File_FS (fs) is a SPIFFS file system implemented by the ESP8266/ESP32 core, and then AutoConnect uses the Global Instance <strong>SPIFFS</strong> to access SPIFFS.</p>
<p>The substance of AC_File_FS (fs) is a SPIFFS file system implemented by the ESP8266/ESP32 core, and then AutoConnect uses the Global Instance <strong>SPIFFS</strong> to access SPIFFS.</p>
<p>Also, the substance of AC_File_SD (sd) is a FAT file of Arduino SD library ported to the ESP8266/ESP32 core, and then AutoConnect uses the Global Instance <strong>SD</strong> to access SD. When saving to an external SD device, there are additional required parameters for the connection interface and is defined as the macro in AutoConnectDefs.h.</p>
<p>Also, the substance of AC_File_SD (sd) is a FAT file of Arduino SD library ported to the ESP8266/ESP32 core, and then AutoConnect uses the Global Instance <strong>SD</strong> to access SD. When saving to an external SD device, there are additional required parameters for the connection interface and is defined as the macro in AutoConnectDefs.h.</p>
<p><code>AUTOCONNECT_SD_CS</code> defines which GPIO for the CS (Chip Select, or SS as Slave Select) pin. This definition is derived from pins_arduino.h, which is included in the Arduino core distribution. If you want to assign the CS pin to another GPIO, you need to change the macro definition of AutoConnectDefs.h.</p>
<p><code>AUTOCONNECT_SD_CS</code> defines which GPIO for the CS (Chip Select, or SS as Slave Select) pin. This definition is derived from pins_arduino.h, which is included in the Arduino core distribution. If you want to assign the CS pin to another GPIO, you need to change the macro definition of AutoConnectDefs.h.</p>
@ -1219,9 +1219,9 @@
<dd><spanclass="apidef">uploadClass</span><spanclass="apidesc">Specifies the custom upload class instance.</span></dd>
<dd><spanclass="apidef">uploadClass</span><spanclass="apidesc">Specifies the custom upload class instance.</span></dd>
</dl></p>
</dl></p>
<p>The rough structure of the Sketches that completed these implementations will be as follows:</p>
<p>The rough structure of the Sketches that completed these implementations will be as follows:</p>
@ -1370,25 +1370,25 @@ See the <a href="credit.html">Saved credentials access</a> chapter for details o
<p>The Sketch can abort the <ahref="api.html#begin"><em>AutoConnect::begin</em></a> by setting the captive portal timeout and returns control to Sketch. AutoConnect has two parameters for timeout control. One is a timeout value used when trying to connect to the specified AP. It behaves the same as general timeout control in connection attempt by WiFi.begin. This control is specified by the third parameter of <ahref="api.html#begin"><em>AutoConnect::begin</em></a>. The default value is macro defined by <ahref="api.html#defined-macros"><strong>AUTOCONNECT_TIMEOUT</strong></a> in the <strong>AutoConnectDefs.h</strong> file.</p>
<p>The Sketch can abort the <ahref="api.html#begin"><em>AutoConnect::begin</em></a> by setting the captive portal timeout and returns control to Sketch. AutoConnect has two parameters for timeout control. One is a timeout value used when trying to connect to the specified AP. It behaves the same as general timeout control in connection attempt by WiFi.begin. This control is specified by the third parameter of <ahref="api.html#begin"><em>AutoConnect::begin</em></a>. The default value is macro defined by <ahref="api.html#defined-macros"><strong>AUTOCONNECT_TIMEOUT</strong></a> in the <strong>AutoConnectDefs.h</strong> file.</p>
<p>The other timeout control is for the captive portal itself. It is useful when you want to continue sketch execution with offline even if the WiFi connection is not possible. You can also combine it with the <ahref="#on-demand-start-the-captive-portal"><strong>immediateStart</strong></a> option to create sketches with high mobility.</p>
<p>The other timeout control is for the captive portal itself. It is useful when you want to continue sketch execution with offline even if the WiFi connection is not possible. You can also combine it with the <ahref="#on-demand-start-the-captive-portal"><strong>immediateStart</strong></a> option to create sketches with high mobility.</p>
<p>The timeout of the captive portal is specified together with <ahref="apiconfig.html#portaltimeout"><em>AutoConnectConfig::portalTimeout</em></a> as follows.</p>
<p>The timeout of the captive portal is specified together with <ahref="apiconfig.html#portaltimeout"><em>AutoConnectConfig::portalTimeout</em></a> as follows.</p>
<spanstyle="background-color: #49483e"><spanstyle="color: #f8f8f2">config.portalTimeout</span><spanstyle="color: #f92672">=</span><spanstyle="color: #ae81ff">60000</span><spanstyle="color: #f8f8f2">;</span><spanstyle="color: #7a7a7a">// It will time out in 60 seconds</span>
<spanstyle="background-color: #49483e"><spanstyle="color: #f8f8f2">config.portalTimeout</span><spanstyle="color: #f92672">=</span><spanstyle="color: #ae81ff">60000</span><spanstyle="color: #f8f8f2">;</span><spanstyle="color: #75715e">// It will time out in 60 seconds</span>
<spanstyle="color: #f8f8f2">config.portalTimeout</span><spanstyle="color: #f92672">=</span><spanstyle="color: #ae81ff">60000</span><spanstyle="color: #f8f8f2">;</span><spanstyle="color: #7a7a7a">// It will time out in 60 seconds</span>
<spanstyle="color: #f8f8f2">config.portalTimeout</span><spanstyle="color: #f92672">=</span><spanstyle="color: #ae81ff">60000</span><spanstyle="color: #f8f8f2">;</span><spanstyle="color: #75715e">// It will time out in 60 seconds</span>
@ -1419,15 +1419,15 @@ Also, if you want to stop AutoConnect completely when the captive portal is time
</code></pre></div>
</code></pre></div>
<p>There is another option related to timeout in AutoConnectConfig. It can make use of the captive portal function even after a timeout. The <ahref="apiconfig.html#retainportal"><em>AutoConnectConfig::retainPortal</em></a> option will not stop the SoftAP when the captive portal is timed out. If you enable the ratainPortal option, you can try to connect to the AP at any time while continuing to sketch execution with offline even after the captive portal timed-out. Compared to the above code specified no option with the following example code, the captive portal will remain available even after a timeout without changing the logic of the Sketch.</p>
<p>There is another option related to timeout in AutoConnectConfig. It can make use of the captive portal function even after a timeout. The <ahref="apiconfig.html#retainportal"><em>AutoConnectConfig::retainPortal</em></a> option will not stop the SoftAP when the captive portal is timed out. If you enable the ratainPortal option, you can try to connect to the AP at any time while continuing to sketch execution with offline even after the captive portal timed-out. Compared to the above code specified no option with the following example code, the captive portal will remain available even after a timeout without changing the logic of the Sketch.</p>
<spanstyle="color: #f8f8f2">config.portalTimeout</span><spanstyle="color: #f92672">=</span><spanstyle="color: #ae81ff">60000</span><spanstyle="color: #f8f8f2">;</span><spanstyle="color: #7a7a7a">// It will time out in 60 seconds</span>
<spanstyle="color: #f8f8f2">config.portalTimeout</span><spanstyle="color: #f92672">=</span><spanstyle="color: #ae81ff">60000</span><spanstyle="color: #f8f8f2">;</span><spanstyle="color: #75715e">// It will time out in 60 seconds</span>
<spanstyle="color: #f8f8f2">portal.handleClient();</span><spanstyle="color: #7a7a7a">// Step #6 as the above procedure</span>
<spanstyle="color: #f8f8f2">portal.handleClient();</span><spanstyle="color: #75715e">// Step #6 as the above procedure</span>
<spanstyle="color: #f8f8f2">}</span>
<spanstyle="color: #f8f8f2">}</span>
</code></pre></div>
</code></pre></div>
@ -1503,15 +1503,15 @@ Also, if you want to stop AutoConnect completely when the captive portal is time
<li>
<li>
<p>Overwrite the label literal of library source code directly.</p>
<p>Overwrite the label literal of library source code directly.</p>
<p>You can change the label of the AutoConnect menu item by rewriting the default label literal in <ahref="https://github.com/Hieromon/AutoConnect/blob/master/src/AutoConnectLabels.h">AutoConnectLabels.h</a> macros. However, changing menu items literal influences all the Sketch's build scenes.</p>
<p>You can change the label of the AutoConnect menu item by rewriting the default label literal in <ahref="https://github.com/Hieromon/AutoConnect/blob/master/src/AutoConnectLabels.h">AutoConnectLabels.h</a> macros. However, changing menu items literal influences all the Sketch's build scenes.</p>
<divclass="codehilite"style="background: #272822"><prestyle="line-height: 125%"><span></span><code><spanstyle="color: #7a7a7a">#define AUTOCONNECT_MENULABEL_CONFIGNEW "Configure new AP"</span>
<divclass="codehilite"style="background: #272822"><prestyle="line-height: 125%"><span></span><code><spanstyle="color: #75715e">#define AUTOCONNECT_MENULABEL_CONFIGNEW "Configure new AP"</span>
@ -1528,9 +1528,9 @@ And PlatformIO is a build system. Library sources will not be compiled unless Au
</ol>
</ol>
<h3id="combination-with-mdns"><iclass="fa fa-caret-right"></i> Combination with mDNS<aclass="headerlink"href="#combination-with-mdns"title="Permanent link">¶</a></h3>
<h3id="combination-with-mdns"><iclass="fa fa-caret-right"></i> Combination with mDNS<aclass="headerlink"href="#combination-with-mdns"title="Permanent link">¶</a></h3>
<p>With <ahref="https://github.com/esp8266/Arduino/tree/master/libraries/ESP8266mDNS">mDNS library</a>, you can access to ESP8266 by name instead of IP address after connection. The Sketch can start the MDNS responder after <ahref="api.html#begin"><em>AutoConnect::begin</em></a>.</p>
<p>With <ahref="https://github.com/esp8266/Arduino/tree/master/libraries/ESP8266mDNS">mDNS library</a>, you can access to ESP8266 by name instead of IP address after connection. The Sketch can start the MDNS responder after <ahref="api.html#begin"><em>AutoConnect::begin</em></a>.</p>
<p>You can output AutoConnect monitor messages to the <strong>Serial</strong>. A monitor message activation switch is in an include header file <ahref="https://github.com/Hieromon/AutoConnect/blob/master/src/AutoConnectDefs.h">AutoConnectDefs.h</a> of library source. Define <ahref="https://github.com/Hieromon/AutoConnect/blob/master/src/AutoConnectDefs.h#L14"><strong>AC_DEBUG</strong></a> macro to output the monitor messages.<supid="fnref:1"><aclass="footnote-ref"href="#fn:1">1</a></sup></p>
<p>You can output AutoConnect monitor messages to the <strong>Serial</strong>. A monitor message activation switch is in an include header file <ahref="https://github.com/Hieromon/AutoConnect/blob/master/src/AutoConnectDefs.h">AutoConnectDefs.h</a> of library source. Define <ahref="https://github.com/Hieromon/AutoConnect/blob/master/src/AutoConnectDefs.h#L14"><strong>AC_DEBUG</strong></a> macro to output the monitor messages.<supid="fnref:1"><aclass="footnote-ref"href="#fn:1">1</a></sup></p>
<h3id="disable-the-captive-portal"><iclass="fa fa-caret-right"></i> Disable the captive portal<aclass="headerlink"href="#disable-the-captive-portal"title="Permanent link">¶</a></h3>
<h3id="disable-the-captive-portal"><iclass="fa fa-caret-right"></i> Disable the captive portal<aclass="headerlink"href="#disable-the-captive-portal"title="Permanent link">¶</a></h3>
@ -1632,8 +1632,8 @@ Combining these two parameters allows you to filter the destination AP when mult
<p>You can use this template if the ESP module does not connect to WiFi at an ordinal situation and need to establish by a manual trigger. In this case, it is desirable that AutoConnect not start until an external switch fires. This behavior is similar to the <ahref="https://github.com/tzapu/WiFiManager#on-demand-configuration-portal">WiFiManager's startConfigPortal</a> function.<br/>
<p>You can use this template if the ESP module does not connect to WiFi at an ordinal situation and need to establish by a manual trigger. In this case, it is desirable that AutoConnect not start until an external switch fires. This behavior is similar to the <ahref="https://github.com/tzapu/WiFiManager#on-demand-configuration-portal">WiFiManager's startConfigPortal</a> function.<br/>
<ahref="apiconfig.html#immediatestart"><em>AutoConnectConfig::immediateStart</em></a> is an option to launch the portal by the SoftAP immediately without attempting 1<sup>st</sup>-WiFi.begin. Also, by setting the <ahref="apiconfig.html#autorise"><em>AutoConnectConfig::autoRise</em></a> option to false, it is possible to suppress unintended automatic pop-ups of the portal screen when connecting to an ESP module SSID.<br/>
<ahref="apiconfig.html#immediatestart"><em>AutoConnectConfig::immediateStart</em></a> is an option to launch the portal by the SoftAP immediately without attempting 1<sup>st</sup>-WiFi.begin. Also, by setting the <ahref="apiconfig.html#autorise"><em>AutoConnectConfig::autoRise</em></a> option to false, it is possible to suppress unintended automatic pop-ups of the portal screen when connecting to an ESP module SSID.<br/>
To implement this, execute AutoConnect::config within the <strong>setup()</strong> function as usual, and handle AutoConnect::begin inside the <strong>loop()</strong> function.</p>
To implement this, execute AutoConnect::config within the <strong>setup()</strong> function as usual, and handle AutoConnect::begin inside the <strong>loop()</strong> function.</p>
<divclass="codehilite"style="background: #272822"><prestyle="line-height: 125%"><span></span><code><spanstyle="color: #7a7a7a">#define TRIGGER_PIN 5 // Trigger switch should be LOW active.</span>
<divclass="codehilite"style="background: #272822"><prestyle="line-height: 125%"><span></span><code><spanstyle="color: #75715e">#define TRIGGER_PIN 5 // Trigger switch should be LOW active.</span>
</span><spanstyle="color: #7a7a7a">// Config.autoRise = false; // If you don't need to automatically pop-up the portal when connected to the ESP module's SSID.</span>
</span><spanstyle="color: #75715e">// Config.autoRise = false; // If you don't need to automatically pop-up the portal when connected to the ESP module's SSID.</span>
@ -1743,9 +1743,9 @@ Known access point credentials are saved by AutoConnect, to the ESP module can u
</div>
</div>
<h3id="usage-for-automatically-instantiated-esp8266webserverwebserver"><iclass="fa fa-caret-right"></i> Usage for automatically instantiated ESP8266WebServer/WebServer<aclass="headerlink"href="#usage-for-automatically-instantiated-esp8266webserverwebserver"title="Permanent link">¶</a></h3>
<h3id="usage-for-automatically-instantiated-esp8266webserverwebserver"><iclass="fa fa-caret-right"></i> Usage for automatically instantiated ESP8266WebServer/WebServer<aclass="headerlink"href="#usage-for-automatically-instantiated-esp8266webserverwebserver"title="Permanent link">¶</a></h3>
<p>The Sketch can handle URL requests using ESP8266WebServer or WebServer that AutoConnect started internally. ESP8266WebServer/WebServer instantiated dynamically by AutoConnect can be referred to by <ahref="api.html#host"><em>AutoConnect::host</em></a> function. The Sketch can use the '<strong>on</strong>' function, '<strong>send</strong>' function, '<strong>client</strong>' function and others by ESP8266WebServer/WebServer reference of its return value.</p>
<p>The Sketch can handle URL requests using ESP8266WebServer or WebServer that AutoConnect started internally. ESP8266WebServer/WebServer instantiated dynamically by AutoConnect can be referred to by <ahref="api.html#host"><em>AutoConnect::host</em></a> function. The Sketch can use the '<strong>on</strong>' function, '<strong>send</strong>' function, '<strong>client</strong>' function and others by ESP8266WebServer/WebServer reference of its return value.</p>
@ -1936,7 +1936,7 @@ But this method is not recommended. The broadcast radio of SSID emitted from Sof
</div>
</div>
<h3id="relocate-the-autoconnect-home-path"><iclass="fa fa-caret-right"></i> Relocate the AutoConnect home path<aclass="headerlink"href="#relocate-the-autoconnect-home-path"title="Permanent link">¶</a></h3>
<h3id="relocate-the-autoconnect-home-path"><iclass="fa fa-caret-right"></i> Relocate the AutoConnect home path<aclass="headerlink"href="#relocate-the-autoconnect-home-path"title="Permanent link">¶</a></h3>
<p>A home path of AutoConnect is <strong>/_ac</strong> by default. You can access from the browser with <ahref="http://IPADDRESS/">http://IPADDRESS/</a>_ac. You can change the home path by revising <ahref="https://github.com/Hieromon/AutoConnect/blob/master/src/AutoConnectDefs.h#L69"><strong>AUTOCONNECT_URI</strong></a> macro in the include header file as <ahref="https://github.com/Hieromon/AutoConnect/blob/master/src/AutoConnectDefs.h">AutoConnectDefs.h</a>.</p>
<p>A home path of AutoConnect is <strong>/_ac</strong> by default. You can access from the browser with <ahref="http://IPADDRESS/">http://IPADDRESS/</a>_ac. You can change the home path by revising <ahref="https://github.com/Hieromon/AutoConnect/blob/master/src/AutoConnectDefs.h#L69"><strong>AUTOCONNECT_URI</strong></a> macro in the include header file as <ahref="https://github.com/Hieromon/AutoConnect/blob/master/src/AutoConnectDefs.h">AutoConnectDefs.h</a>.</p>
@ -1146,9 +1146,9 @@ Get vector of reference of all elements.
<dd>A reference to std::vector of reference to AutoConnecctElements.</dd>
<dd>A reference to std::vector of reference to AutoConnecctElements.</dd>
</dl></p>
</dl></p>
<p>The getElements returns a reference to std::vector of reference to AutoConnecctElements. This function is provided to handle AutoConnectElemets owned by AutoConnectAux in bulk, and you can use each method of std::vector for a return value.</p>
<p>The getElements returns a reference to std::vector of reference to AutoConnecctElements. This function is provided to handle AutoConnectElemets owned by AutoConnectAux in bulk, and you can use each method of std::vector for a return value.</p>
<divclass="codehilite"style="background: #272822"><prestyle="line-height: 125%"><span></span><code><spanstyle="color: #7a7a7a">// An example of getting type and name of all AutoConnectElements registered in AutoConnectAux.</span>
<divclass="codehilite"style="background: #272822"><prestyle="line-height: 125%"><span></span><code><spanstyle="color: #75715e">// An example of getting type and name of all AutoConnectElements registered in AutoConnectAux.</span>
<spanstyle="color: #f8f8f2">Serial.printf(</span><spanstyle="color: #e6db74">"name<%s> as type %d</span><spanstyle="color: #ae81ff">\n</span><spanstyle="color: #e6db74">"</span><spanstyle="color: #f8f8f2">,</span><spanstyle="color: #f8f8f2">elm.name.c_str(),</span><spanstyle="color: #f8f8f2">(</span><spanstyle="color: #66d9ef">int</span><spanstyle="color: #f8f8f2">)elm.typeOf());</span>
<spanstyle="color: #f8f8f2">Serial.printf(</span><spanstyle="color: #e6db74">"name<%s> as type %d</span><spanstyle="color: #ae81ff">\n</span><spanstyle="color: #e6db74">"</span><spanstyle="color: #f8f8f2">,</span><spanstyle="color: #f8f8f2">elm.name.c_str(),</span><spanstyle="color: #f8f8f2">(</span><spanstyle="color: #66d9ef">int</span><spanstyle="color: #f8f8f2">)elm.typeOf());</span>
@ -1361,11 +1361,11 @@ Sets the value of the specified AutoConnectElement. If values is specified
<pclass="admonition-title">You can directly access the value member variable.</p>
<pclass="admonition-title">You can directly access the value member variable.</p>
<p>If you are gripping with the Sketch to the AutoConnectElements of the target that sets the value, you can access the value member variable directly. The following sketch code has the same effect.
<p>If you are gripping with the Sketch to the AutoConnectElements of the target that sets the value, you can access the value member variable directly. The following sketch code has the same effect.
<spanstyle="color: #f8f8f2">AutoConnectConfig</span><spanstyle="color: #a6e22e">Config</span><spanstyle="color: #f8f8f2">(</span><spanstyle="color: #e6db74">""</span><spanstyle="color: #f8f8f2">,</span><spanstyle="color: #e6db74">"passpass"</span><spanstyle="color: #f8f8f2">);</span><spanstyle="color: #7a7a7a">// SoftAp name is determined at runtime</span>
<spanstyle="color: #f8f8f2">AutoConnectConfig</span><spanstyle="color: #a6e22e">Config</span><spanstyle="color: #f8f8f2">(</span><spanstyle="color: #e6db74">""</span><spanstyle="color: #f8f8f2">,</span><spanstyle="color: #e6db74">"passpass"</span><spanstyle="color: #f8f8f2">);</span><spanstyle="color: #75715e">// SoftAp name is determined at runtime</span>
<spanstyle="color: #f8f8f2">Config.apid</span><spanstyle="color: #f92672">=</span><spanstyle="color: #f8f8f2">ESP.hostname();</span><spanstyle="color: #7a7a7a">// Retrieve host name to SotAp identification</span>
<spanstyle="color: #f8f8f2">Config.apid</span><spanstyle="color: #f92672">=</span><spanstyle="color: #f8f8f2">ESP.hostname();</span><spanstyle="color: #75715e">// Retrieve host name to SotAp identification</span>
<spanstyle="color: #f8f8f2">Config.autoSave</span><spanstyle="color: #f92672">=</span><spanstyle="color: #f8f8f2">AC_SAVECREDENTIAL_NEVER;</span><spanstyle="color: #7a7a7a">// No save credential</span>
<spanstyle="color: #f8f8f2">Config.autoSave</span><spanstyle="color: #f92672">=</span><spanstyle="color: #f8f8f2">AC_SAVECREDENTIAL_NEVER;</span><spanstyle="color: #75715e">// No save credential</span>
<spanstyle="color: #f8f8f2">Config.boundaryOffset</span><spanstyle="color: #f92672">=</span><spanstyle="color: #ae81ff">64</span><spanstyle="color: #f8f8f2">;</span><spanstyle="color: #7a7a7a">// Reserve 64 bytes for the user data in EEPROM.</span>
<spanstyle="color: #f8f8f2">Config.boundaryOffset</span><spanstyle="color: #f92672">=</span><spanstyle="color: #ae81ff">64</span><spanstyle="color: #f8f8f2">;</span><spanstyle="color: #75715e">// Reserve 64 bytes for the user data in EEPROM.</span>
<spanstyle="color: #f8f8f2">Config.portalTimeout</span><spanstyle="color: #f92672">=</span><spanstyle="color: #ae81ff">60000</span><spanstyle="color: #f8f8f2">;</span><spanstyle="color: #7a7a7a">// Sets timeout value for the captive portal</span>
<spanstyle="color: #f8f8f2">Config.portalTimeout</span><spanstyle="color: #f92672">=</span><spanstyle="color: #ae81ff">60000</span><spanstyle="color: #f8f8f2">;</span><spanstyle="color: #75715e">// Sets timeout value for the captive portal</span>
<spanstyle="color: #f8f8f2">Config.retainPortal</span><spanstyle="color: #f92672">=</span><spanstyle="color: #f8f8f2">true;</span><spanstyle="color: #7a7a7a">// Retains the portal function after timed-out</span>
<spanstyle="color: #f8f8f2">Config.retainPortal</span><spanstyle="color: #f92672">=</span><spanstyle="color: #f8f8f2">true;</span><spanstyle="color: #75715e">// Retains the portal function after timed-out</span>
<spanstyle="color: #f8f8f2">Config.homeUri</span><spanstyle="color: #f92672">=</span><spanstyle="color: #e6db74">"/index.html"</span><spanstyle="color: #f8f8f2">;</span><spanstyle="color: #7a7a7a">// Sets home path of Sketch application</span>
<spanstyle="color: #f8f8f2">Config.homeUri</span><spanstyle="color: #f92672">=</span><spanstyle="color: #e6db74">"/index.html"</span><spanstyle="color: #f8f8f2">;</span><spanstyle="color: #75715e">// Sets home path of Sketch application</span>
<spanstyle="color: #f8f8f2">Config.title</span><spanstyle="color: #f92672">=</span><spanstyle="color: #e6db74">"My menu"</span><spanstyle="color: #f8f8f2">;</span><spanstyle="color: #7a7a7a">// Customize the menu title</span>
<spanstyle="color: #f8f8f2">Config.title</span><spanstyle="color: #f92672">=</span><spanstyle="color: #e6db74">"My menu"</span><spanstyle="color: #f8f8f2">;</span><spanstyle="color: #75715e">// Customize the menu title</span>
<p>The definition of label text must conform to a certain coding pattern. Undefine with <code>#undef</code> the <code>#define</code> directive corresponding to the above IDs, and then redefine the ID with the replacement text. And surround it with <code>#ifdef</code> ~ <code>#endif</code>.</p>
<p>The definition of label text must conform to a certain coding pattern. Undefine with <code>#undef</code> the <code>#define</code> directive corresponding to the above IDs, and then redefine the ID with the replacement text. And surround it with <code>#ifdef</code> ~ <code>#endif</code>.</p>
<p>You may not need to rewrite all definitions. It depends on your wishes and is sufficient that the above the include file contains only the labels you need.</p>
<p>You may not need to rewrite all definitions. It depends on your wishes and is sufficient that the above the include file contains only the labels you need.</p>
<p>If you are using an Arduino core for ESP32 1.0.2 earlier and need to use credentials in EEPROM for backward compatibility, turns off the <strong>AUTOCONNECT_USE_PREFERENCES</strong><supid="fnref:3"><aclass="footnote-ref"href="#fn:3">3</a></sup> macro definition in <code>AutoConnectCredentials.h</code> file. AutoConnect behaves assuming that credentials are stored in EEPROM if <code>AUTOCONNECT_USE_PREFERENCES</code> is not defined.</p>
<p>If you are using an Arduino core for ESP32 1.0.2 earlier and need to use credentials in EEPROM for backward compatibility, turns off the <strong>AUTOCONNECT_USE_PREFERENCES</strong><supid="fnref:3"><aclass="footnote-ref"href="#fn:3">3</a></sup> macro definition in <code>AutoConnectCredentials.h</code> file. AutoConnect behaves assuming that credentials are stored in EEPROM if <code>AUTOCONNECT_USE_PREFERENCES</code> is not defined.</p>
@ -999,7 +999,7 @@ You can shorten it and write as like:
</code></pre></div></p>
</code></pre></div></p>
<h3id="date-time"><iclass="fa fa-exchange"></i> Date & Time<aclass="headerlink"href="#date-time"title="Permanent link">¶</a></h3>
<h3id="date-time"><iclass="fa fa-exchange"></i> Date & Time<aclass="headerlink"href="#date-time"title="Permanent link">¶</a></h3>
<p>The easiest way is to use the <ahref="https://www.pjrc.com/teensy/td_libs_Time.html">Arduino Time Library</a>. Sketches must accommodate differences in date and time formats depending on the time zone. You can absorb the difference in DateTime format by using <code>sscanf</code> function.<supid="fnref:1"><aclass="footnote-ref"href="#fn:1">1</a></sup></p>
<p>The easiest way is to use the <ahref="https://www.pjrc.com/teensy/td_libs_Time.html">Arduino Time Library</a>. Sketches must accommodate differences in date and time formats depending on the time zone. You can absorb the difference in DateTime format by using <code>sscanf</code> function.<supid="fnref:1"><aclass="footnote-ref"href="#fn:1">1</a></sup></p>
@ -1026,9 +1026,9 @@ You can shorten it and write as like:
<p>To convert input data correctly from the string, it must match its format. The validation implementation with sketches depends on various perspectives. Usually, the tiny devices have no enough power for the lexical analysis completely. But you can reduce the burden for data verification using the <ahref="achandling.html#check-data-against-on-submission"><strong>pattern</strong></a> of AutoConnectInput.</p>
<p>To convert input data correctly from the string, it must match its format. The validation implementation with sketches depends on various perspectives. Usually, the tiny devices have no enough power for the lexical analysis completely. But you can reduce the burden for data verification using the <ahref="achandling.html#check-data-against-on-submission"><strong>pattern</strong></a> of AutoConnectInput.</p>
<p>By giving a <ahref="acelements.html#pattern">pattern</a> to <ahref="apielements.html#pattern">AutoConnectInput</a>, you can find errors in data format while typing in custom Web pages. Specifying the input data rule as a <ahref="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions">regular expression</a> will validate the type match during input. If there is an error in the format during input, the background color of the field will change to pink. Refer to section <ahref="achandling.html#check-data-against-on-submission"><em>Handling the custom Web pages</em></a>.</p>
<p>By giving a <ahref="acelements.html#pattern">pattern</a> to <ahref="apielements.html#pattern">AutoConnectInput</a>, you can find errors in data format while typing in custom Web pages. Specifying the input data rule as a <ahref="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions">regular expression</a> will validate the type match during input. If there is an error in the format during input, the background color of the field will change to pink. Refer to section <ahref="achandling.html#check-data-against-on-submission"><em>Handling the custom Web pages</em></a>.</p>
<p>However, input data will be transmitted even if the value does not match the pattern. Sketches require the validation of the received data. You can use the <ahref="apielements.html#isvalid">AutoConnectInput::isValid</a> function to validate it. The isValid function validates whether the value member variable matches a pattern and returns true or false.</p>
<p>However, input data will be transmitted even if the value does not match the pattern. Sketches require the validation of the received data. You can use the <ahref="apielements.html#isvalid">AutoConnectInput::isValid</a> function to validate it. The isValid function validates whether the value member variable matches a pattern and returns true or false.</p>
@ -1290,7 +1290,7 @@ For AutoConnect menus to work properly, call <a href="api.html#handlerequest"><e
<li>
<li>
<p>Disable an AutoConnectUpdate feature if you don't need.</p>
<p>Disable an AutoConnectUpdate feature if you don't need.</p>
<p>You can disable the AutoConnectUpdate feature by commenting out the <ahref="https://github.com/Hieromon/AutoConnect/blob/master/src/AutoConnectDefs.h#L34"><strong>AUTOCONNECT_USE_UPDATE</strong></a> macro in the <ahref="api.html#defined-macros"><code>AutoConnectDefs.h</code></a> header file.
<p>You can disable the AutoConnectUpdate feature by commenting out the <ahref="https://github.com/Hieromon/AutoConnect/blob/master/src/AutoConnectDefs.h#L34"><strong>AUTOCONNECT_USE_UPDATE</strong></a> macro in the <ahref="api.html#defined-macros"><code>AutoConnectDefs.h</code></a> header file.
@ -1329,7 +1329,7 @@ You have the following two options to avoid this conflict:</p>
<h2id="does-not-appear-esp8266ap-in-smartphone"><iclass="fa fa-question-circle"></i> Does not appear esp8266ap in smartphone.<aclass="headerlink"href="#does-not-appear-esp8266ap-in-smartphone"title="Permanent link">¶</a></h2>
<h2id="does-not-appear-esp8266ap-in-smartphone"><iclass="fa fa-question-circle"></i> Does not appear esp8266ap in smartphone.<aclass="headerlink"href="#does-not-appear-esp8266ap-in-smartphone"title="Permanent link">¶</a></h2>
<p>Maybe it is successfully connected at the <ahref="lsbegin.html#autoconnectbegin-logic-sequence"><strong>first WiFi.begin</strong></a>. ESP8266 remembers the last SSID successfully connected and will use at the next. It means SoftAP will only start up when the first <em>WiFi.begin()</em> fails.</p>
<p>Maybe it is successfully connected at the <ahref="lsbegin.html#autoconnectbegin-logic-sequence"><strong>first WiFi.begin</strong></a>. ESP8266 remembers the last SSID successfully connected and will use at the next. It means SoftAP will only start up when the first <em>WiFi.begin()</em> fails.</p>
<p>The saved SSID would be cleared by <em>WiFi.disconnect()</em> with WIFI_STA mode. If you do not want automatic reconnection, you can erase the memorized SSID with the following simple sketch.</p>
<p>The saved SSID would be cleared by <em>WiFi.disconnect()</em> with WIFI_STA mode. If you do not want automatic reconnection, you can erase the memorized SSID with the following simple sketch.</p>
@ -1390,7 +1390,7 @@ You have the following two options to avoid this conflict:</p>
<p>You can use the <ahref="api.html#ondetect">AutoConnect::onDetect</a> exit routine. For more details and an implementation example of the onDetect exit routine, refer to the chapter "<ahref="advancedusage.html#captive-portal-start-detection">Captive portal start detection</a>".</p>
<p>You can use the <ahref="api.html#ondetect">AutoConnect::onDetect</a> exit routine. For more details and an implementation example of the onDetect exit routine, refer to the chapter "<ahref="advancedusage.html#captive-portal-start-detection">Captive portal start detection</a>".</p>
<h2id="how-change-http-port"><iclass="fa fa-question-circle"></i> How change HTTP port?<aclass="headerlink"href="#how-change-http-port"title="Permanent link">¶</a></h2>
<h2id="how-change-http-port"><iclass="fa fa-question-circle"></i> How change HTTP port?<aclass="headerlink"href="#how-change-http-port"title="Permanent link">¶</a></h2>
<p>HTTP port number is defined as a macro in <ahref="https://github.com/Hieromon/AutoConnect/blob/master/src/AutoConnectDefs.h#L123">AutoConnectDefs.h</a> header file. You can change it directly with several editors and must re-compile.</p>
<p>HTTP port number is defined as a macro in <ahref="https://github.com/Hieromon/AutoConnect/blob/master/src/AutoConnectDefs.h#L123">AutoConnectDefs.h</a> header file. You can change it directly with several editors and must re-compile.</p>
<h2id="how-change-ssid-or-password-in-captive-portal"><iclass="fa fa-question-circle"></i> How change SSID or Password in Captive portal?<aclass="headerlink"href="#how-change-ssid-or-password-in-captive-portal"title="Permanent link">¶</a></h2>
<h2id="how-change-ssid-or-password-in-captive-portal"><iclass="fa fa-question-circle"></i> How change SSID or Password in Captive portal?<aclass="headerlink"href="#how-change-ssid-or-password-in-captive-portal"title="Permanent link">¶</a></h2>
@ -1399,7 +1399,7 @@ You have the following two options to avoid this conflict:</p>
<p>If you don't use ArduinoJson at all, you can detach it from the library. By detaching ArduinoJson, the binary size after compilation can be reduced. You can implement custom Web pages with your sketches without using ArduinoJson. Its method is described in <ahref="wojson.html">Custom Web pages w/o JSON</a>.<br/>
<p>If you don't use ArduinoJson at all, you can detach it from the library. By detaching ArduinoJson, the binary size after compilation can be reduced. You can implement custom Web pages with your sketches without using ArduinoJson. Its method is described in <ahref="wojson.html">Custom Web pages w/o JSON</a>.<br/>
To completely remove ArduinoJson at compile-time from the binary, you need to define a special <code>#define</code> directive for it. And if you define the directive, you will not be able to use the <ahref="otaserver.html#updates-with-the-update-server">OTA update with the update server</a> feature as well as AutoConnectAux described by JSON.</p>
To completely remove ArduinoJson at compile-time from the binary, you need to define a special <code>#define</code> directive for it. And if you define the directive, you will not be able to use the <ahref="otaserver.html#updates-with-the-update-server">OTA update with the update server</a> feature as well as AutoConnectAux described by JSON.</p>
<p>To exclude ArduinoJson at compile-time, give the following <code>#define</code> directive as a compiler option such as the <ahref="https://github.com/arduino/arduino-cli">arduino-cli</a> or <ahref="https://platformio.org/">PlatformIO</a>.</p>
<p>To exclude ArduinoJson at compile-time, give the following <code>#define</code> directive as a compiler option such as the <ahref="https://github.com/arduino/arduino-cli">arduino-cli</a> or <ahref="https://platformio.org/">PlatformIO</a>.</p>
<p>For example, add the following description to the <code>[env]</code> section of the <code>platformio.ini</code> file with the <code>build-flags</code>.</p>
<p>For example, add the following description to the <code>[env]</code> section of the <code>platformio.ini</code> file with the <code>build-flags</code>.</p>
@ -1451,9 +1451,9 @@ Also, you can check the memory running out status by rebuilding the Sketch with
<spanstyle="color: #f8f8f2">config.channel</span><spanstyle="color: #f92672">=</span><spanstyle="color: #ae81ff">3</span><spanstyle="color: #f8f8f2">;</span><spanstyle="color: #7a7a7a">// Specifies a channel number that matches the AP</span>
<spanstyle="color: #f8f8f2">config.channel</span><spanstyle="color: #f92672">=</span><spanstyle="color: #ae81ff">3</span><spanstyle="color: #f8f8f2">;</span><spanstyle="color: #75715e">// Specifies a channel number that matches the AP</span>
<spanstyle="color: #f8f8f2">portal.begin();</span><spanstyle="color: #7a7a7a">// Start the portal</span>
<spanstyle="color: #f8f8f2">portal.begin();</span><spanstyle="color: #75715e">// Start the portal</span>
</code></pre></div>
</code></pre></div>
<divclass="admonition info">
<divclass="admonition info">
@ -1470,11 +1470,11 @@ Also, you can check the memory running out status by rebuilding the Sketch with
<h3id="3-turn-on-the-debug-log-options">3. Turn on the debug log options<aclass="headerlink"href="#3-turn-on-the-debug-log-options"title="Permanent link">¶</a></h3>
<h3id="3-turn-on-the-debug-log-options">3. Turn on the debug log options<aclass="headerlink"href="#3-turn-on-the-debug-log-options"title="Permanent link">¶</a></h3>
<p>To fully enable for the AutoConnect debug logging options, change the following two files.</p>
<p>To fully enable for the AutoConnect debug logging options, change the following two files.</p>
<h3id="4-reports-the-issue-to-autoconnect-github-repository">4. Reports the issue to AutoConnect Github repository<aclass="headerlink"href="#4-reports-the-issue-to-autoconnect-github-repository"title="Permanent link">¶</a></h3>
<h3id="4-reports-the-issue-to-autoconnect-github-repository">4. Reports the issue to AutoConnect Github repository<aclass="headerlink"href="#4-reports-the-issue-to-autoconnect-github-repository"title="Permanent link">¶</a></h3>
<h2id="lets-do-the-most-simple-sketch">Let's do the most simple sketch<aclass="headerlink"href="#lets-do-the-most-simple-sketch"title="Permanent link">¶</a></h2>
<h2id="lets-do-the-most-simple-sketch">Let's do the most simple sketch<aclass="headerlink"href="#lets-do-the-most-simple-sketch"title="Permanent link">¶</a></h2>
<p>Open the Arduino IDE, write the following sketch and upload it. The feature of this sketch is that the SSID and Password are not coded.</p>
<p>Open the Arduino IDE, write the following sketch and upload it. The feature of this sketch is that the SSID and Password are not coded.</p>
<divclass="codehilite"style="background: #272822"><prestyle="line-height: 125%"><span></span><code><spanstyle="color: #7a7a7a">#include</span><spanstyle="color: #7a7a7a"><ESP8266WiFi.h> // Replace with WiFi.h for ESP32</span>
<divclass="codehilite"style="background: #272822"><prestyle="line-height: 125%"><span></span><code><spanstyle="color: #75715e">#include</span><spanstyle="color: #75715e"><ESP8266WiFi.h> // Replace with WiFi.h for ESP32</span>
<spanstyle="color: #7a7a7a">#include</span><spanstyle="color: #7a7a7a"><ESP8266WebServer.h> // Replace with WebServer.h for ESP32</span>
<spanstyle="color: #75715e">#include</span><spanstyle="color: #75715e"><ESP8266WebServer.h> // Replace with WebServer.h for ESP32</span>
<spanstyle="color: #f8f8f2">ESP8266WebServer</span><spanstyle="color: #f8f8f2">Server;</span><spanstyle="color: #7a7a7a">// Replace with WebServer for ESP32</span>
<spanstyle="color: #f8f8f2">ESP8266WebServer</span><spanstyle="color: #f8f8f2">Server;</span><spanstyle="color: #75715e">// Replace with WebServer for ESP32</span>
<p>The complete code of the Sketch is <ahref="https://github.com/Hieromon/AutoConnect/blob/master/examples/mqttRSSI/mqttRSSI.ino">mqttRSSI.ino</a> in the <ahref="https://github.com/Hieromon/AutoConnect">AutoConnect repository</a>. Replace the following #define in a sketch with <strong>User API Key</strong>, <strong>Write API Key</strong> and <strong>Channel ID</strong>. After Keys updated, compile the Sketch and upload it.</p>
<p>The complete code of the Sketch is <ahref="https://github.com/Hieromon/AutoConnect/blob/master/examples/mqttRSSI/mqttRSSI.ino">mqttRSSI.ino</a> in the <ahref="https://github.com/Hieromon/AutoConnect">AutoConnect repository</a>. Replace the following #define in a sketch with <strong>User API Key</strong>, <strong>Write API Key</strong> and <strong>Channel ID</strong>. After Keys updated, compile the Sketch and upload it.</p>
<divclass="codehilite"style="background: #272822"><prestyle="line-height: 125%"><span></span><code><spanstyle="color: #7a7a7a">#define MQTT_USER_KEY "****************" // Replace to User API Key.</span>
<divclass="codehilite"style="background: #272822"><prestyle="line-height: 125%"><span></span><code><spanstyle="color: #75715e">#define MQTT_USER_KEY "****************" // Replace to User API Key.</span>
<spanstyle="color: #7a7a7a">#define CHANNEL_ID "******" // Replace to Channel ID.</span>
<spanstyle="color: #75715e">#define CHANNEL_ID "******" // Replace to Channel ID.</span>
<spanstyle="color: #7a7a7a">#define CHANNEL_API_KEY_WR "****************" // Replace to the write API Key.</span>
<spanstyle="color: #75715e">#define CHANNEL_API_KEY_WR "****************" // Replace to the write API Key.</span>
<p>A <strong>HOME</strong> item at the bottom of the menu list is a link to the home path, and the default URI is <code>/</code> which is defined by <code>AUTOCONNECT_HOMEURI</code> in <strong>AutoConnectDefs.h</strong> header file.</p>
<p>A <strong>HOME</strong> item at the bottom of the menu list is a link to the home path, and the default URI is <code>/</code> which is defined by <code>AUTOCONNECT_HOMEURI</code> in <strong>AutoConnectDefs.h</strong> header file.</p>
<p>Also, you can change the HOME path using the AutoConnect API. The <ahref="api.html#home"><strong>AutoConnect::home</strong></a> function sets the URI as a link of the HOME item in the AutoConnect menu.</p>
<p>Also, you can change the HOME path using the AutoConnect API. The <ahref="api.html#home"><strong>AutoConnect::home</strong></a> function sets the URI as a link of the HOME item in the AutoConnect menu.</p>
<spanstyle="color: #e6db74"> { "name": "content", "type": "ACText", "value": "In this page, place the custom web page handled by the Sketch application." } ]</span>
<spanstyle="color: #e6db74"> { "name": "content", "type": "ACText", "value": "In this page, place the custom web page handled by the Sketch application." } ]</span>
<p>AutoConnectOTA has implemented using AutoConnectAUX. So it occupies two URIs by default. An update operation page is assigned to <strong>AUTOCONNECT_URI_UPDATE</strong> and the binary file uploader for the update is assigned to <strong>AUTOCONNECT_URI_UPDATE_ACT</strong>. These symbols are defined in the <code>AutoConnectDefs.h</code> header file as follows:</p>
<p>AutoConnectOTA has implemented using AutoConnectAUX. So it occupies two URIs by default. An update operation page is assigned to <strong>AUTOCONNECT_URI_UPDATE</strong> and the binary file uploader for the update is assigned to <strong>AUTOCONNECT_URI_UPDATE_ACT</strong>. These symbols are defined in the <code>AutoConnectDefs.h</code> header file as follows:</p>
<p>Therefore, the normal Sketch that imports AutoConnectOTA while keeping the default, you cannot use the two URIs <code>/_ac/update</code> and <code>/_ac/update_act</code> for your specific. If you want to use the URIs for any purpose other than AutoConnectOTA, you need to override the <code>AutoConnectDefs.h</code> definition at compile time. It can be overwritten by giving the build flags for platformio.ini as follows with the PlatformIO environment for example.</p>
<p>Therefore, the normal Sketch that imports AutoConnectOTA while keeping the default, you cannot use the two URIs <code>/_ac/update</code> and <code>/_ac/update_act</code> for your specific. If you want to use the URIs for any purpose other than AutoConnectOTA, you need to override the <code>AutoConnectDefs.h</code> definition at compile time. It can be overwritten by giving the build flags for platformio.ini as follows with the PlatformIO environment for example.</p>
@ -974,11 +974,11 @@ The AutoConnectOTA activates the ticker constantly regardless of the <a href="ap
<p>It will be born during <ahref="api.html#handleclient">AutoConnect::handleClient</a> process. AutoConnect will evaluate the enabled state of <ahref="apiconfig.html#ota">AutoConnectConfig::ota</a> each time the handleClient is executed, and if OTA is enabled then it creates an AutoConnectAux internally and assigns it to the update page. At this time, AutoConnectOTA is also instantiated together. The generated AUX page containing AutoConnectOTA is bound to AutoConnect inside the AutoConnect::handleClient process.</p>
<p>It will be born during <ahref="api.html#handleclient">AutoConnect::handleClient</a> process. AutoConnect will evaluate the enabled state of <ahref="apiconfig.html#ota">AutoConnectConfig::ota</a> each time the handleClient is executed, and if OTA is enabled then it creates an AutoConnectAux internally and assigns it to the update page. At this time, AutoConnectOTA is also instantiated together. The generated AUX page containing AutoConnectOTA is bound to AutoConnect inside the AutoConnect::handleClient process.</p>
<p>If you want to attach AutoConnectOTA dynamically with an external trigger, you can sketch like this:<br/>
<p>If you want to attach AutoConnectOTA dynamically with an external trigger, you can sketch like this:<br/>
<em>This sketch imports the OTA update feature with an external switch assigned to the GPIO pin. While the trigger not occurs, AutoConnect OTA will not be imported into Sketch and will not appear on the menu list.</em></p>
<em>This sketch imports the OTA update feature with an external switch assigned to the GPIO pin. While the trigger not occurs, AutoConnect OTA will not be imported into Sketch and will not appear on the menu list.</em></p>
<p>In addition to the above procedure, to completely cut off for binding with the ArduinoJson library, turn off the ArduinoJson use indicator which is declared by the <ahref="api.html#defined-macros">AutoConnect definitions</a>. Its declaration is in <strong>AutoConnectDefs.h</strong> file.<supid="fnref:1"><aclass="footnote-ref"href="#fn:1">1</a></sup></p>
<p>In addition to the above procedure, to completely cut off for binding with the ArduinoJson library, turn off the ArduinoJson use indicator which is declared by the <ahref="api.html#defined-macros">AutoConnect definitions</a>. Its declaration is in <strong>AutoConnectDefs.h</strong> file.<supid="fnref:1"><aclass="footnote-ref"href="#fn:1">1</a></sup></p>
<divclass="codehilite"style="background: #272822"><prestyle="line-height: 125%"><span></span><code><spanstyle="color: #7a7a7a">// Comment out the AUTOCONNECT_USE_JSON macro to detach the ArduinoJson.</span>
<divclass="codehilite"style="background: #272822"><prestyle="line-height: 125%"><span></span><code><spanstyle="color: #75715e">// Comment out the AUTOCONNECT_USE_JSON macro to detach the ArduinoJson.</span>
<spanstyle="margin-right:6px;margin-top:2px;"><imgalign="middle"width="32"height="32"src="images/arrow_down.png"></span><iclass="fa fa-code"></i> Exclude the JSON and replace to the AutoConnectElements natively</p>
<spanstyle="margin-right:6px;margin-top:2px;"><imgalign="middle"width="32"height="32"src="images/arrow_down.png"></span><iclass="fa fa-code"></i> Exclude the JSON and replace to the AutoConnectElements natively</p>
<divclass="codehilite"style="background: #272822"><prestyle="line-height: 125%"><span></span><code><spanstyle="color: #7a7a7a">// In the declaration,</span>
<divclass="codehilite"style="background: #272822"><prestyle="line-height: 125%"><span></span><code><spanstyle="color: #75715e">// In the declaration,</span>
<spanstyle="color: #7a7a7a">// Declare AutoConnectElements for the page asf /mqtt_setting</span>
<spanstyle="color: #75715e">// Declare AutoConnectElements for the page asf /mqtt_setting</span>
<spanstyle="color: #f8f8f2">ACText(caption,</span><spanstyle="color: #e6db74">"Publishing the WiFi signal strength to MQTT channel. RSSI value of ESP8266 to the channel created on ThingSpeak"</span><spanstyle="color: #f8f8f2">,</span><spanstyle="color: #e6db74">"font-family:serif;color:#4682b4;"</span><spanstyle="color: #f8f8f2">);</span>
<spanstyle="color: #f8f8f2">ACText(caption,</span><spanstyle="color: #e6db74">"Publishing the WiFi signal strength to MQTT channel. RSSI value of ESP8266 to the channel created on ThingSpeak"</span><spanstyle="color: #f8f8f2">,</span><spanstyle="color: #e6db74">"font-family:serif;color:#4682b4;"</span><spanstyle="color: #f8f8f2">);</span>