<ahref="#change-ssid-and-password-for-softap"title=" Change SSID and Password for SoftAP"class="md-nav__link">
Change SSID and Password for SoftAP
</a>
</li>
</li>
<liclass="md-nav__item">
<liclass="md-nav__item">
@ -1042,6 +1049,13 @@
Assign user sketch's home path
Assign user sketch's home path
</a>
</a>
</li>
<liclass="md-nav__item">
<ahref="#change-ssid-and-password-for-softap"title=" Change SSID and Password for SoftAP"class="md-nav__link">
Change SSID and Password for SoftAP
</a>
</li>
</li>
<liclass="md-nav__item">
<liclass="md-nav__item">
@ -1094,8 +1108,8 @@
<p>Registering the "not found" handler is a different way than ESP8266WebServer/WebServer. The <em>onNotFound</em> of ESP8266WebServer/WebServer does not work with AutoConnect. AutoConnect overrides <em>ESP8266WebServer::onNotFound</em>/<em>WebServer::onNotFound</em> to handle a captive portal. To register "not found" handler, use <ahref="api.html#onnotfound"><em>AutoConnect::onNotFound</em></a>.</p>
<p>Registering the "not found" handler is a different way than ESP8266WebServer/WebServer. The <em>onNotFound</em> of ESP8266WebServer/WebServer does not work with AutoConnect. AutoConnect overrides <em>ESP8266WebServer::onNotFound</em>/<em>WebServer::onNotFound</em> to handle a captive portal. To register "not found" handler, use <ahref="api.html#onnotfound"><em>AutoConnect::onNotFound</em></a>.</p>
<p>When the captive portal is started, SoftAP starts and the STA is disconnected. The current SSID setting memorized in ESP8266 will be lost but then the reconnect behavior of ESP32 is somewhat different from this.</p>
<p>When the captive portal is started, SoftAP starts and the STA is disconnected. The current SSID setting memorized in ESP8266 will be lost but then the reconnect behavior of ESP32 is somewhat different from this.</p>
<p>The <ahref="https://github.com/espressif/arduino-esp32/blob/a0f0bd930cfd2d607bf3d3288f46e2d265dd2e11/libraries/WiFi/src/WiFiSTA.h#L46">WiFiSTAClass::disconnect</a> function implemented in the arduino-esp32 has extended parameters than the ESP8266's arduino-core. The second parameter of WiFi.disconnect on the arduino-esp32 core that does not exist in the <ahref="https://github.com/esp8266/Arduino/blob/7e1bdb225da8ab337373517e6a86a99432921a86/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp#L296">ESP8266WiFiSTAClass</a> has the effect of deleting the currently connected WiFi configuration and its default value is "false". On the ESP32 platform, even if WiFi.disconnect is executed, WiFi.begin() without the parameters in the next turn will try to connect to that AP. That is, automatic reconnection is implemented in arduino-esp32 already. Although this behavior appears seemingly competent, it is rather a disadvantage in scenes where you want to change the access point each time. When explicitly disconnecting WiFi from the Disconnect menu, AutoConnect will erase the AP connection settings saved by arduino-esp32 core. AutoConnect's automatic reconnection is a mechanism independent from the automatic reconnection of the arduino-esp32 core.</p>
<p>The <ahref="https://github.com/espressif/arduino-esp32/blob/a0f0bd930cfd2d607bf3d3288f46e2d265dd2e11/libraries/WiFi/src/WiFiSTA.h#L46"><em>WiFiSTAClass::disconnect</em></a> function implemented in the arduino-esp32 has extended parameters than the ESP8266's arduino-core. The second parameter of WiFi.disconnect on the arduino-esp32 core that does not exist in the <ahref="https://github.com/esp8266/Arduino/blob/7e1bdb225da8ab337373517e6a86a99432921a86/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp#L296">ESP8266WiFiSTAClass</a> has the effect of deleting the currently connected WiFi configuration and its default value is "false". On the ESP32 platform, even if WiFi.disconnect is executed, WiFi.begin() without the parameters in the next turn will try to connect to that AP. That is, automatic reconnection is implemented in arduino-esp32 already. Although this behavior appears seemingly competent, it is rather a disadvantage in scenes where you want to change the access point each time. When explicitly disconnecting WiFi from the Disconnect menu, AutoConnect will erase the AP connection settings saved by arduino-esp32 core. AutoConnect's automatic reconnection is a mechanism independent from the automatic reconnection of the arduino-esp32 core.</p>
<p>If the <ahref="api.html#autoreconnect"><strong>autoReconnect</strong></a> option of the <ahref="api.html#autoconnectconfig-api"><strong>AutoConnectConfig</strong></a> class is enabled, it automatically attempts to reconnect to the disconnected past access point. When the autoReconnect option is specified, AutoConnect will not start SoftAP immediately if the first WiFi.begin fails. It will scan WiFi signal and the same connection information as the detected BSSID is stored in EEPROM as AutoConnect's credentials, explicitly apply it with WiFi.begin and rerun.</p>
<p>If the <ahref="apiconfig.html#autoreconnect"><strong>autoReconnect</strong></a> option of the <ahref="apiconfig.html">AutoConnectConfig</a> class is enabled, it automatically attempts to reconnect to the disconnected past access point. When the autoReconnect option is specified, AutoConnect will not start SoftAP immediately if the first WiFi.begin fails. It will scan WiFi signal and the same connection information as the detected BSSID is stored in EEPROM as AutoConnect's credentials, explicitly apply it with WiFi.begin and rerun.</p>
<p>An autoReconnect will not effect if the SSID which stored credential to be connected is a hidden access point.</p>
<p>An autoReconnect will not effect if the SSID which stored credential to be connected is a hidden access point.</p>
</div>
</div>
<h3id="auto-save-credential"><iclass="fa fa-caret-right"></i> Auto save Credential<aclass="headerlink"href="#auto-save-credential"title="Permanent link">¶</a></h3>
<h3id="auto-save-credential"><iclass="fa fa-caret-right"></i> Auto save Credential<aclass="headerlink"href="#auto-save-credential"title="Permanent link">¶</a></h3>
<p>By default, AutoConnect saves the credentials of the established connection in EEPROM. You can disable it with the <ahref="api.html#autosave"><strong>autoSave</strong></a> parameter specified by <ahref="api.html#autoconnectconfig"><strong>AutoConnectConfig</strong></a>.</p>
<p>By default, AutoConnect saves the credentials of the established connection in EEPROM. You can disable it with the <ahref="apiconfig.html#autosave"><strong>autoSave</strong></a> parameter specified by <ahref="apiconfig.html">AutoConnectConfig</a>.</p>
<p>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>AutoConnectDef.h</strong> file.</p>
<p>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>AutoConnectDef.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"><strong>AutoConnectConfig::portalTimeout</strong></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>
Also, if you want to stop AutoConnect completely when the captive portal is timed out, you need to call the <ahref="api.html#end"><strong>AutoConnect::end</strong></a> function. It looks like the following code:</p>
Also, if you want to stop AutoConnect completely when the captive portal is timed out, you need to call the <ahref="api.html#end"><em>AutoConnect::end</em></a> function. It looks like the following code:</p>
@ -1198,7 +1212,7 @@ Also, if you want to stop AutoConnect completely when the captive portal is time
<spanstyle="color: #f8f8f2">}</span>
<spanstyle="color: #f8f8f2">}</span>
</pre></div>
</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"><strong>AutoConnectConfig::retainPortal</strong></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>
@ -1237,7 +1251,7 @@ Also, if you want to stop AutoConnect completely when the captive portal is time
</ol>
</ol>
<p>For details, see section <ahref="menuize.html">Constructing the menu</a> of Examples page.</p>
<p>For details, see section <ahref="menuize.html">Constructing the menu</a> of Examples page.</p>
<h3id="change-menu-title"><iclass="fa fa-caret-right"></i> Change menu title<aclass="headerlink"href="#change-menu-title"title="Permanent link">¶</a></h3>
<h3id="change-menu-title"><iclass="fa fa-caret-right"></i> Change menu title<aclass="headerlink"href="#change-menu-title"title="Permanent link">¶</a></h3>
<p>Although the default menu title is <strong>AutoConnect</strong>, you can change the title by setting <ahref="apiconfig.html#title">AutoConnectConfig::title</a>. To set the menu title properly, you must set before calling <ahref="api.html#begin"><em>AutoConnect::begin</em></a>.</p>
<p>Although the default menu title is <strong>AutoConnect</strong>, you can change the title by setting <ahref="apiconfig.html#title"><em>AutoConnectConfig::title</em></a>. To set the menu title properly, you must set before calling <ahref="api.html#begin"><em>AutoConnect::begin</em></a>.</p>
@ -1280,7 +1294,7 @@ Also, if you want to stop AutoConnect completely when the captive portal is time
<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>
<p>It can also prevent the captive portal from starting even if the connection at the first <em>WiFi.begin</em> fails. In this case, <ahref="api.html#begin"><em>AutoConnect::begin</em></a> behaves same as <em>WiFi.begin</em>.</p>
<p>It can also prevent the captive portal from starting even if the connection at the first <em>WiFi.begin</em> fails. In this case, <ahref="api.html#begin"><em>AutoConnect::begin</em></a> behaves same as <em>WiFi.begin</em>.</p>
<p>For disabling the captive portal, <ahref="api.html#autorise"><strong>autoRise</strong></a> sets to false with <ahref="api.html#autoconnectconfig-api"><strong>AutoConnectConfig</strong></a>.</p>
<p>For disabling the captive portal, <ahref="apiconfig.html#autorise"><strong>autoRise</strong></a> sets to false with <ahref="apiconfig.html">AutoConnectConfig</a>.</p>
@ -1290,7 +1304,7 @@ Also, if you want to stop AutoConnect completely when the captive portal is time
</pre></div>
</pre></div>
<h3id="make-ssid-of-softap-unique"><iclass="fa fa-caret-right"></i> Make SSID of SoftAP unique<aclass="headerlink"href="#make-ssid-of-softap-unique"title="Permanent link">¶</a></h3>
<h3id="make-ssid-of-softap-unique"><iclass="fa fa-caret-right"></i> Make SSID of SoftAP unique<aclass="headerlink"href="#make-ssid-of-softap-unique"title="Permanent link">¶</a></h3>
<p>You can change SoftAP's SSID and password programmatically when the captive portal starts up. By using chip specific ID of esp8266/esp32 you can make SSID of SoftAP unique. SSID and password for SoftAP is <ahref="apiconfig.html#apid"><strong>AutoConnectConfig::apid</strong></a> and <ahref="apiconfig.html#psk"><strong>AutoConnectConfig::psk</strong></a>.</p>
<p>You can change SoftAP's SSID and password programmatically when the captive portal starts up. By using chip specific ID of esp8266/esp32 you can make SSID of SoftAP unique. SSID and password for SoftAP is <ahref="apiconfig.html#apid"><em>AutoConnectConfig::apid</em></a> and <ahref="apiconfig.html#psk"><em>AutoConnectConfig::psk</em></a>.</p>
@ -1319,7 +1333,7 @@ Sketch OTA update File system EEPROM WiFi config (SDK)
<p>EEPROM library uses one sector of flash located <ahref="http://arduino-esp8266.readthedocs.io/en/latest/libraries.html?highlight=SPIFFS#eeprom">just after the SPIFFS</a>.</p>
<p>EEPROM library uses one sector of flash located <ahref="http://arduino-esp8266.readthedocs.io/en/latest/libraries.html?highlight=SPIFFS#eeprom">just after the SPIFFS</a>.</p>
</blockquote>
</blockquote>
<p>Also, the placement of the EEPROM area of ESP32 is described in the <ahref="https://github.com/espressif/arduino-esp32/blob/master/tools/partitions/default.csv">partition table</a>. So in the default state, the credential storage area used by AutoConnect conflicts with data owned by the user sketch. It will be destroyed together saved data in EEPROM by user sketch and AutoConnect each other. But you can move the storage area to avoid this.</p>
<p>Also, the placement of the EEPROM area of ESP32 is described in the <ahref="https://github.com/espressif/arduino-esp32/blob/master/tools/partitions/default.csv">partition table</a>. So in the default state, the credential storage area used by AutoConnect conflicts with data owned by the user sketch. It will be destroyed together saved data in EEPROM by user sketch and AutoConnect each other. But you can move the storage area to avoid this.</p>
<p>The <ahref="api.html#boundaryoffset"><strong>boundaryOffset</strong></a> in <ahref="api.html#autoconnectconfig-api"><strong>AutoConnectConfig</strong></a> specifies the start offset of the credentials storage area. The default value is 0.</p>
<p>The <ahref="apiconfig.html#boundaryoffset"><strong>boundaryOffset</strong></a> in <ahref="apiconfig.html">AutoConnectConfig</a> specifies the start offset of the credentials storage area. The default value is 0.</p>
<h3id="on-demand-start-the-captive-portal"><iclass="fa fa-caret-right"></i> On-demand start the captive portal<aclass="headerlink"href="#on-demand-start-the-captive-portal"title="Permanent link">¶</a></h3>
<h3id="on-demand-start-the-captive-portal"><iclass="fa fa-caret-right"></i> On-demand start the captive portal<aclass="headerlink"href="#on-demand-start-the-captive-portal"title="Permanent link">¶</a></h3>
<p>If you do not usually connect to WiFi and need to establish a WiFi connection if necessary, you can combine the <ahref="api.html#autorise"><strong>autoRise</strong></a> option with the <ahref="api.html#immediatestart"><strong>immediateStart</strong></a> option to achieve on-demand connection. This behavior is similar to the <ahref="https://github.com/tzapu/WiFiManager#on-demand-configuration-portal">WiFiManager's startConfigPortal</a> function. In order to do this, you usually configure only with AutoConnectConfig in <em>setup()</em> and <ahref="api.html#begin"><em>AutoConnect::begin</em></a> handles in <em>loop()</em>.</p>
<p>If you do not usually connect to WiFi and need to establish a WiFi connection if necessary, you can combine the <ahref="api.html#autorise"><strong>autoRise</strong></a> option with the <ahref="api.html#immediatestart"><strong>immediateStart</strong></a> option to achieve on-demand connection. This behavior is similar to the <ahref="https://github.com/tzapu/WiFiManager#on-demand-configuration-portal">WiFiManager's startConfigPortal</a> function. In order to do this, you usually configure only with AutoConnectConfig in <em>setup()</em> and <ahref="api.html#begin"><em>AutoConnect::begin</em></a> handles in <em>loop()</em>.</p>
<h3id="configuration-for-soft-ap-and-captive-portal"><iclass="fa fa-caret-right"></i> Configuration for Soft AP and captive portal<aclass="headerlink"href="#configuration-for-soft-ap-and-captive-portal"title="Permanent link">¶</a></h3>
<h3id="configuration-for-soft-ap-and-captive-portal"><iclass="fa fa-caret-right"></i> Configuration for Soft AP and captive portal<aclass="headerlink"href="#configuration-for-soft-ap-and-captive-portal"title="Permanent link">¶</a></h3>
<p>AutoConnect will activate SoftAP at failed the first <em>WiFi.begin</em>. It SoftAP settings are stored in <ahref="api.html#autoconnectconfig"><strong>AutoConnectConfig</strong></a> as the following parameters. The sketch could be configured SoftAP using these parameters, refer the <ahref="api.html#autoconnectconfig-api">AutoConnectConfig API</a> for details.</p>
<p>AutoConnect will activate SoftAP at failed the first <em>WiFi.begin</em>. It SoftAP settings are stored in <ahref="apiconfig.html#autoconnectconfig"><strong>AutoConnectConfig</strong></a> as the following parameters. The sketch could be configured SoftAP using these parameters, refer the <ahref="apiconfig.html#public-member-variables">AutoConnectConfig API</a> for details.</p>
<ul>
<ul>
<li>IP address of SoftAP activated.</li>
<li>IP address of SoftAP activated.</li>
<li>Gateway IP address.</li>
<li>Gateway IP address.</li>
@ -1433,8 +1447,31 @@ The above example does not connect to WiFi until TRIGGER_PIN goes LOW. When TRIG
<h3id="assign-user-sketchs-home-path"><iclass="fa fa-caret-right"></i> Assign user sketch's home path<aclass="headerlink"href="#assign-user-sketchs-home-path"title="Permanent link">¶</a></h3>
<h3id="assign-user-sketchs-home-path"><iclass="fa fa-caret-right"></i> Assign user sketch's home path<aclass="headerlink"href="#assign-user-sketchs-home-path"title="Permanent link">¶</a></h3>
<p><strong>HOME</strong> for returning to the user's sketch homepage will display at the bottom of the AutoConnect menu. It could be set using the <ahref="api.html#home"><em>AutoConnect::home</em></a> function.</p>
<p><strong>HOME</strong> for returning to the user's sketch homepage will display at the bottom of the AutoConnect menu. It could be set using the <ahref="api.html#home"><em>AutoConnect::home</em></a> function.</p>
<p><imgsrc="images/menu_home.png"/></p>
<p><imgsrc="images/menu_home.png"/></p>
<h3id="change-ssid-and-password-for-softap"><iclass="fa fa-caret-right"></i> Change SSID and Password for SoftAP<aclass="headerlink"href="#change-ssid-and-password-for-softap"title="Permanent link">¶</a></h3>
<p>An <strong>esp8266ap</strong> is default SSID name for SoftAP of captive portal and password is <strong>12345678</strong> for ESP8266. Similarly, <strong>esp32ap</strong> and <strong>12345678</strong> for ESP32. You can change both by setting <ahref="apiconfig.html#apid">apid</a> and <ahref="apiconfig.html#psk">psk</a>.</p>
<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 http://IPADDRESS/_ac. You can change the home path by revising <ahref="https://github.com/Hieromon/AutoConnect/blob/master/src/AutoConnect.h#L58"><strong>AUTOCONNECT_URI</strong></a> macro in the include header file as <ahref="https://github.com/Hieromon/AutoConnect/blob/master/src/AutoConnect.h">AutoConnect.h</a>.</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 <ahref="https://github.com/Hieromon/AutoConnect/blob/master/src/AutoConnectDefs.h#L62"><strong>AUTOCONNECT_URI</strong></a> macro in the include header file as <ahref="https://github.com/Hieromon/AutoConnect/blob/master/src/AutoConnectDef.h">AutoConnectDef.h</a>.</p>
<h2id="public-member-variables"><iclass="fa fa-code"></i> Public member variables<aclass="headerlink"href="#public-member-variables"title="Permanent link">¶</a></h2>
<h2id="public-member-variables"><iclass="fa fa-code"></i> Public member variables<aclass="headerlink"href="#public-member-variables"title="Permanent link">¶</a></h2>
<dd><spanclass="apidef">String</span><spanclass="apidesc"> The default value is <strong>esp8266ap</strong> for ESP8266, <strong>esp32ap</strong> for ESP32.</span></dd>
<p>Sets IP address for Soft AP in captive portal. When AutoConnect fails the initial WiFi.begin, it starts the captive portal with the IP address specified this.
<p>Sets IP address for Soft AP in captive portal. When AutoConnect fails the initial WiFi.begin, it starts the captive portal with the IP address specified this.
@ -1205,9 +1205,9 @@ For AutoConnect menus to work properly, call <a href="api.html#handlerequest"><e
<h2id="does-not-response-from-95ac"><iclass="fa fa-question-circle"></i> Does not response from /_ac.<aclass="headerlink"href="#does-not-response-from-95ac"title="Permanent link">¶</a></h2>
<h2id="does-not-response-from-95ac"><iclass="fa fa-question-circle"></i> Does not response from /_ac.<aclass="headerlink"href="#does-not-response-from-95ac"title="Permanent link">¶</a></h2>
<p>Probably <strong>WiFi.begin</strong> failed with the specified SSID. Activating the <ahref="advancedusage.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 <ahref="advancedusage.html#debug-print">debug printing</a> will help you to track down the cause.</p>
<h2id="how-change-esp8266ap-for-ssid-name-in-captive-portal"><iclass="fa fa-question-circle"></i> How change esp8266ap for SSID name in Captive portal?<aclass="headerlink"href="#how-change-esp8266ap-for-ssid-name-in-captive-portal"title="Permanent link">¶</a></h2>
<h2id="how-change-esp8266ap-for-ssid-name-in-captive-portal"><iclass="fa fa-question-circle"></i> How change esp8266ap for SSID name in Captive portal?<aclass="headerlink"href="#how-change-esp8266ap-for-ssid-name-in-captive-portal"title="Permanent link">¶</a></h2>
<p>An <strong>esp8266ap</strong> is default SSID name for SoftAP of captive portal and password is <strong>12345678</strong>. You can change both by using<ahref="api.html#autoconnectconfig-api">AutoConnectConfig</a>.</p>
<p>You can change both by using <ahref="apiconfig.html#apid">AutoConnectConfig::apid</a> and <ahref="apiconfig.html#psk">AutoConnectConfig::psk</a>. Refer to section <ahref="advancedusage.html#change-ssid-and-password-for-softap">Change SSID and Password for SoftAP</a> in<ahref="advancedusage.html">Advanced usage</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/77d5cb5dc6d50651fd15f74b47859105c71fc317/src/AutoConnect.h#L89">AutoConnect.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#L112">AutoConnect.h</a> header file. You can change it directly with several editors and must re-compile.</p>
<p>Call <ahref="api.html#begin"><strong>AutoConnect::begin</strong></a>. If you need to assign a static IP address, executes <ahref="api.html#autoconnectconfig-api"><strong>AutoConnectConfig</strong></a> before that. </p>
<p>Call <ahref="api.html#begin"><strong>AutoConnect::begin</strong></a>. If you need to assign a static IP address, executes <ahref="apiconfig.html">AutoConnectConfig</a> before that. </p>
@ -8,9 +8,9 @@ Registering the "not found" handler is a different way than ESP8266WebServer/Web
When the captive portal is started, SoftAP starts and the STA is disconnected. The current SSID setting memorized in ESP8266 will be lost but then the reconnect behavior of ESP32 is somewhat different from this.
When the captive portal is started, SoftAP starts and the STA is disconnected. The current SSID setting memorized in ESP8266 will be lost but then the reconnect behavior of ESP32 is somewhat different from this.
The [WiFiSTAClass::disconnect](https://github.com/espressif/arduino-esp32/blob/a0f0bd930cfd2d607bf3d3288f46e2d265dd2e11/libraries/WiFi/src/WiFiSTA.h#L46) function implemented in the arduino-esp32 has extended parameters than the ESP8266's arduino-core. The second parameter of WiFi.disconnect on the arduino-esp32 core that does not exist in the [ESP8266WiFiSTAClass](https://github.com/esp8266/Arduino/blob/7e1bdb225da8ab337373517e6a86a99432921a86/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp#L296) has the effect of deleting the currently connected WiFi configuration and its default value is "false". On the ESP32 platform, even if WiFi.disconnect is executed, WiFi.begin() without the parameters in the next turn will try to connect to that AP. That is, automatic reconnection is implemented in arduino-esp32 already. Although this behavior appears seemingly competent, it is rather a disadvantage in scenes where you want to change the access point each time. When explicitly disconnecting WiFi from the Disconnect menu, AutoConnect will erase the AP connection settings saved by arduino-esp32 core. AutoConnect's automatic reconnection is a mechanism independent from the automatic reconnection of the arduino-esp32 core.
The [*WiFiSTAClass::disconnect*](https://github.com/espressif/arduino-esp32/blob/a0f0bd930cfd2d607bf3d3288f46e2d265dd2e11/libraries/WiFi/src/WiFiSTA.h#L46) function implemented in the arduino-esp32 has extended parameters than the ESP8266's arduino-core. The second parameter of WiFi.disconnect on the arduino-esp32 core that does not exist in the [ESP8266WiFiSTAClass](https://github.com/esp8266/Arduino/blob/7e1bdb225da8ab337373517e6a86a99432921a86/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp#L296) has the effect of deleting the currently connected WiFi configuration and its default value is "false". On the ESP32 platform, even if WiFi.disconnect is executed, WiFi.begin() without the parameters in the next turn will try to connect to that AP. That is, automatic reconnection is implemented in arduino-esp32 already. Although this behavior appears seemingly competent, it is rather a disadvantage in scenes where you want to change the access point each time. When explicitly disconnecting WiFi from the Disconnect menu, AutoConnect will erase the AP connection settings saved by arduino-esp32 core. AutoConnect's automatic reconnection is a mechanism independent from the automatic reconnection of the arduino-esp32 core.
If the [**autoReconnect**](api.md#autoreconnect) option of the [**AutoConnectConfig**](api.md#autoconnectconfig-api) class is enabled, it automatically attempts to reconnect to the disconnected past access point. When the autoReconnect option is specified, AutoConnect will not start SoftAP immediately if the first WiFi.begin fails. It will scan WiFi signal and the same connection information as the detected BSSID is stored in EEPROM as AutoConnect's credentials, explicitly apply it with WiFi.begin and rerun.
If the [**autoReconnect**](apiconfig.md#autoreconnect) option of the [AutoConnectConfig](apiconfig.md) class is enabled, it automatically attempts to reconnect to the disconnected past access point. When the autoReconnect option is specified, AutoConnect will not start SoftAP immediately if the first WiFi.begin fails. It will scan WiFi signal and the same connection information as the detected BSSID is stored in EEPROM as AutoConnect's credentials, explicitly apply it with WiFi.begin and rerun.
```cpp hl_lines="3"
```cpp hl_lines="3"
AutoConnect Portal;
AutoConnect Portal;
@ -27,7 +27,7 @@ An autoReconnect option is available to *AutoConnect::begin* without SSID and pa
### <iclass="fa fa-caret-right"></i> Auto save Credential
### <iclass="fa fa-caret-right"></i> Auto save Credential
By default, AutoConnect saves the credentials of the established connection in EEPROM. You can disable it with the [**autoSave**](api.md#autosave) parameter specified by [**AutoConnectConfig**](api.md#autoconnectconfig).
By default, AutoConnect saves the credentials of the established connection in EEPROM. You can disable it with the [**autoSave**](apiconfig.md#autosave) parameter specified by [AutoConnectConfig](apiconfig.md).
```cpp hl_lines="3"
```cpp hl_lines="3"
AutoConnect Portal;
AutoConnect Portal;
@ -74,7 +74,7 @@ AutoConnect has two parameters for timeout control. One is a timeout value used
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 [**immediateStart**](#on-demand-start-the-captive-portal) option to create sketches with high mobility.
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 [**immediateStart**](#on-demand-start-the-captive-portal) option to create sketches with high mobility.
The timeout of the captive portal is specified together with [**AutoConnectConfig::portalTimeout**](apiconfig.md#portaltimeout) as follows.
The timeout of the captive portal is specified together with [*AutoConnectConfig::portalTimeout*](apiconfig.md#portaltimeout) as follows.
```cpp hl_lines="9"
```cpp hl_lines="9"
#include<ESP8266WiFi.h>
#include<ESP8266WiFi.h>
@ -100,7 +100,7 @@ void loop() {
portal.handleClient();
portal.handleClient();
}
}
```
```
Also, if you want to stop AutoConnect completely when the captive portal is timed out, you need to call the [**AutoConnect::end**](api.md#end) function. It looks like the following code:
Also, if you want to stop AutoConnect completely when the captive portal is timed out, you need to call the [*AutoConnect::end*](api.md#end) function. It looks like the following code:
```cpp
```cpp
bool acEnable;
bool acEnable;
@ -127,7 +127,7 @@ void loop() {
}
}
```
```
There is another option related to timeout in AutoConnectConfig. It can make use of the captive portal function even after a timeout. The [**AutoConnectConfig::retainPortal**](apiconfig.md#retainportal) 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.
There is another option related to timeout in AutoConnectConfig. It can make use of the captive portal function even after a timeout. The [*AutoConnectConfig::retainPortal*](apiconfig.md#retainportal) 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.
```cpp hl_lines="10"
```cpp hl_lines="10"
#include<ESP8266WiFi.h>
#include<ESP8266WiFi.h>
@ -172,7 +172,7 @@ For details, see section [Constructing the menu](menuize.md) of Examples page.
### <iclass="fa fa-caret-right"></i> Change menu title
### <iclass="fa fa-caret-right"></i> Change menu title
Although the default menu title is **AutoConnect**, you can change the title by setting [AutoConnectConfig::title](apiconfig.md#title). To set the menu title properly, you must set before calling [*AutoConnect::begin*](api.md#begin).
Although the default menu title is **AutoConnect**, you can change the title by setting [*AutoConnectConfig::title*](apiconfig.md#title). To set the menu title properly, you must set before calling [*AutoConnect::begin*](api.md#begin).
```cpp hl_lines="6 7"
```cpp hl_lines="6 7"
AutoConnect Portal;
AutoConnect Portal;
@ -228,7 +228,7 @@ You can output AutoConnect monitor messages to the **Serial**. A monitor message
It can also prevent the captive portal from starting even if the connection at the first *WiFi.begin* fails. In this case, [*AutoConnect::begin*](api.md#begin) behaves same as *WiFi.begin*.
It can also prevent the captive portal from starting even if the connection at the first *WiFi.begin* fails. In this case, [*AutoConnect::begin*](api.md#begin) behaves same as *WiFi.begin*.
For disabling the captive portal, [**autoRise**](api.md#autorise) sets to false with [**AutoConnectConfig**](api.md#autoconnectconfig-api).
For disabling the captive portal, [**autoRise**](apiconfig.md#autorise) sets to false with [AutoConnectConfig](apiconfig.md).
```cpp hl_lines="4"
```cpp hl_lines="4"
AutoConnect portal;
AutoConnect portal;
@ -241,7 +241,7 @@ portal.begin();
### <iclass="fa fa-caret-right"></i> Make SSID of SoftAP unique
### <iclass="fa fa-caret-right"></i> Make SSID of SoftAP unique
You can change SoftAP's SSID and password programmatically when the captive portal starts up. By using chip specific ID of esp8266/esp32 you can make SSID of SoftAP unique. SSID and password for SoftAP is [**AutoConnectConfig::apid**](apiconfig.md#apid) and [**AutoConnectConfig::psk**](apiconfig.md#psk).
You can change SoftAP's SSID and password programmatically when the captive portal starts up. By using chip specific ID of esp8266/esp32 you can make SSID of SoftAP unique. SSID and password for SoftAP is [*AutoConnectConfig::apid*](apiconfig.md#apid) and [*AutoConnectConfig::psk*](apiconfig.md#psk).
```cpp
```cpp
AutoConnect portal;
AutoConnect portal;
@ -275,7 +275,7 @@ and
Also, the placement of the EEPROM area of ESP32 is described in the [partition table](https://github.com/espressif/arduino-esp32/blob/master/tools/partitions/default.csv). So in the default state, the credential storage area used by AutoConnect conflicts with data owned by the user sketch. It will be destroyed together saved data in EEPROM by user sketch and AutoConnect each other. But you can move the storage area to avoid this.
Also, the placement of the EEPROM area of ESP32 is described in the [partition table](https://github.com/espressif/arduino-esp32/blob/master/tools/partitions/default.csv). So in the default state, the credential storage area used by AutoConnect conflicts with data owned by the user sketch. It will be destroyed together saved data in EEPROM by user sketch and AutoConnect each other. But you can move the storage area to avoid this.
The [**boundaryOffset**](api.md#boundaryoffset) in [**AutoConnectConfig**](api.md#autoconnectconfig-api) specifies the start offset of the credentials storage area. The default value is 0.
The [**boundaryOffset**](apiconfig.md#boundaryoffset) in [AutoConnectConfig](apiconfig.md) specifies the start offset of the credentials storage area. The default value is 0.
### <iclass="fa fa-caret-right"></i> On-demand start the captive portal
### <iclass="fa fa-caret-right"></i> On-demand start the captive portal
@ -374,7 +374,7 @@ An example sketch used with the PageBuilder as follows and it explains how it ai
### <iclass="fa fa-caret-right"></i> Configuration for Soft AP and captive portal
### <iclass="fa fa-caret-right"></i> Configuration for Soft AP and captive portal
AutoConnect will activate SoftAP at failed the first *WiFi.begin*. It SoftAP settings are stored in [**AutoConnectConfig**](api.md#autoconnectconfig) as the following parameters. The sketch could be configured SoftAP using these parameters, refer the [AutoConnectConfig API](api.md#autoconnectconfig-api) for details.
AutoConnect will activate SoftAP at failed the first *WiFi.begin*. It SoftAP settings are stored in [**AutoConnectConfig**](apiconfig.md#autoconnectconfig) as the following parameters. The sketch could be configured SoftAP using these parameters, refer the [AutoConnectConfig API](apiconfig.md#public-member-variables) for details.
- IP address of SoftAP activated.
- IP address of SoftAP activated.
- Gateway IP address.
- Gateway IP address.
@ -405,9 +405,37 @@ AutoConnect will activate SoftAP at failed the first *WiFi.begin*. It SoftAP set
<imgsrc="images/menu_home.png"/>
<imgsrc="images/menu_home.png"/>
### <iclass="fa fa-caret-right"></i> Change SSID and Password for SoftAP
An **esp8266ap** is default SSID name for SoftAP of captive portal and password is **12345678** for ESP8266. Similarly, **esp32ap** and **12345678** for ESP32. You can change both by setting [apid](apiconfig.md#apid) and [psk](apiconfig.md#psk).
```cpp hl_lines="5 6"
AutoConnect portal;
AutoConnectConfig config;
void setup() {
config.apid = "ap_portal"
config.psk = "new_password";
portal.config(config);
portal.begin();
}
```
Also, you can specify the SSID, password for SoftAP with the constructor of the AutoConnectConfig as below.
### <iclass="fa fa-caret-right"></i> Relocate the AutoConnect home path
### <iclass="fa fa-caret-right"></i> Relocate the AutoConnect home path
A home path of AutoConnect is **/\_ac** by default. You can access from the browser with http://IPADDRESS/\_ac. You can change the home path by revising [**AUTOCONNECT_URI**](https://github.com/Hieromon/AutoConnect/blob/master/src/AutoConnect.h#L58) macro in the include header file as [AutoConnect.h](https://github.com/Hieromon/AutoConnect/blob/master/src/AutoConnect.h).
A home path of AutoConnect is **/\_ac** by default. You can access from the browser with http://IPADDRESS/\_ac. You can change the home path by revising [**AUTOCONNECT_URI**](https://github.com/Hieromon/AutoConnect/blob/master/src/AutoConnectDefs.h#L62) macro in the include header file as [AutoConnectDef.h](https://github.com/Hieromon/AutoConnect/blob/master/src/AutoConnectDef.h).
```cpp
```cpp
#define AUTOCONNECT_URI "/_ac"
#define AUTOCONNECT_URI "/_ac"
@ -425,7 +453,7 @@ To assign a static IP to ESP8266/ESP32 with WIFI\_MODE\_STA, the following param
- Primary DNS server.
- Primary DNS server.
- Secondary DNS server. (optional)
- Secondary DNS server. (optional)
The above parameters must be executed before *AutoConnect::begin* as [arguments of AutoConnectConfig](api.md#staip).
The above parameters must be executed before *AutoConnect::begin* as [arguments of AutoConnectConfig](apiconfig.md#staip).
@ -64,11 +64,11 @@ Probably **WiFi.begin** failed with the specified SSID. Activating the [debug pr
## <iclass="fa fa-question-circle"></i> How change esp8266ap for SSID name in Captive portal?
## <iclass="fa fa-question-circle"></i> How change esp8266ap for SSID name in Captive portal?
An **esp8266ap** is default SSID name for SoftAP of captive portal and password is **12345678**. You can change both by using [AutoConnectConfig](api.md#autoconnectconfig-api).
You can change both by using [AutoConnectConfig::apid](apiconfig.md#apid) and [AutoConnectConfig::psk](apiconfig.md#psk). Refer to section [Change SSID and Password for SoftAP](advancedusage.md#change-ssid-and-password-for-softap) in [Advanced usage](advancedusage.md).
## <iclass="fa fa-question-circle"></i> How change HTTP port?
## <iclass="fa fa-question-circle"></i> How change HTTP port?
HTTP port number is defined as a macro in [AutoConnect.h](https://github.com/Hieromon/AutoConnect/blob/77d5cb5dc6d50651fd15f74b47859105c71fc317/src/AutoConnect.h#L89) header file. You can change it directly with several editors and must re-compile.
HTTP port number is defined as a macro in [AutoConnect.h](https://github.com/Hieromon/AutoConnect/blob/master/src/AutoConnectDefs.h#L112) header file. You can change it directly with several editors and must re-compile.
@ -110,7 +110,7 @@ For the client sketches, the code required to connect to WiFi is the following f
3. Invokes "begin()"
3. Invokes "begin()"
Call [**AutoConnect::begin**](api.md#begin). If you need to assign a static IP address, executes [**AutoConnectConfig**](api.md#autoconnectconfig-api) before that.
Call [**AutoConnect::begin**](api.md#begin). If you need to assign a static IP address, executes [AutoConnectConfig](apiconfig.md) before that.