Under the work of v0.9.7 documentation

pull/41/head
Hieromon Ikasamo 6 years ago
parent 4d81c4e4ef
commit 04ec5fcfc9
  1. 4
      README.md
  2. 2
      mkdocs.yml
  3. 51
      mkdocs/achandling.md
  4. 28
      mkdocs/acjson.md
  5. 55
      mkdocs/api.md
  6. 158
      mkdocs/apiaux.md
  7. 48
      mkdocs/apiconfig.md
  8. 166
      mkdocs/apielements.md
  9. 12
      mkdocs/css/paragraph.css
  10. 12
      mkdocs/datatips.md
  11. 15
      mkdocs/faq.md
  12. BIN
      mkdocs/images/arrow_down.png
  13. BIN
      mkdocs/images/aux_ov.gif
  14. 2
      mkdocs/index.md
  15. 204
      mkdocs/wojson.md

@ -94,7 +94,7 @@ Full documentation is available on https://Hieromon.github.io/AutoConnect, some
## Change log ## Change log
### [0.9.7] Jan. 25, 2019 ### [0.9.7] Feb. 25, 2019
- Fixed crash in some environments. Thank you @ageurtse - Fixed crash in some environments. Thank you @ageurtse
- Supports AutoConnect menu extention by user sketch with **AutoConnectAux**. - Supports AutoConnect menu extention by user sketch with **AutoConnectAux**.
- Supports loading and saving of user-defined parameters with JSON format. - Supports loading and saving of user-defined parameters with JSON format.
@ -128,4 +128,4 @@ Full documentation is available on https://Hieromon.github.io/AutoConnect, some
## License ## License
License under the [MIT license](LICENSE). License under the [MIT license](LICENSE).

@ -29,6 +29,7 @@ nav:
- 'How to embed': howtoembed.md - 'How to embed': howtoembed.md
- 'Tips for data conversion': datatips.md - 'Tips for data conversion': datatips.md
- 'Constucting menu': menuize.md - 'Constucting menu': menuize.md
- 'Custom Web pages w/o JSON': wojson.md
- 'FAQ' : faq.md - 'FAQ' : faq.md
- 'Change log' : changelog.md - 'Change log' : changelog.md
- 'License' : license.md - 'License' : license.md
@ -60,6 +61,7 @@ theme:
extra_css: extra_css:
- 'css/paragraph.css' - 'css/paragraph.css'
- 'css/extra.css' - 'css/extra.css'
- 'https://use.fontawesome.com/releases/v5.6.1/css/all.css'
extra_javascript: extra_javascript:
- 'js/gifffer.min.js' - 'js/gifffer.min.js'
extra: extra:

@ -362,7 +362,7 @@ void loop() {
} }
``` ```
The above example handles in the handler for the values of a custom web page. An [AutoConnect::on](api.md#on) function registers a handler for the AutoConnectAux page of the specified uri. The argument of the custom Web page handler is an AutoConnectAux of the page itself and the [PageArgument](https://github.com/Hieromon/PageBuilder#arguments-of-invoked-user-function) object. The above example handles in the handler for the values of a custom Web page. An [AutoConnect::on](api.md#on) function registers a handler for the AutoConnectAux page of the specified uri. The argument of the custom Web page handler is an AutoConnectAux of the page itself and the [PageArgument](https://github.com/Hieromon/PageBuilder#arguments-of-invoked-user-function) object.
To retrieve the values entered in a custom Web page you need to access the AutoConnectElement of the page that caused the request to this page and to do this, you use the [AutoConnect::where](api.md#where) function. The `AutoConnect::where` function returns a pointer to the AutoConnectAux object of the custom Web page that caused the HTTP request. To retrieve the values entered in a custom Web page you need to access the AutoConnectElement of the page that caused the request to this page and to do this, you use the [AutoConnect::where](api.md#where) function. The `AutoConnect::where` function returns a pointer to the AutoConnectAux object of the custom Web page that caused the HTTP request.
@ -490,18 +490,52 @@ portal.on("/echo", [](AutoConnectAux& aux, PageArgument& args) {
portal.begin(); portal.begin();
``` ```
### <i class="fa fa-wpforms"></i> Over typing with LoadElement function ### <i class="fa fa-wpforms"></i> Overwrite the AutoConnectElements
The [AutoConnectAux::loadElement](apiaux.md#loadelement) function overwrites its value when loading an AutoConnectElement. If the loadElement function wields an element with an input value, the previous value will be lost by the loaded value. If you need to preserve input values even during page transition operations, we recommend that you load parameters only once at an early stage in the `setup()` of sketches. Sketches can update the attributes of AutoConnectElements with two approaches. A one is to assign directly to the attributes of a member variable of its element. The other is to overwrite them with loading the element by [AutoConnectAux::loadElement](apiaux.md#loadelement).
### <i class="fa fa-check-square"></i> Check data against on submission The elements for attributes described in the JSON document for AutoConnectElements overwrites the member variables of the target AutoConnectElements. However, AutoConnectAux::loadElement keeps the member variables unchanged if there is no element in the JSON document. This overwriting behavior is the same for the [AutoConnect::load](api.md#load) function.
For example, the combination of the sketch and JSON document as follows updates only the style while keeping Captiopn (ie. "Hello, world") as AutoConnectText value.
<i class="fa fa-code"></i> The sketch (part of code)
```cpp
ACText(Caption, "Hello, world");
AutoConnectAux helloPage("/hello", "Hello", true, { Caption });
AutoConnect portal;
String onHello(AutoConnectAux& aux, PageArgument& args) {
aux.loadElement(JSON);
return String();
}
void setup() {
helloPage.on(onHello);
portal.join(helloPage);
portal.begin();
}
void loop() {
portal.handleClient();
}
```
<i class="fab fa-js-square"></i> External JSON document for the above sketch to modify the text style
```json
{
"name" : "Caption",
"type" : "ACText",
"style": "text-align:center;font-family:'Avenir','Corbel','Osaka';color:Green;"
}
```
### <i class="far fa-check-square"></i> Check data against on submission
By giving a [pattern](apielements.md#pattern) to [AutoConnectInput](apielements.md#autoconenctinput), you can find errors in data styles while typing in custom Web pages. The pattern is specified by [regular expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions).[^2] If the value during input of AutoConnectInput does not match the regular expression specified in the pattern, its background color changes to pink. The following example shows the behavior when checking the IP address in the AutoConnectInput field. By giving a [pattern](apielements.md#pattern) to [AutoConnectInput](apielements.md#autoconenctinput), you can find errors in data styles while typing in custom Web pages. The pattern is specified by [regular expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions).[^2] If the value during input of AutoConnectInput does not match the regular expression specified in the pattern, its background color changes to pink. The following example shows the behavior when checking the IP address in the AutoConnectInput field.
[^2]: The pattern of AutoConnectInput conforms to javascript specification. [^2]: The pattern of AutoConnectInput conforms to javascript specification.
<span style="display:block;margin-left:auto;margin-right:auto;width:306px;height:136px;border:1px solid lightgrey;"><img data-gifffer="./images/aux_pattern.gif" data-gifffer-height="134" data-gifffer-width="304" /></span>
```json hl_lines="10" ```json hl_lines="10"
{ {
"title" : "Page-1", "title" : "Page-1",
@ -518,6 +552,11 @@ By giving a [pattern](apielements.md#pattern) to [AutoConnectInput](apielements.
} }
``` ```
<div>
<span style="display:block;margin-left:136px;"><img width="32px" height="32xp" src="./images/arrow_down.png"></span>
<span style="display:block;width:306px;height:136px;border:1px solid lightgrey;"><img data-gifffer="./images/aux_pattern.gif" data-gifffer-height="134" data-gifffer-width="304" /></span>
</div>
### <i class="fa fa-exchange"></i> Convert data to actually type ### <i class="fa fa-exchange"></i> Convert data to actually type
## Transitions of the custom Web pages ## Transitions of the custom Web pages

@ -1,4 +1,4 @@
## Describe custom Web pages with JSON
You can embed custom Web pages written in [**JSON**](https://www.json.org/index.html) into AutoConnect without declaring AutoConnectAux &amp; AutoConnectElements in sketches. Custom Web page declaration in JSON can be included in the sketch in advance as the fixed string, or it can be stored in the external file such as SPIFFS for stream loading. You can also load and save AutoConnectElements objects individually.[^1] You can embed custom Web pages written in [**JSON**](https://www.json.org/index.html) into AutoConnect without declaring AutoConnectAux &amp; AutoConnectElements in sketches. Custom Web page declaration in JSON can be included in the sketch in advance as the fixed string, or it can be stored in the external file such as SPIFFS for stream loading. You can also load and save AutoConnectElements objects individually.[^1]
@ -9,7 +9,7 @@ By providing the following JSON document to AutoConnect, you can include the cus
<div style="float:left;width:50%;height:470px;overflow:auto"><img src="./images/ac_json.png"></div> <div style="float:left;width:50%;height:470px;overflow:auto"><img src="./images/ac_json.png"></div>
<img style="margin-left:30px;width:40%;height:470px;" src="./images/ac_mqtt_setting.png"> <img style="margin-left:30px;width:40%;height:470px;" src="./images/ac_mqtt_setting.png">
A JSON document for AutoConnect can also contain declarations of multiple custom web pages. If you fit those multiple pages in one JSON document, sketch processing for loading AutoConnectAux will degenerate further. A JSON document for AutoConnect can also contain declarations of multiple custom Web pages. If you fit those multiple pages in one JSON document, sketch processing for loading AutoConnectAux will degenerate further.
!!! caution "Need ArduinoJson v5" !!! caution "Need ArduinoJson v5"
To process the AutoConnectAux &amp; AutoConnectElements written in the JSON is you need to install the [ArduinoJson version 5](https://arduinojson.org/v5/doc/installation/) library. To process the AutoConnectAux &amp; AutoConnectElements written in the JSON is you need to install the [ArduinoJson version 5](https://arduinojson.org/v5/doc/installation/) library.
@ -33,16 +33,16 @@ An AutoConnectAux is described by a JSON object. The elements that make up an ob
: A title of the custom Web page. This is string value. String specified *title* will be displayed in the AutoConnection menu. : A title of the custom Web page. This is string value. String specified *title* will be displayed in the AutoConnection menu.
#### <i class="fa fa-key"></i> **uri** #### <i class="fa fa-key"></i> **uri**
: String of URI path that specifies where to place the custom web page. It needs to be a location from the root path including '**/**'. : String of URI path that specifies where to place the custom Web page. It needs to be a location from the root path including '**/**'.
#### <i class="fa fa-key"></i> **menu** #### <i class="fa fa-key"></i> **menu**
: This is a Boolean value indicating whether to include the custom web page in the AutoConnect menu. If the page only responds to another page and you want to prevent the direct use from the menu, you can exclude from the AutoConnect menu. If this key is false, it will not appear in the menu. : This is a Boolean value indicating whether to include the custom Web page in the AutoConnect menu. If the page only responds to another page and you want to prevent the direct use from the menu, you can exclude from the AutoConnect menu. If this key is false, it will not appear in the menu.
#### <i class="fa fa-key"></i> **element** #### <i class="fa fa-key"></i> **element**
: Describe an array of JSON objects as *element_array*. It is a JSON object array of the [AutoConnectElements](#json-object-for-autoconnectelements) that make up the custom Web page. : Describe an array of JSON objects as *element_array*. It is a JSON object array of the [AutoConnectElements](#json-object-for-autoconnectelements) that make up the custom Web page.
!!! note "Order of elements on a custom Web page" !!! note "Order of elements on a custom Web page"
The order in which AutoConnectElements are placed on a custom web page is the order in the JSON document. The order in which AutoConnectElements are placed on a custom Web page is the order in the JSON document.
### <i class="fa fa-copy"></i> Multiple custom Web pages declaration in JSON document ### <i class="fa fa-copy"></i> Multiple custom Web pages declaration in JSON document
@ -104,16 +104,12 @@ You can put declarations of multiple custom Web pages in one JSON document. In t
AutoConnectElements in JSON description are described as an array in the `element` with arguments of each [constructor](acelements.md#constructor). AutoConnectElements in JSON description are described as an array in the `element` with arguments of each [constructor](acelements.md#constructor).
``` ```
"element" : [ {
{ "name" : name,
"name" : name, "type" : type,
"type" : type, key_according_to_type : the_value | array_of_value,
key_according_to_type : the_value | array_of_value , key_according_to_type : the_value | array_of_value [ key_according_to_type : the_value | array_of_value ]
}, }
{
the_nect_element
}
]
``` ```
#### <i class="fa fa-key"></i> **name** #### <i class="fa fa-key"></i> **name**
@ -229,4 +225,4 @@ AutoConnect passes the given JSON document directly to the [**parseObject()**](h
## Saving JSON document ## Saving JSON document
However, AutoConnect does not support saving AutoConnectAux as a whole custom Web page. If you want to persist an AutoConnectElements object, you need to save it as an AutoConenctElement object unit. AutoConnectAux has a [function](achandling.md#saving-autoconnectelements) to write multiple elements to the stream in a batch. The sketch can persist AutoConnectElements as a JSON document and also uses [this function](achandling.md#saving-autoconnectelements-with-json) to save the values entered on the custom Web page. And you can reload the saved JSON document into AutoConnectElements as the field in a custom Web page using the [load function](achandling.md#loading-autoconnectaux-autoconnectelements-with-json).

@ -58,7 +58,7 @@ Run the AutoConnect site using the externally ensured ESP8266WebServer for ESP82
The [**handleClient**](api.md#handleclient) function of AutoConnect can include the response of the URI handler added by the user using the "*on*" function of ESP8266WebServer/WebServer. If ESP8266WebServer/WebServer is assigned internally by AutoConnect, the sketch can obtain that reference with the [**host**](api.md#host) function. The [**handleClient**](api.md#handleclient) function of AutoConnect can include the response of the URI handler added by the user using the "*on*" function of ESP8266WebServer/WebServer. If ESP8266WebServer/WebServer is assigned internally by AutoConnect, the sketch can obtain that reference with the [**host**](api.md#host) function.
<dl class="apidl"> <dl class="apidl">
<dt>**Parameters**</dt> <dt>**Parameters**</dt>
<dd><span class="apidef">webServer</span>A reference of ESP8266WebServer or WebServer instance.</dd> <dd><span class="apidef">webServer</span><span class="apidesc">A reference of ESP8266WebServer or WebServer instance.</span></dd>
</dl> </dl>
## <i class="fa fa-code"></i> Public member functions ## <i class="fa fa-code"></i> Public member functions
@ -71,7 +71,7 @@ AutoConnectAux* aux(const String& uri) const
Returns a pointer to AutoConnectAux with the URI specified by *uri*. If AutoConnectAux with that URI is not bound, it returns **nullptr**. Returns a pointer to AutoConnectAux with the URI specified by *uri*. If AutoConnectAux with that URI is not bound, it returns **nullptr**.
<dl class="apidl"> <dl class="apidl">
<dt>**Parameters**</dt> <dt>**Parameters**</dt>
<dd><span class="apidef">uri</span>A string of the URI.</dd> <dd><span class="apidef">uri</span><span class="apidesc">A string of the URI.</span></dd>
<dt>**Return value**</dt> <dt>**Return value**</dt>
<dd>A Pointer of the AutoConnectAux instance.</dd> <dd>A Pointer of the AutoConnectAux instance.</dd>
</dl> </dl>
@ -93,12 +93,12 @@ AutoConnect first invokes *WiFi.begin*. If the *ssid* and the *passphrase* are m
The captive portal will not be started if the connection has been established with first *WiFi.begin*. If the connection cannot establish, switch to WIFI_AP_STA mode and activate SoftAP. Then DNS server starts. The captive portal will not be started if the connection has been established with first *WiFi.begin*. If the connection cannot establish, switch to WIFI_AP_STA mode and activate SoftAP. Then DNS server starts.
<dl class="apidl"> <dl class="apidl">
<dt>**Parameters**</dt> <dt>**Parameters**</dt>
<dd><span class="apidef">ssid</span>SSID to be connected.</dd> <dd><span class="apidef">ssid</span><span class="apidesc">SSID to be connected.</span></dd>
<dd><span class="apidef">passphrase</span>Password for connection.</dd> <dd><span class="apidef">passphrase</span><span class="apidesc">Password for connection.</span></dd>
<dd><span class="apidef">timeout</span>A time out value in milliseconds for waiting connection.</dd> <dd><span class="apidef">timeout</span><span class="apidesc">A time out value in milliseconds for waiting connection.</span></dd>
<dt>**Return value**</dt> <dt>**Return value**</dt>
<dd><span class="apidef">true</span>Connection established, AutoConnect service started with WIFI_STA mode.</dd> <dd><span class="apidef">true</span><span class="apidesc">Connection established, AutoConnect service started with WIFI_STA mode.</span></dd>
<dd><span class="apidef">false</span>Could not connected, Captive portal started with WIFI_AP_STA mode.</dd> <dd><span class="apidef">false</span><span class="apidesc">Could not connected, Captive portal started with WIFI_AP_STA mode.</span></dd>
</dl> </dl>
### <i class="fa fa-caret-right"></i> config ### <i class="fa fa-caret-right"></i> config
@ -113,12 +113,12 @@ bool config(const char* ap, const char* password = nullptr)
Set SoftAP's WiFi configuration and static IP configuration. Set SoftAP's WiFi configuration and static IP configuration.
<dl class="apidl"> <dl class="apidl">
<dt>**Parameters**</dt> <dt>**Parameters**</dt>
<dd><span class="apidef">config</span>Reference to [**AutoConnectConfig**](apiconfig.md) containing SoftAP's parameters and static IP parameters.</dd> <dd><span class="apidef">config</span><span class="apidesc">Reference to [**AutoConnectConfig**](apiconfig.md) containing SoftAP's parameters and static IP parameters.</span></dd>
<dd><span class="apidef">ap</span>SSID for SoftAP. The default value is **esp8266ap** for ESP8266, **esp32ap** for ESP32.</dd> <dd><span class="apidef">ap</span><span class="apidesc">SSID for SoftAP. The default value is **esp8266ap** for ESP8266, **esp32ap** for ESP32.</span></dd>
<dd><span class="apidef">password</span>Password for SodtAP. The default value is **12345678**.</dd> <dd><span class="apidef">password</span><span class="apidesc">Password for SodtAP. The default value is **12345678**.</span></dd>
<dt>**Return value**</dt> <dt>**Return value**</dt>
<dd><span class="apidef">true</span>Successfully configured.</dd> <dd><span class="apidef">true</span><span class="apidesc">Successfully configured.</span></dd>
<dd><span class="apidef">false</span>Configuration parameter is invalid, some values out of range.</dd> <dd><span class="apidef">false</span><span class="aidesc">Configuration parameter is invalid, some values out of range.</span></dd>
</dl> </dl>
### <i class="fa fa-caret-right"></i> end ### <i class="fa fa-caret-right"></i> end
@ -154,13 +154,13 @@ Handling for the AutoConnect menu request.
### <i class="fa fa-caret-right"></i> home ### <i class="fa fa-caret-right"></i> home
```cpp ```cpp
void home(String uri) void home(String& uri)
``` ```
Put a user site's home URI. The URI specified by home is linked from "HOME" in the AutoConnect menu. Put a user site's home URI. The URI specified by home is linked from "HOME" in the AutoConnect menu.
<dl class="apidl"> <dl class="apidl">
<dt>**Parameters**</dt> <dt>**Parameters**</dt>
<dd><span class="apidef">uri</span> A URI string of user site's home path.</dd> <dd><span class="apidef">uri</span><span class="aidesc">A URI string of user site's home path.</span></dd>
</dl> </dl>
### <i class="fa fa-caret-right"></i> host ### <i class="fa fa-caret-right"></i> host
@ -205,7 +205,7 @@ void join(std::vector<std::reference_wrapper<AutoConnectAux>> aux)
Join the AutoConnectAux object to AutoConnect. AutoConnectAux objects can be joined one by one, or joined altogether. The AutoConnectAux object joined by the join function can be handled from the AutoConnect menu. Join the AutoConnectAux object to AutoConnect. AutoConnectAux objects can be joined one by one, or joined altogether. The AutoConnectAux object joined by the join function can be handled from the AutoConnect menu.
<dl class="apidl"> <dl class="apidl">
<dt>**Parameters**</dt> <dt>**Parameters**</dt>
<dd><span class="apidef">aux</span>Reference to AutoConnectAux. It can be std::vector of std::reference_wrapper of AutoConnectAux with [list initialization](https://en.cppreference.com/w/cpp/language/list_initialization).</dd> <dd><span class="apidef">aux</span><span class="apidesc">Reference to AutoConnectAux. It can be std::vector of std::reference_wrapper of AutoConnectAux with [list initialization](https://en.cppreference.com/w/cpp/language/list_initialization).</span></dd>
</dl> </dl>
### <i class="fa fa-caret-right"></i> load ### <i class="fa fa-caret-right"></i> load
@ -222,10 +222,10 @@ bool load(Stream& aux)
Load JSON document of AutoConnectAux which contains AutoConnectElements. If there is a syntax error in the JSON document, false is returned. Load JSON document of AutoConnectAux which contains AutoConnectElements. If there is a syntax error in the JSON document, false is returned.
<dl class="apidl"> <dl class="apidl">
<dt>**Parameters**</dt> <dt>**Parameters**</dt>
<dd><span class="apidef">aux</span>The input string to be loaded.</dd> <dd><span class="apidef">aux</span><span class="apidesc">The input string to be loaded.</span></dd>
<dt>**Return value**</dt> <dt>**Return value**</dt>
<dd><span class="apidef">true</span>The JSON document as AutoConnectAux successfully loaded.</dd> <dd><span class="apidef">true</span><span class="apidesc">The JSON document as AutoConnectAux successfully loaded.</span></dd>
<dd><span class="apidef">false</span>Loading JSON document unsuccessful, probably syntax errors have occurred or insufficient memory. You can diagnose the cause of loading failure using the [ArduinoJson Assistant](https://arduinojson.org/v5/assistant/).</dd> <dd><span class="apidef">false</span><span class="apidesc">Loading JSON document unsuccessful, probably syntax errors have occurred or insufficient memory. You can diagnose the cause of loading failure using the [ArduinoJson Assistant](https://arduinojson.org/v5/assistant/).</span></dd>
</dl> </dl>
### <i class="fa fa-caret-right"></i> on ### <i class="fa fa-caret-right"></i> on
@ -236,10 +236,9 @@ bool on(const String& uri, const AuxHandlerFunctionT handler, AutoConnectExitOrd
Register the handler function of the AutoConnectAux. Register the handler function of the AutoConnectAux.
<dl class="apidl"> <dl class="apidl">
<dt>**Parameters**</dt> <dt>**Parameters**</dt>
<dd><span class="apidef">uri</span>A string of the URI assigned to the AutoConnectAux page.</dd> <dd><span class="apidef">uri</span><span class="apidesc">A string of the URI assigned to the AutoConnectAux page.</span></dd>
<dd><span class="apidef">handler</span>A function that behaves when a request to the AutoConnectAux page occurs. AuxHandlerFunctionT type is defined by the following declaration.</dd> <dd><span class="apidef">handler</span><span class="apidesc">A function that behaves when a request to the AutoConnectAux page occurs. AuxHandlerFunctionT type is defined by the following declaration.<p class=""apidesc">`String handler(AutoConnectAux&, PageArgument&)`</p></span></dd>
<dd><span class="apidef"></span>`String handler(AutoConnectAux&, PageArgument&)`</dd> <dd><span class="apidef">order</span><span class="apidesc">Specifies when the handler is called with the following enumeration value.</span></dd>
<dd><span class="apidef">order</span>Specifies when the handler is called with the following enumeration value.</dd>
: - **AC_EXIT_AHEAD** : : - **AC_EXIT_AHEAD** :
Called before AutoConnect generates the HTML of the page. You set the value of AutoConnectElements in the handler then its value will be displayed on the page. Called before AutoConnect generates the HTML of the page. You set the value of AutoConnectElements in the handler then its value will be displayed on the page.
: - **AC_EXIT_LATER** : : - **AC_EXIT_LATER** :
@ -259,7 +258,7 @@ void onDetect(DetectExit_ft fn)
Register the function which will call from AutoConnect at the start of the captive portal. Register the function which will call from AutoConnect at the start of the captive portal.
<dl class="apidl"> <dl class="apidl">
<dt>**Parameters**</dt> <dt>**Parameters**</dt>
<dd><span class="apidef">fn</span>Function called at the captive portal start.</dd> <dd><span class="apidef">fn</span><span class="apidesc">Function called at the captive portal start.</span></dd>
</dl> </dl>
@ -270,10 +269,10 @@ typedef std::function<bool(IPAddress softapIP)> DetectExit_ft
``` ```
<dl class="apidl"> <dl class="apidl">
<dt>**Parameters**</dt> <dt>**Parameters**</dt>
<dd><span class="apidef">softapIP</span>An IP address of SoftAP for the captive portal.</dd> <dd><span class="apidef">softapIP</span><span class="apidesc">An IP address of SoftAP for the captive portal.</span></dd>
<dt>**Retuen value**</dt> <dt>**Retuen value**</dt>
<dd><span class="apidef">true</span>Continues captive portal handling.</dd> <dd><span class="apidef">true</span><span class="apidesc">Continues captive portal handling.</span></dd>
<dd><span class="apidef">false</span>Cancel the captive portal. AutoConnect::begin function will return with a false.</dd> <dd><span class="apidef">false</span><span class="apidesc">Cancel the captive portal. AutoConnect::begin function will return with a false.</span></dd>
</dl> </dl>
### <i class="fa fa-caret-right"></i> onNotFound ### <i class="fa fa-caret-right"></i> onNotFound
@ -292,14 +291,14 @@ void onNotFound(WebServer::THandlerFunction fn)
Register the handler function for undefined URL request detected. Register the handler function for undefined URL request detected.
<dl class="apidl"> <dl class="apidl">
<dt>**Parameters**</dt> <dt>**Parameters**</dt>
<dd><span class="apidef">fn</span>A function of the "not found" handler.</dd> <dd><span class="apidef">fn</span><span class="apidesc">A function of the "not found" handler.</span></dd>
</dl> </dl>
### <i class="fa fa-caret-right"></i> where ### <i class="fa fa-caret-right"></i> where
```cpp ```cpp
AutoConenctAux* where(void) AutoConenctAux* where(void)
``` ```
Returns a pointer to the AutoConnectAux object of the custom web page that caused the request to that page. This function is available only for the AutoConnectAux object. It is invalid for HTTP requests from individual pages registered with the **on** handler of ESP8266WebServer/ESP32. In other words, this function only returns the last AutoConnecAux page called. Returns a pointer to the AutoConnectAux object of the custom Web page that caused the request to that page. This function is available only for the AutoConnectAux object. It is invalid for HTTP requests from individual pages registered with the **on** handler of ESP8266WebServer/ESP32. In other words, this function only returns the last AutoConnecAux page called.
<dl class="apidl"> <dl class="apidl">
<dt>**Retuen value**</dt> <dt>**Retuen value**</dt>
<dd>A pointer to the AutoConnectAux that caused the request the page.</dd> <dd>A pointer to the AutoConnectAux that caused the request the page.</dd>

@ -7,9 +7,10 @@ AutoConnectAux(const String& uri = String(""), const String& title = String(""),
``` ```
<dl class="apidl"> <dl class="apidl">
<dt>**Parameters**</dt> <dt>**Parameters**</dt>
<dd><span class="apidef">uri</span>URI of this custom Web Page.</dd> <dd><span class="apidef">uri</span><span class="apidesc">URI of this custom Web Page.</span></dd>
<dd><span class="apidef">title</span>Page title of this custom web page. It will appear on the auto connection menu and at the top of that page.</dd> <dd><span class="apidef">title</span><span class="apidesc">Page title of this custom Web page. It will appear on the auto connection menu and at the top of that page.</span></dd>
<dd><span class="apidef">addons</span>Reference to AutoConnectElement collection.</dt> <dd><span class="apidef">menu</span><span class="apidesc">Specifies whether to display this page on menu.</span></dd>
<dd><span class="apidef">addons</span><span class="apidesc">Reference to AutoConnectElement collection.</span></dt>
</dl> </dl>
## <i class="fa fa-code"></i> Public member functions ## <i class="fa fa-code"></i> Public member functions
@ -23,17 +24,27 @@ void add(AutoConnectElement& addon)
void add(AutoConnectElementVT addons) void add(AutoConnectElementVT addons)
``` ```
Add an element to the AutoConnectAux. An added element is displayed on the custom Web page invoked from the AutoConnect menu. Add an element to the AutoConnectAux. An added element is displayed on the custom Web page invoked from the AutoConnect menu.
<dl class="apidl">
<dt>**Parameters**</dt>
<dd><span class="apidef">addon</span><span class="apidesc">Reference of AutoConnectElements. Specifies one of the AutoConnectElements classes.</span></dd>
<dd><span class="apidef">addons</span><span class="apidesc">An array list of reference of AutoConnectElements. An [list initialization](https://en.cppreference.com/w/cpp/language/list_initialization) of the [std::vector](https://en.cppreference.com/w/cpp/container/vector) can be used for the addons parameter cause the actual definition of type **AutoConnectElementVT** is `std::vector<std::reference_wrapper<AutoConnectElement>>`.</span></dd>
</dl>
### <i class="fa fa-caret-right"></i> getElement ### <i class="fa fa-caret-right"></i> getElement
```cpp ```cpp
template<typename T> T& getElement(const String& name) T& getElement<T>(const String& name)
``` ```
```cpp ```cpp
AutoConnectElement* getElement(const String& name) AutoConnectElement* getElement(const String& name)
``` ```
Get a registered AutoConnectElement as specified name. If **T** is specified as an actual type of AutoConnectElements, it returns a reference to that instance.
Get registered AutoConnectElement as specified name. <dl class="apidl">
<dt>**Parameters**</dt>
<dd><span class="apidef">T</span><span class="apidesc">Actual type name of AutoConnectElements as [AutoConnectButton](apielements.md#autoconnectbutton), [AutoConnectCheckbox](apielements.md#autoconnectcheckbox), [AutoConnectElement](apielements.md#autoconnectelement), [AutoConnectInput](apielements.md#autoconnectinput), [AutoConnectRadio](apielements.md#autoconnectradio), [AutoConnectSelect](apielements.md#autoconnectselect), [AutoConnectSubmit](apielements.md#autoconnectsubmit), [AutoConnectText](apielements.md#autoconnecttext).</span></dd>
<dd><span class="apidef">name</span><span class="apidesc">Name of the AutoConnectElements to be retrieved.</span></dd>
<dt>**Return value**</dt><dd>A reference of the AutoConnectElements. If a type is not specified returns a pointer.</dd>
</dl>
### <i class="fa fa-caret-right"></i> getElements ### <i class="fa fa-caret-right"></i> getElements
@ -41,6 +52,22 @@ Get registered AutoConnectElement as specified name.
AutoConnectElementVT& getElements(void) AutoConnectElementVT& getElements(void)
``` ```
Get vector of reference of all elements. Get vector of reference of all elements.
<dl class="apidl">
<dt>**Return value**</dt>
<dd>A reference to std::vector of reference to AutoConnecctElements.</dd>
</dl>
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.
```cpp
// An example of getting type and name of all AutoConnectElements registered in AutoConnectAux.
AutoConnectAux aux;
// some code here...
AutoConnectElementVt& elements = aux.getElements();
for (AutoConnectElement& elm : elements) {
Serial.printf("name<%s> as type %d\n", elm.name.c_str(), (int)elm.typeOf());
}
```
### <i class="fa fa-caret-right"></i> load ### <i class="fa fa-caret-right"></i> load
@ -53,7 +80,22 @@ bool load(const __FlashStringHelper* in)
```cpp ```cpp
bool load(Stream& in) bool load(Stream& in)
``` ```
Load whole elements to AutoConnectAux Pages. Load all AutoConnectElements elements from JSON document into AutoConnectAux as custom Web pages. The JSON document specified by the load function must be the [document structure](acjson.md#json-objects-elements-for-the-custom-web-page) of AutoConnectAux. Its JSON document can describe multiple pages as an array.
<dl class="apidl">
<dt>**Parameters**</dt>
<dd><span class="apidef">in</span><span class="apidesc">Specifies the JSON document to be load. The load function can input the following objects.
- String : Read-only String
- PROGMEM : Character array contained in the flash
- Stream : An entity that inherits stream class, generally SPIFFS or SD.
</span></dd>
<dt>**Return value**</dt>
<dd><span class="apidef">true</span><span class="apidesc">JSON document as the custom Web pages successfully loaded.</span></dd>
<dd><span class="apidef">false</span><span class="apidesc">JSON document loading failed.</span></dd>
</dl>
!!! hint "Load multiple custom Web pages separately"
Multiple custom Web pages can be loaded at once with JSON as an array. But it will consume a lot of memory. By loading a JSON document by page as much as possible, you can reduce memory consumption.
### <i class="fa fa-caret-right"></i> loadElement ### <i class="fa fa-caret-right"></i> loadElement
@ -66,14 +108,49 @@ bool loadElement(const __FlashStringHelper* in, const String& name = String(""))
```cpp ```cpp
bool loadElement(Stream& in, const String& name = String("")) bool loadElement(Stream& in, const String& name = String(""))
``` ```
Load specified element. Load specified element from JSON document into AutoConnectAux. The JSON document specified by the loadElement function must be the [AutoConnectElement document structure](acjson.md#json-object-for-autoconnectelements). When loading from a JSON document that describes multiple elements, its description must be an array syntax.
<dl class="apidl">
<dt>**Parameters**</dt>
<dd><span class="apidef">in</span><span class="apidesc">Specifies the JSON document to be load. The load function can input the following objects.
- String : Read-only String
- PROGMEM : Character array contained in the flash
- Stream : An entity that inherits stream class, generally SPIFFS or SD.
</span></dd>
<dd><span class="apidef">name</span><span class="apidesc">Specifies the name to be load. If the name is not specified, the loadElement function will load all elements contained in the JSON document.</span></dd>
<dt>**Return value**</dt>
<dd><span class="apidef">true</span><span class="apidesc">Specified AutoConnectElements successfully loaded.</span></dd>
<dd><span class="apidef">false</span><span class="apidesc">JSON document loading failed.</span></dd>
</dl>
!!! caution "Maybe it is an array"
Please note that the JSON document that is the input for loadElement is an array syntax of AutoConnectElements when there are multiple elements. For example, the following JSON document has a syntax error:
```json
{
"name": "Caption",
"type": "ACText",
"value": "Hello, world"
},
{
"name": "Server",
"type": "ACInput",
"label": "Server address"
}
```
The outermost `[`, `]` is missing.
### <i class="fa fa-caret-right"></i> menu ### <i class="fa fa-caret-right"></i> menu
```cpp ```cpp
void menu(const bool post) void menu(const bool post)
``` ```
Set or reset the display as menu item for this AutoConnectAux. Set or reset the display as menu item for this AutoConnectAux. This function programmatically manipulates the menu parameter of the [AutoConenctAux constructor](apiaux.md#autoconnectaux).
<dl class="apidl">
<dt>**Parameters**</dt>
<dd><span class="apidef">true</span><span class="apidesc">Show on the menu.</span></dd>
<dd><span class="apidef">false</span><span class="apidesc">Hidden on the menu.</span></dd>
</dl>
### <i class="fa fa-caret-right"></i> on ### <i class="fa fa-caret-right"></i> on
@ -83,15 +160,14 @@ void on(const AuxHandlerFunctionT handler, const AutoConnectExitOrder_t order =
Register the handler function of the AutoConnectAux. Register the handler function of the AutoConnectAux.
<dl class="apidl"> <dl class="apidl">
<dt>**Parameters**</dt> <dt>**Parameters**</dt>
<dd><span class="apidef">handler</span>A function that behaves when a request to the AutoConnectAux page occurs. AuxHandlerFunctionT type is defined by the following declaration.</dd> <dd><span class="apidef">handler</span><span class="apidesc">A function that behaves when a request to the AutoConnectAux page occurs. AuxHandlerFunctionT type is defined by the following declaration.<p class="apidesc">`String handler(AutoConnectAux&, PageArgument&)`</p></span></dd>
<dd><span class="apidef"></span>`String handler(AutoConnectAux&, PageArgument&)`</dd> <dd><span class="apidef">order</span><span class="apidesc">Specifies when the handler is called with the following enumeration value.</span>
<dd><span class="apidef">order</span>Specifies when the handler is called with the following enumeration value.</dd>
: - **AC_EXIT_AHEAD** : : - **AC_EXIT_AHEAD** :
Called before AutoConnect generates the HTML of the page. You set the value of AutoConnectElements in the handler then its value will be displayed on the page. Called before AutoConnect generates the HTML of the page. You set the value of AutoConnectElements in the handler then its value will be displayed on the page.
: - **AC_EXIT_LATER** : : - **AC_EXIT_LATER** :
Called after AutoConnect generates the HTML of the page. You can append to HTML generated by AutoConnect. Called after AutoConnect generates the HTML of the page. You can append to HTML generated by AutoConnect.
: - **AC_EXIT_BOTH** : : - **AC_EXIT_BOTH** :
Called even before generating HTML and after generated. Called even before generating HTML and after generated.</dd>
</dl> </dl>
### <i class="fa fa-caret-right"></i> release ### <i class="fa fa-caret-right"></i> release
@ -99,14 +175,31 @@ Register the handler function of the AutoConnectAux.
```cpp ```cpp
bool release(const String& name) bool release(const String& name)
``` ```
Release a specified AutoConnectElement. Release a specified AutoConnectElement from AutoConenctAux. The release function is provided to dynamically change the structure of the custom Web pages with the sketch. By combining the release function and the [add](apiaux.md#add) function or the [loadElement](apiaux.md#loadelement) function, the sketch can change the style of the custom Web page according to its behavior.
<dl class="apidl">
<dt>**Parameters**</dt>
<dd><span class="apidef">name</span><span class="apidesc">Specifies the name of AutoConnectElements to be released.</span></dd>
<dt>**Return value**</dt>
<dd><span class="apidef">true</span><span class="apidesc">The AutoConnectElement successfully released.</span></dd>
<dd><span class="apidef">false</span><span class="apidesc">The AutoConnectElement can not be released.</span></dd>
</dl>
### <i class="fa fa-caret-right"></i> saveElement ### <i class="fa fa-caret-right"></i> saveElement
```cpp ```cpp
size_t saveElement(Stream& out, std::vector<String> const& names = {}) size_t saveElement(Stream& out, std::vector<String> const& names = {})
``` ```
Write elements of AutoConnectAux to the stream. Write elements of AutoConnectAux to the stream. The saveElement function outputs the specified AutoConenctElements as a JSON document using the [prettyPrintTo](https://arduinojson.org/v5/api/jsonobject/prettyprintto/) function of the [ArduinoJson](https://arduinojson.org/) library.
<dl class="apidl">
<dt>**Parameters**</dt>
<dd><span class="apidef">out</span><span class="apidesc">Output stream to be output. SPIFFS, SD also Serial can be specified generally.</span></dd>
<dd><span class="apidef">names</span><span class="apidesc">The array of the name of AutoConnectElements to be output. If the names parameter is not specified, all AutoConnectElements registered in AutoConnectAux are output.</span></dd>
<dt>**Return value**</dt>
<dd>The number of bytes written.</dd>
</dl>
!!! note "The output format is pretty"
The saveElement function outputs a prettified JSON document.
### <i class="fa fa-caret-right"></i> setElementValue ### <i class="fa fa-caret-right"></i> setElementValue
@ -116,10 +209,43 @@ bool setElementValue(const String& name, const String value)
```cpp ```cpp
bool setElementValue(const String& name, std::vector<String> const& values) bool setElementValue(const String& name, std::vector<String> const& values)
``` ```
Sets the value of the specified AutoConnectElement. If values is specified as a *std::vector* of String, the element that can set the values is the [AutoConnectRadio](apielements.md#autoconnectradio) or the [AutoConnectSelect](apielements.md#autoconnectselect).
<dl class="apidl">
<dt>**Parameters**</dt>
<dd><span class="apidef">name</span><span class="apidesc">Specifies the name of the AutoConnectElements that you want to set the value.</span></dd>
<dd><span class="apidef">value</span><span class="apidesc">Specifies the value to be set.</span></dd>
<dd><span class="apidef">values</span><span class="apidesc">Specifies a reference of a *std::vector* of String. It contains the values of the AutoConnectRadio or the AutoConnectSelect.</span></dd>
<dt>**Return value**</dt>
<dd><span class="apidef">true</span><span class="apidesc">The value has been set.</span></dd>
<dd><span class="apidef">false</span><span class="apidesc">AutoConnectElements with the specified name are not registered. Or the type of the value is not consistent with the specified AutoConnectElements.</span></dd>
</dl>
!!! hint "You can directly access the value member variable."
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.
```cpp
AutoConnectAux aux;
// ... Griping the AutoConnectText here.
aux.setElementValue("TEXT_FIELD", "New value");
```
```cpp
AutoConnectAux aux;
// ... Griping the AutoConnectText here.
AutoConnectText& text = aux.getElement<AutoConnectText>("TEXT_FIELD");
text.value = "New value";
```
The difference between the setElementValue and the value access with the [getElement](apiaux.md#getelement) is the certainty of the registration state for the element. The [getElement](apiaux.md#getelement) returns an empty object if the element is not registered then a sketch assigns the value to it. May occur unexpected results and crashes. You should use the setElementValue if its registration is unsettled.
### <i class="fa fa-caret-right"></i> setTitle ### <i class="fa fa-caret-right"></i> setTitle
```cpp ```cpp
void setTitle(const String& title) void setTitle(const String& title)
``` ```
Set the title string of the AutoConnectAux page. Set the title string of the custom Web page. This title will be displayed as the menu title of the custom Web page.
<dl class="apidl">
<dt>**Parameter**</dt>
<dd><span class="apidef">title</span><span class="apidesc">Title string to be display.</span></dd>
</dl>
!!! caution "Not the menu title"
The setTitle function is not set for the AutoConnect menu title. The effect of this function is that custom Web page only. To change the AutoConnect menu title use [AutoConnectConfig::title](apiconfig.md#title).

@ -16,10 +16,10 @@ AutoConnectConfig(const char* ap, const char* password, const unsigned long time
``` ```
<dl class="apidl"> <dl class="apidl">
<dt>**Parameters**</dt> <dt>**Parameters**</dt>
<dd><span class="apidef">ap</span>SSID for SoftAP. The length should be up to 31. The default value is **esp8266ap** for ESP8266, **esp32ap** for ESP32.</dd> <dd><span class="apidef">ap</span><span class="apidesc">SSID for SoftAP. The length should be up to 31. The default value is **esp8266ap** for ESP8266, **esp32ap** for ESP32.</span></dd>
<dd><span class="apidef">password</span>Password for SodtAP. The length should be from 8 to up to 63. The default value is **12345678**.</dd> <dd><span class="apidef">password</span><span class="apidesc">Password for SodtAP. The length should be from 8 to up to 63. The default value is **12345678**.</span></dd>
<dd><span class="apidef">timeout</span>The timeout value of the captive portal in [ms] units. The default value is 0.</dd> <dd><span class="apidef">timeout</span><span class="apidesc">The timeout value of the captive portal in [ms] units. The default value is 0.</span></dd>
<dd><span class="apidef">channel</span>The channel number of WIFi when SoftAP starts. The default values is 1.</dd> <dd><span class="apidef">channel</span><span class="apidesc">The channel number of WIFi when SoftAP starts. The default values is 1.</span></dd>
</dl> </dl>
## <i class="fa fa-code"></i> Public member variables ## <i class="fa fa-code"></i> Public member variables
@ -37,7 +37,7 @@ SoftAP's SSID.
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. 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.
<dl class="apidl"> <dl class="apidl">
<dt>**Type**</dt> <dt>**Type**</dt>
<dd><span class="apidef" style="width:230px;">IPAddress</span>The default value is **192.168.244.1**</dd> <dd><span class="apidef">IPAddress</span><span class="apidesc">The default value is **192.168.244.1**</span></dd>
</dl> </dl>
### <i class="fa fa-caret-right"></i> autoReconnect ### <i class="fa fa-caret-right"></i> autoReconnect
@ -48,8 +48,8 @@ If the connection fails, starts the captive portal in SoftAP + STA mode.
<dt>**Type**</dt> <dt>**Type**</dt>
<dd>bool</dd> <dd>bool</dd>
<dt>**Value**</dt> <dt>**Value**</dt>
<dd><span class="apidef" style="width:230px;">true</span>Reconnect automatically.</dd> <dd><span class="apidef">true</span><span class="apidesc">Reconnect automatically.</span></dd>
<dd><span class="apidef" style="width:230px;">false</span>Starts Captive Portal in SoftAP + STA mode without trying to reconnect. This is the default.</dd> <dd><span class="apidef">false</span><span class="apidesc">Starts Captive Portal in SoftAP + STA mode without trying to reconnect. This is the default.</span></dd>
</dl> </dl>
When the autoReconnect option is enabled, an automatic connection will behave if the following conditions are satisfied. When the autoReconnect option is enabled, an automatic connection will behave if the following conditions are satisfied.
@ -64,8 +64,8 @@ Reset ESP8266 module automatically after WLAN disconnected.
<dt>**Type**</dt> <dt>**Type**</dt>
<dd>bool</dd> <dd>bool</dd>
<dt>**Value**</dt> <dt>**Value**</dt>
<dd><span class="apidef" style="width:230px;">true</span>Reset after WiFi disconnected automatically.</dd> <dd><span class="apidef">true</span><span class="apidesc">Reset after WiFi disconnected automatically.</span></dd>
<dd><span class="apidef" style="width:230px;">false</span>No reset.</dd> <dd><span class="apidef">false</span><span class="apidesc">No reset.</span></dd>
</dl> </dl>
### <i class="fa fa-caret-right"></i> autoRise ### <i class="fa fa-caret-right"></i> autoRise
@ -75,8 +75,8 @@ Captive portal activation switch. False for disabling the captive portal. It pre
<dt>**Type**</dt> <dt>**Type**</dt>
<dd>bool</dd> <dd>bool</dd>
<dt>**Value**</dt> <dt>**Value**</dt>
<dd><span class="apidef" style="width:230px;">true</span>Enable the captive portal. This is the default.</dd> <dd><span class="apidef">true</span><span class="apidesc">Enable the captive portal. This is the default.</span></dd>
<dd><span class="apidef" style="width:230px;">false</span>Disable the captive portal.</dd> <dd><span class="apidef">false</span><span class="apidesc">Disable the captive portal.</span></dd>
</dl> </dl>
### <i class="fa fa-caret-right"></i> autoSave ### <i class="fa fa-caret-right"></i> autoSave
@ -86,8 +86,8 @@ The credential saved automatically at the connection establishment.
<dt>**Type**</dt> <dt>**Type**</dt>
<dd>AC_SAVECREDENTIAL_t</dd> <dd>AC_SAVECREDENTIAL_t</dd>
<dt>**Value**</dt> <dt>**Value**</dt>
<dd><span class="apidef" style="width:230px;">AC_SAVECREDENTIAL_AUTO</span>The credential saved automatically. This is the default.</dd> <dd><span class="apidef">AC_SAVECREDENTIAL_AUTO</span><span class="apidesc"></span><span class="apidef">&nbsp;</span><span class="apidesc">The credential saved automatically. This is the default.</span></dd>
<dd><span class="apidef" style="width:230px;">AC_SAVECREDENTIAL_NEVER</span>The credential no saved.</dd> <dd><span class="apidef">AC_SAVECREDENTIAL_NEVER</span><span class="apidesc"></span><span class="apidef">&nbsp;</span><span class="apidesc">The credential no saved.</span></dd>
</dl> </dl>
### <i class="fa fa-caret-right"></i> bootUri ### <i class="fa fa-caret-right"></i> bootUri
@ -97,8 +97,8 @@ Specify the location to be redirected after module reset in the AutoConnect menu
<dt>**Type**</dt> <dt>**Type**</dt>
<dd>AC_ONBOOTURI_t</dd> <dd>AC_ONBOOTURI_t</dd>
<dt>**Value**</dt> <dt>**Value**</dt>
<dd><span class="apidef" style="width:230px;">AC_ONBOOTURI_ROOT</span>Resetting the module redirects it to the AutoConnect root path. The root path is assumed to be AUTOCONNECT_URI defined in AutoConnectDefs.h.</dd> <dd><span class="apidef">AC_ONBOOTURI_ROOT</span><span class="apidesc"></span><span class="apidef">&nbsp;</span><span class="apidesc">Resetting the module redirects it to the AutoConnect root path. The root path is assumed to be AUTOCONNECT_URI defined in AutoConnectDefs.h.</span></dd>
<dd><span class="apidef" style="width:230px;">AC_ONBOOTURI_HOME</span>It is redirected to the uri specified by [**AutoConnectConfig::homeUri**](apiconfig.md#homeuri).</dd> <dd><span class="apidef">AC_ONBOOTURI_HOME</span><span class="apidesc"></span><span class="apidef">&nbsp;</span><span class="apidesc">It is redirected to the uri specified by [**AutoConnectConfig::homeUri**](apiconfig.md#homeuri).</span></dd>
</dl> </dl>
### <i class="fa fa-caret-right"></i> boundaryOffset ### <i class="fa fa-caret-right"></i> boundaryOffset
@ -147,7 +147,7 @@ Set secondary DNS server address when using static IP address.
Sets gateway 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. Sets gateway 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.
<dl class="apidl"> <dl class="apidl">
<dt>**Type**</dt> <dt>**Type**</dt>
<dd><span class="apidef" style="width:230px;">IPAddress</span>The default value is **192.168.244.1**</dd> <dd><span class="apidef">IPAddress</span><span class="apidesc">The default value is **192.168.244.1**</span></dd>
</dl> </dl>
### <i class="fa fa-caret-right"></i> hidden ### <i class="fa fa-caret-right"></i> hidden
@ -157,8 +157,8 @@ Sets SoftAP to hidden SSID.
<dt>**Type**</dt> <dt>**Type**</dt>
<dd>uint8_t</dd> <dd>uint8_t</dd>
<dt>**Value**</dt> <dt>**Value**</dt>
<dd><span class="apidef" style="width:230px;">0</span>SSID will be appeared. This is the default.</dd> <dd><span class="apidef">0</span><span class="aidesc">SSID will be appeared. This is the default.</span></dd>
<dd><span class="apidef" style="width:230px;">1</span>SSID will be hidden.</dd> <dd><span class="apidef">1</span><span class="apidesc">SSID will be hidden.</span></dd>
</dl> </dl>
### <i class="fa fa-caret-right"></i> homeUri ### <i class="fa fa-caret-right"></i> homeUri
@ -184,8 +184,8 @@ Disable the first WiFi.begin() and start the captive portal. If this option is e
<dt>**Type**</dt> <dt>**Type**</dt>
<dd>bool</dd> <dd>bool</dd>
<dt>**Value**</dt> <dt>**Value**</dt>
<dd><span class="apidef" style="width:230px;">true</span>Start the captive portal with [**AutoConnect::begin**](api.md#begin).</dd> <dd><span class="apidef">true</span><span class="apidesc">Start the captive portal with [**AutoConnect::begin**](api.md#begin).</span></dd>
<dd><span class="apidef" style="width:230px;">false</span>Enable the first WiFi.begin() and it will start captive portal when connection failed. This is default.</dd> <dd><span class="apidef">false</span><span class="apidesc">Enable the first WiFi.begin() and it will start captive portal when connection failed. This is default.</span></dd>
</dl> </dl>
### <i class="fa fa-caret-right"></i> netmask ### <i class="fa fa-caret-right"></i> netmask
@ -193,7 +193,7 @@ Disable the first WiFi.begin() and start the captive portal. If this option is e
Sets subnet mask for Soft AP in captive portal. When AutoConnect fails the initial WiFi.begin, it starts the captive portal with the IP address specified this. Sets subnet mask for Soft AP in captive portal. When AutoConnect fails the initial WiFi.begin, it starts the captive portal with the IP address specified this.
<dl class="apidl"> <dl class="apidl">
<dt>**Type**</dt> <dt>**Type**</dt>
<dd><span class="apidef" style="width:230px;">IPAddress</span>The default value is **255.255.255.0**</dd> <dd><span class="apidef">IPAddress</span><span class="apidesc">The default value is **255.255.255.0**</span></dd>
</dl> </dl>
### <i class="fa fa-caret-right"></i> portalTimeout ### <i class="fa fa-caret-right"></i> portalTimeout
@ -201,7 +201,7 @@ Sets subnet mask for Soft AP in captive portal. When AutoConnect fails the initi
Specify the timeout value of the captive portal in [ms] units. It is valid when the station is not connected and does not time out if the station is connected to the ESP module in SoftAP mode (ie Attempting WiFi connection with the portal function). If 0, the captive portal will not be timed-out. Specify the timeout value of the captive portal in [ms] units. It is valid when the station is not connected and does not time out if the station is connected to the ESP module in SoftAP mode (ie Attempting WiFi connection with the portal function). If 0, the captive portal will not be timed-out.
<dl class="apidl"> <dl class="apidl">
<dt>**Type**</dt> <dt>**Type**</dt>
<dd><span class="apidef" style="width:230px;">unsigned long</span>Captive portal timeout value. The default value is 0.</dd> <dd><span class="apidef">unsigned long</span><span class="apidesc">Captive portal timeout value. The default value is 0.</span></dd>
</dl> </dl>
### <i class="fa fa-caret-right"></i> psk ### <i class="fa fa-caret-right"></i> psk
@ -219,8 +219,8 @@ Specify whether to continue the portal function even if the captive portal timed
<dt>**Type**</dt> <dt>**Type**</dt>
<dd>bool</dd> <dd>bool</dd>
<dt>**Value**</dt> <dt>**Value**</dt>
<dd><span class="apidef" style="width:230px;">true</span>Continue the portal function even if the captive portal times out. The STA + SoftAP mode of the ESP module continues and accepts the connection request to the AP.</dd> <dd><span class="apidef">true</span><span class="apidesc">Continue the portal function even if the captive portal times out. The STA + SoftAP mode of the ESP module continues and accepts the connection request to the AP.</span></dd>
<dd><span class="apidef" style="width:230px;">false</span>When the captive portal times out, STA + SoftAP mode of the ESP module is stopped. This is default.</dd> <dd><span class="apidef">false</span><span class="apidesc">When the captive portal times out, STA + SoftAP mode of the ESP module is stopped. This is default.</span></dd>
</dl> </dl>
!!! hint "Connection request after timed-out" !!! hint "Connection request after timed-out"

@ -7,9 +7,9 @@ AutoConnectButton(const char* name = "", const char* value = "", const String& a
``` ```
<dl class="apidl"> <dl class="apidl">
<dt>**Parameters**</dt> <dt>**Parameters**</dt>
<dd><span class="apidef">name</span>The element name.</dd> <dd><span class="apidef">name</span><span class="apidesc">The element name.</span></dd>
<dd><span class="apidef">value</span>Value of the element.</dd> <dd><span class="apidef">value</span><span class="apidesc">Value of the element.</span></dd>
<dd><span class="apidef">action</span>Native code of the action script executed when the button is clicked.</dd> <dd><span class="apidef">action</span><span class="apidesc">Native code of the action script executed when the button is clicked.</span></dd>
</dl> </dl>
### <i class="fa fa-code"></i> Public member variables ### <i class="fa fa-code"></i> Public member variables
@ -19,7 +19,7 @@ AutoConnectButton(const char* name = "", const char* value = "", const String& a
The element name. The element name.
<dl class="apidl"> <dl class="apidl">
<dt>**Type**</dt> <dt>**Type**</dt>
<dd><span class="apidef" style="width:230px;">String</span></dd> <dd><span class="apidef">String</span><span class="apidesc"></span></dd>
</dl> </dl>
#### <i class="fa fa-caret-right"></i> value #### <i class="fa fa-caret-right"></i> value
@ -27,7 +27,7 @@ The element name.
Value of the element. Value of the element.
<dl class="apidl"> <dl class="apidl">
<dt>**Type**</dt> <dt>**Type**</dt>
<dd><span class="apidef" style="width:230px;">String</span></dd> <dd><span class="apidef">String</span><span class="apidesc"></span></dd>
</dl> </dl>
#### <i class="fa fa-caret-right"></i> action #### <i class="fa fa-caret-right"></i> action
@ -35,7 +35,7 @@ Value of the element.
HTML native code of the action script to be executed when the button is clicked. It is mostly used with a JavaScript to activate a script.[^1] HTML native code of the action script to be executed when the button is clicked. It is mostly used with a JavaScript to activate a script.[^1]
<dl class="apidl"> <dl class="apidl">
<dt>**Type**</dt> <dt>**Type**</dt>
<dd><span class="apidef" style="width:230px;">String</span></dd> <dd><span class="apidef">String</span><span class="apidesc"></span></dd>
</dl> </dl>
[^1]:JavaScript can be inserted into a custom Web page using AutoConnectElement. [^1]:JavaScript can be inserted into a custom Web page using AutoConnectElement.
@ -62,10 +62,10 @@ Returns type of AutoConnectElement.
``` ```
<dl class="apidl"> <dl class="apidl">
<dt>**Parameters**</dt> <dt>**Parameters**</dt>
<dd><span class="apidef">name</span>The element name.</dd> <dd><span class="apidef">name</span><span class="apidesc">The element name.</span></dd>
<dd><span class="apidef">value</span>Value of the element.</dd> <dd><span class="apidef">value</span><span class="apidesc">Value of the element.</span></dd>
<dd><span class="apidef">label</span>A label string prefixed to the checkbox.</dd> <dd><span class="apidef">label</span><span class="apidesc">A label string prefixed to the checkbox.</span></dd>
<dd><span class="apidef">check</span>Checked state of the checkbox.</dd> <dd><span class="apidef">check</span><span class="apidesc">Checked state of the checkbox.</span></dd>
</dl> </dl>
### <i class="fa fa-code"></i> Public member variables ### <i class="fa fa-code"></i> Public member variables
@ -75,7 +75,7 @@ Returns type of AutoConnectElement.
The element name. The element name.
<dl class="apidl"> <dl class="apidl">
<dt>**Type**</dt> <dt>**Type**</dt>
<dd><span class="apidef" style="width:230px;">String</span></dd> <dd><span class="apidef">String</span><span class="apidesc"></span></dd>
</dl> </dl>
#### <i class="fa fa-caret-right"></i> value #### <i class="fa fa-caret-right"></i> value
@ -83,7 +83,7 @@ The element name.
Value of the element. It becomes a value attribute of an HTML `#!html <input type="checkbox">` tag. Value of the element. It becomes a value attribute of an HTML `#!html <input type="checkbox">` tag.
<dl class="apidl"> <dl class="apidl">
<dt>**Type**</dt> <dt>**Type**</dt>
<dd><span class="apidef" style="width:230px;">String</span></dd> <dd><span class="apidef">String</span><span class="apidesc"></span></dd>
</dl> </dl>
#### <i class="fa fa-caret-right"></i> label #### <i class="fa fa-caret-right"></i> label
@ -91,7 +91,7 @@ Value of the element. It becomes a value attribute of an HTML `#!html <input typ
A label is an optional string. A label is always arranged on the right side of the checkbox. Specification of a label will generate an HTML `#!html <label>` tag with an `id` attribute. The checkbox and the label are connected by the id attribute. A label is an optional string. A label is always arranged on the right side of the checkbox. Specification of a label will generate an HTML `#!html <label>` tag with an `id` attribute. The checkbox and the label are connected by the id attribute.
<dl class="apidl"> <dl class="apidl">
<dt>**Type**</dt> <dt>**Type**</dt>
<dd><span class="apidef" style="width:230px;">String</span></dd> <dd><span class="apidef">String</span><span class="apidesc"></span></dd>
</dl> </dl>
#### <i class="fa fa-caret-right"></i> checked #### <i class="fa fa-caret-right"></i> checked
@ -99,7 +99,7 @@ A label is an optional string. A label is always arranged on the right side of t
It indicates the checked status of the checkbox. The value of the checked checkbox element is packed in the query string and sent by submit. It indicates the checked status of the checkbox. The value of the checked checkbox element is packed in the query string and sent by submit.
<dl class="apidl"> <dl class="apidl">
<dt>**Type**</dt> <dt>**Type**</dt>
<dd><span class="apidef" style="width:230px;">Boolean</span></dd> <dd><span class="apidef">Boolean</span><span class="apidesc"></span></dd>
</dl> </dl>
### <i class="fa fa-code"></i> Public member functions ### <i class="fa fa-code"></i> Public member functions
@ -124,8 +124,8 @@ AutoConnectElement(const char* name = "", const char* value = "")
``` ```
<dl class="apidl"> <dl class="apidl">
<dt>**Parameters**</dt> <dt>**Parameters**</dt>
<dd><span class="apidef">name</span>The element name.</dd> <dd><span class="apidef">name</span><span class="apidesc">The element name.</span></dd>
<dd><span class="apidef">value</span>Value of the element.</dd> <dd><span class="apidef">value</span><span class="apidesc">Value of the element.</span></dd>
</dl> </dl>
### <i class="fa fa-code"></i> Public member variables ### <i class="fa fa-code"></i> Public member variables
@ -135,7 +135,7 @@ AutoConnectElement(const char* name = "", const char* value = "")
The element name. The element name.
<dl class="apidl"> <dl class="apidl">
<dt>**Type**</dt> <dt>**Type**</dt>
<dd><span class="apidef" style="width:230px;">String</span></dd> <dd><span class="apidef">String</span><span class="apidesc"></span></dd>
</dl> </dl>
#### <i class="fa fa-caret-right"></i> value #### <i class="fa fa-caret-right"></i> value
@ -143,7 +143,7 @@ The element name.
Value of the element. It is output as HTML as it is as a source for generating HTML code. Value of the element. It is output as HTML as it is as a source for generating HTML code.
<dl class="apidl"> <dl class="apidl">
<dt>**Type**</dt> <dt>**Type**</dt>
<dd><span class="apidef" style="width:230px;">String</span></dd> <dd><span class="apidef">String</span><span class="apidesc"></span></dd>
</dl> </dl>
### <i class="fa fa-code"></i> Public member functions ### <i class="fa fa-code"></i> Public member functions
@ -168,11 +168,11 @@ AutoConnectInput(const char* name = "", const char* value = "", const char* labe
``` ```
<dl class="apidl"> <dl class="apidl">
<dt>**Parameters**</dt> <dt>**Parameters**</dt>
<dd><span class="apidef">name</span>The element name.</dd> <dd><span class="apidef">name</span><span class="apidesc">The element name.</span></dd>
<dd><span class="apidef">value</span>Value of the element.</dd> <dd><span class="apidef">value</span><span class="apidesc">Value of the element.</span></dd>
<dd><span class="apidef">label</span>Label string.</dd> <dd><span class="apidef">label</span><span class="apidesc">Label string.</span></dd>
<dd><span class="apidef">pattern</span>Regular expression string for checking data format.</dd> <dd><span class="apidef">pattern</span><span class="apidesc">Regular expression string for checking data format.</span></dd>
<dd><span class="apidef">placeholder</span>A placeholder string.</dd> <dd><span class="apidef">placeholder</span><span class="apidesc">A placeholder string.</span></dd>
</dl> </dl>
### <i class="fa fa-code"></i> Public member variables ### <i class="fa fa-code"></i> Public member variables
@ -182,7 +182,7 @@ AutoConnectInput(const char* name = "", const char* value = "", const char* labe
The element name. The element name.
<dl class="apidl"> <dl class="apidl">
<dt>**Type**</dt> <dt>**Type**</dt>
<dd><span class="apidef" style="width:230px;">String</span></dd> <dd><span class="apidef">String</span><span class="apidesc"></span></dd>
</dl> </dl>
#### <i class="fa fa-caret-right"></i> value #### <i class="fa fa-caret-right"></i> value
@ -190,7 +190,7 @@ The element name.
Value of the element. It becomes a value attribute of an HTML `#!html <input type="text">` tag. An entered text in the custom Web page will be sent with a query string of the form. The value set before accessing the page is displayed as the initial value. Value of the element. It becomes a value attribute of an HTML `#!html <input type="text">` tag. An entered text in the custom Web page will be sent with a query string of the form. The value set before accessing the page is displayed as the initial value.
<dl class="apidl"> <dl class="apidl">
<dt>**Type**</dt> <dt>**Type**</dt>
<dd><span class="apidef" style="width:230px;">String</span></dd> <dd><span class="apidef">String</span><span class="apidesc"></span></dd>
</dl> </dl>
#### <i class="fa fa-caret-right"></i> label #### <i class="fa fa-caret-right"></i> label
@ -198,7 +198,7 @@ Value of the element. It becomes a value attribute of an HTML `#!html <input typ
A label is an optional string. A label is always arranged on the left side of the input box. Specification of a label will generate an HTML `#!html <label>` tag with an id attribute. The input box and the label are connected by the id attribute. A label is an optional string. A label is always arranged on the left side of the input box. Specification of a label will generate an HTML `#!html <label>` tag with an id attribute. The input box and the label are connected by the id attribute.
<dl class="apidl"> <dl class="apidl">
<dt>**Type**</dt> <dt>**Type**</dt>
<dd><span class="apidef" style="width:230px;">String</span></dd> <dd><span class="apidef">String</span><span class="apidesc"></span></dd>
</dl> </dl>
#### <i class="fa fa-caret-right"></i> pattern #### <i class="fa fa-caret-right"></i> pattern
@ -206,7 +206,7 @@ A label is an optional string. A label is always arranged on the left side of th
A pattern specifies a regular expression that the input-box's value is checked against on form submission. A pattern specifies a regular expression that the input-box's value is checked against on form submission.
<dl class="apidl"> <dl class="apidl">
<dt>**Type**</dt> <dt>**Type**</dt>
<dd><span class="apidef" style="width:230px;">String</span></dd> <dd><span class="apidef">String</span><span class="apidesc"></span></dd>
</dl> </dl>
#### <i class="fa fa-caret-right"></i> placeholder #### <i class="fa fa-caret-right"></i> placeholder
@ -214,7 +214,7 @@ A pattern specifies a regular expression that the input-box's value is checked a
A placeholder is an option string. Specification of a placeholder will generate a `placeholder` attribute for the input tag. A placeholder is an option string. Specification of a placeholder will generate a `placeholder` attribute for the input tag.
<dl class="apidl"> <dl class="apidl">
<dt>**Type**</dt> <dt>**Type**</dt>
<dd><span class="apidef" style="width:230px;">String</span></dd> <dd><span class="apidef">String</span><span class="apidesc"></span></dd>
</dl> </dl>
### <i class="fa fa-code"></i> Public member functions ### <i class="fa fa-code"></i> Public member functions
@ -239,11 +239,11 @@ AutoConnectRadio(const char* name = "", std::vector<String> const& values = {},
``` ```
<dl class="apidl"> <dl class="apidl">
<dt>**Parameters**</dt> <dt>**Parameters**</dt>
<dd><span class="apidef">name</span>The element name.</dd> <dd><span class="apidef">name</span><span class="apidesc">The element name.</span></dd>
<dd><span class="apidef">values</span>An array of values of the radio buttons. Specifies an [std::vector](https://en.cppreference.com/w/cpp/container/vector) object.</dd> <dd><span class="apidef">values</span><span class="apidesc">An array of values of the radio buttons. Specifies an [std::vector](https://en.cppreference.com/w/cpp/container/vector) object.</span></dd>
<dd><span class="apidef">label</span>Label string.</dd> <dd><span class="apidef">label</span><span class="apidesc">Label string.</span></dd>
<dd><span class="apidef">order</span>The direction to arrange the radio buttons.</dd> <dd><span class="apidef">order</span><span class="apidesc">The direction to arrange the radio buttons.</span></dd>
<dd><span class="apidef">checked</span>An index to be checked in the radio buttons.</dd> <dd><span class="apidef">checked</span><span class="apidesc">An index to be checked in the radio buttons.</span></dd>
</dl> </dl>
### <i class="fa fa-code"></i> Public member variables ### <i class="fa fa-code"></i> Public member variables
@ -253,7 +253,7 @@ AutoConnectRadio(const char* name = "", std::vector<String> const& values = {},
The element name. The element name.
<dl class="apidl"> <dl class="apidl">
<dt>**Type**</dt> <dt>**Type**</dt>
<dd><span class="apidef" style="width:230px;">String</span></dd> <dd><span class="apidef">String</span><span class="apidesc"></span></dd>
</dl> </dl>
#### <i class="fa fa-caret-right"></i> values #### <i class="fa fa-caret-right"></i> values
@ -261,7 +261,7 @@ The element name.
An array of String type for the radio button options. It is an initialization list can be used. The `#!html <input type="radio">` tags will be generated from each entry in the values. An array of String type for the radio button options. It is an initialization list can be used. The `#!html <input type="radio">` tags will be generated from each entry in the values.
<dl class="apidl"> <dl class="apidl">
<dt>**Type**</dt> <dt>**Type**</dt>
<dd><span class="apidef" style="width:230px;">std::vector&lt;String&gt;</span></dd> <dd><span class="apidef">std::vector&lt;String&gt;</span><span class="apidesc"></span></dd>
</dl> </dl>
#### <i class="fa fa-caret-right"></i> label #### <i class="fa fa-caret-right"></i> label
@ -269,18 +269,19 @@ An array of String type for the radio button options. It is an initialization li
A label is an optional string. A label will be arranged in the left or top of the radio buttons according to the [order](#order). A label is an optional string. A label will be arranged in the left or top of the radio buttons according to the [order](#order).
<dl class="apidl"> <dl class="apidl">
<dt>**Type**</dt> <dt>**Type**</dt>
<dd><span class="apidef" style="width:230px;">String</span></dd> <dd><span class="apidef">String</span><span class="apidesc"></span></dd>
</dl> </dl>
#### <i class="fa fa-caret-right"></i> order #### <i class="fa fa-caret-right"></i> order
Specifies the direction to arrange the radio buttons. A label will place in the left or the top according to the **_order_**. It is a value of **ACArrange_t** type and accepts one of the following: Specifies the direction to arrange the radio buttons. A label will place in the left or the top according to the **_order_**. It is a value of **ACArrange_t** type and accepts one of the following:
- **`AC_Horizontal`** : Horizontal arrangement.
- **`AC_Vertical`** : Vertical arrangement.
<dl class="apidl"> <dl class="apidl">
<dt>**Type**</dt> <dt>**Type**</dt>
<dd><span class="apidef" style="width:230px;">ACArrange_t</span></dd> <dd><span class="apidef">ACArrange_t</span><span class="apidesc">
- **`AC_Horizontal`** : Horizontal arrangement.
- **`AC_Vertical`** : Vertical arrangement.
</span></dd>
</dl> </dl>
#### <i class="fa fa-caret-right"></i> checked #### <i class="fa fa-caret-right"></i> checked
@ -288,7 +289,7 @@ Specifies the direction to arrange the radio buttons. A label will place in the
Specifies the index number (1-based) of the **values** to be checked. If this parameter is not specified neither item is checked. Specifies the index number (1-based) of the **values** to be checked. If this parameter is not specified neither item is checked.
<dl class="apidl"> <dl class="apidl">
<dt>**Type**</dt> <dt>**Type**</dt>
<dd><span class="apidef" style="width:230px;">uint8_t</span></dd> <dd><span class="apidef">uint8_t</span><span class="apidesc"></span></dd>
</dl> </dl>
### <i class="fa fa-code"></i> Public member functions ### <i class="fa fa-code"></i> Public member functions
@ -312,7 +313,7 @@ void add(const String& value)
Adds an option for the radio button. Adds an option for the radio button.
<dl class="apidl"> <dl class="apidl">
<dt>**Parameters**</dt> <dt>**Parameters**</dt>
<dd><span class="apidef">value</span>An option string to add to the radio button.</dd> <dd><span class="apidef">value</span><span class="apidesc">An option string to add to the radio button.</span></dd>
</dl> </dl>
#### <i class="fa fa-caret-right"></i> check #### <i class="fa fa-caret-right"></i> check
@ -323,7 +324,7 @@ void check(const String& value)
Indicates the check of the specified option for the radio buttons. You can use the **check** function for checking dynamically with arbitrary of the radio button. Indicates the check of the specified option for the radio buttons. You can use the **check** function for checking dynamically with arbitrary of the radio button.
<dl class="apidl"> <dl class="apidl">
<dt>**Parameters**</dt> <dt>**Parameters**</dt>
<dd><span class="apidef">value</span>An option string to be checked.</dd> <dd><span class="apidef">value</span><span class="apidesc">An option string to be checked.</span></dd>
</dl> </dl>
#### <i class="fa fa-caret-right"></i> empty #### <i class="fa fa-caret-right"></i> empty
@ -334,7 +335,7 @@ void empty(const size_t reserve = 0)
Clear the array of option strings that AutoConnectRadio has in values. When a **_reserve_** parameter is specified, a vector container of that size is reserved. Clear the array of option strings that AutoConnectRadio has in values. When a **_reserve_** parameter is specified, a vector container of that size is reserved.
<dl class="apidl"> <dl class="apidl">
<dt>**Parameters**</dt> <dt>**Parameters**</dt>
<dd><span class="apidef">reserve</span>Reserved size of a container for option strings.</dd> <dd><span class="apidef">reserve</span><span class="apidesc">Reserved size of a container for option strings.</span></dd>
</dl> </dl>
#### <i class="fa fa-caret-right"></i> operator &#91;&nbsp;&#93; #### <i class="fa fa-caret-right"></i> operator &#91;&nbsp;&#93;
@ -345,7 +346,7 @@ const String& operator[] (const std::size_t n)
Returns the option string of the index specified by **_n_**. Returns the option string of the index specified by **_n_**.
<dl class="apidl"> <dl class="apidl">
<dt>**Parameters**</dt> <dt>**Parameters**</dt>
<dd><span class="apidef">n</span>Index of values array to return.</dd> <dd><span class="apidef">n</span><span class="apidesc">Index of values array to return.</span></dd>
</dl> </dl>
#### <i class="fa fa-caret-right"></i> value #### <i class="fa fa-caret-right"></i> value
@ -361,6 +362,81 @@ Returns current checked option of the radio buttons.
## AutoConnectSelect ## AutoConnectSelect
### <i class="fa fa-code"></i> Constructor
```cpp
AutoConnectSelect(const char* name = "", std::vector<String> const& options = {}, const char* label = "")
```
<dl class="apidl">
<dt>**Parameters**</dt>
<dd><span class="apidef">name</span><span class="apidesc">The element name.</span></dd>
<dd><span class="apidef">options</span><span class="apidesc">An array of options of the select element. Specifies an [std::vector](https://en.cppreference.com/w/cpp/container/vector) object.</span></dd>
<dd><span class="apidef">label</span><span class="apidesc">Label string.</span></dd>
</dl>
### <i class="fa fa-code"></i> Public member variables
#### <i class="fa fa-caret-right"></i> name
The element name.
<dl class="apidl">
<dt>**Type**</dt>
<dd><span class="apidef">String</span><span class="apidesc"></span></dd>
</dl>
#### <i class="fa fa-caret-right"></i> options
An array of String type for the selection options. It is an initialization list can be used. The `#!html <option value>` tags will be generated from each entry in the options.
<dl class="apidl">
<dt>**Type**</dt>
<dd><span class="apidef">std::vector&lt;String&gt;</span><span class="apidesc"></span></dd>
</dl>
#### <i class="fa fa-caret-right"></i> label
A label is an optional string. A label will be arranged in the top of the selection list.
<dl class="apidl">
<dt>**Type**</dt>
<dd><span class="apidef">String</span><span class="apidesc"></span></dd>
</dl>
### <i class="fa fa-code"></i> Public member functions
#### <i class="fa fa-caret-right"></i> typeOf
```cpp
ACElement_t typeOf(void)
```
Returns type of AutoConnectElement.
<dl class="apidl">
<dt>**Return value**</dt>
<dd>AC_Select</dd>
</dl>
#### <i class="fa fa-caret-right"></i> add
```cpp
void add(const String& option)
```
#### <i class="fa fa-caret-right"></i> empty
```cpp
void empty(const size_t reserve = 0)
```
#### <i class="fa fa-caret-right"></i> size
```cpp
size_t size(void)
```
#### <i class="fa fa-caret-right"></i> operator &#91;&nbsp;&#93;
```cpp
const String& operator[] (const std::size_t n)
```
## AutoConnectSubmit ## AutoConnectSubmit
## AutoConnectText ## AutoConnectText

@ -35,13 +35,19 @@
color: rgba(102,217,224,1); color: rgba(102,217,224,1);
} }
.apidl {
margin-left: 20px;
}
.apidef { .apidef {
display: inline-block; display: block;
float: left;
width: 100px; width: 100px;
} }
.apidl { .apidesc {
margin-left: 20px; display: inline-block;
width: calc(100% - 100px);
} }
.ulsty-edit > li:before { .ulsty-edit > li:before {

@ -68,31 +68,31 @@ By giving a [**pattern**](achandling.md#check-data-against-on-submission) to [Au
Here, represent examples the typical regular expression for the input validation. Here, represent examples the typical regular expression for the input validation.
### <i class="fa fa-check-square"></i> URL ### <i class="far fa-check-square"></i> URL
``` ```
^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$ ^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$
``` ```
### <i class="fa fa-check-square"></i> DNS hostname ### <i class="far fa-check-square"></i> DNS hostname
``` ```
^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$ ^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$
``` ```
### <i class="fa fa-check-square"></i> email address [^1] ### <i class="far fa-check-square"></i> email address [^1]
``` ```
^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$ ^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$
``` ```
### <i class="fa fa-check-square"></i> IP Address ### <i class="far fa-check-square"></i> IP Address
``` ```
^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$ ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$
``` ```
### <i class="fa fa-check-square"></i> Date as MM/DD/YYYY [^2] ### <i class="far fa-check-square"></i> Date as MM/DD/YYYY [^2]
``` ```
^(0[1-9]|1[012])[- \/.](0[1-9]|[12][0-9]|3[01])[- \/.](19|20)\d\d$ ^(0[1-9]|1[012])[- \/.](0[1-9]|[12][0-9]|3[01])[- \/.](19|20)\d\d$
@ -102,4 +102,4 @@ Here, represent examples the typical regular expression for the input validation
If that regular expression contains a backquote it must be escaped by backquote duplication. If that regular expression contains a backquote it must be escaped by backquote duplication.
[^1]: This regular expression does not fully support the format of the e-mail address requested in [RFC5322](https://tools.ietf.org/html/rfc5322). [^1]: This regular expression does not fully support the format of the e-mail address requested in [RFC5322](https://tools.ietf.org/html/rfc5322).
[^2]: This regular expression does not consider semantic constraints. It is not possible to detect errors that do not exist as actual dates. [^2]: This regular expression does not consider semantic constraints. It is not possible to detect errors that do not exist as actual dates.

@ -185,9 +185,9 @@ It consumes about 2K bytes in the static and about 12K bytes are consumed at the
Because AutoConnect does not send a login success response to the captive portal requests from the smartphone. The login success response varies iOS, Android and Windows. By analyzing the request URL of different login success inquiries for each OS, the correct behavior can be implemented, but not yet. Please resets ESP8266 from the AutoConnect menu. Because AutoConnect does not send a login success response to the captive portal requests from the smartphone. The login success response varies iOS, Android and Windows. By analyzing the request URL of different login success inquiries for each OS, the correct behavior can be implemented, but not yet. Please resets ESP8266 from the AutoConnect menu.
## <i class="fa fa-question-circle"></i> I can not see the custom web page. ## <i class="fa fa-question-circle"></i> I cannot see the custom Web page.
JSON parse error If the sketch is correct, a JSON syntax error may have occurred. In this case, activate the [AC_DEBUG](faq.md#3-turn-on-the-debug-log-options) and rerun. If you take the message of JSON syntax error, the [Json Assistant](https://arduinojson.org/v5/assistant/) helps syntax checking. This online tool is provided by the author of ArduinoJson and is most consistent for the AutoConnect.
## <i class="fa fa-question-circle"></i> AutoConnect behaves not stable with my sketch yet. ## <i class="fa fa-question-circle"></i> AutoConnect behaves not stable with my sketch yet.
@ -231,4 +231,13 @@ To fully enable for the AutoConnect debug logging options, change the following
### 4. Reports the issue to AutoConnect repository on Github ### 4. Reports the issue to AutoConnect repository on Github
If you can not solve AutoConnect problems please report to [Issues](https://github.com/Hieromon/AutoConnect/issues). And please make your question comprehensively, not a statement. Include all relevant information. If you can not solve AutoConnect problems please report to [Issues](https://github.com/Hieromon/AutoConnect/issues). And please make your question comprehensively, not a statement. Include all relevant information as follows.
- Hardware module
- Arduino core Version (including the upstream tag ID.)
- Operating System which you use
- lwIP variant
- Problem description
- If you have a STACK DUMP decoded result with formatted by the code block tag
- The sketch code with formatted by the code block tag
- Debug messages output

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 189 KiB

After

Width:  |  Height:  |  Size: 124 KiB

@ -36,7 +36,7 @@ Easy implementing the Web interface constituting the WLAN for ESP8266/ESP32 WiFi
<div style="display:block;height:425px;"> <div style="display:block;height:425px;">
<img style="float:left;width:380px;" src="./images/aux_json.png"> <img style="float:left;width:380px;" src="./images/aux_json.png">
<img style="float:left;margin-top:200px;margin-left:10px;margin-right:10px;width:32px;" src="./images/arrow_right.png"> <img style="float:left;margin-top:200px;margin-left:10px;margin-right:10px;width:32px;" src="./images/arrow_right.png">
<img style="float:left;width:240px" src="./images/AutoConnectAux.gif"> <span style="float:left;width:242px;height:425px;border:1px solid lightgrey;"><img data-gifffer="./images/aux_ov.gif" data-gifffer-width="240" data-gifffer-height="423" /></span>
</div> </div>
## Installation ## Installation

@ -0,0 +1,204 @@
## Suppress increase in memory consumption
Custom Web page processing consumes a lot of memory. AutoConnect will take a whole string of the JSON document for the custom Web pages into memory. The required buffer size for the JSON document of example sketch *mqttRSSI* reaches approximately 3000 bytes. And actually, it needs twice the heap area. Especially this constraint will be a problem with the ESP8266 which has a heap size poor.
AutoConnect can handle custom Web pages without using JSON. In that case, since the ArduinoJson library will not be bound, the sketch size will also be reduced.
## Writing the custom Web pages without JSON
To handle a custom Web page without using JSON, follow the steps below.
1. Create or define [AutoConnectAux](apiaux.md) for each page.
2. Create or define [AutoConnectElement(s)](acelements.md).
3. Add [AutoConnectElement(s)](acelements.md) to AutoConnectAux.
4. Create more AutoConnectAux containing [AutoConnectElement(s)](acelements.md), if necessary.
5. Register the request handlers for the custom Web pages.
6. [Join](api.md#join) prepared AutoConnectAux(s) to AutoConnect.
7. Invoke [AutoConnect::begin()](api.md#begin).
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 [AutoConnect definitions](api.md#defined-macros). Its declaration is in **AutoConnectDefs.h** file.[^1]
[^1]:Detaching the ArduinoJson library reduces the sketch size by approximately 10K bytes.
```cpp
// Comment out the AUTOCONNECT_USE_JSON macro to detach the ArduinoJson.
#define AUTOCONNECT_USE_JSON
```
!!! caution "JSON processing will be disabled"
Commenting out the **AUTOCONNECT_USE_JSON** macro invalidates all functions related to JSON processing. If the sketch is using the JSON function, it will result in a compile error.
## Implementation example without ArduinoJson
The code excluding JSON processing from the mqttRSSI sketch attached to the library is as follows. <small>(It is a part of code. Refer to mqttRSSI_NA.ino for the whole sketch.)</small>
<i class="fa fa-code"></i> The JSON document for mqttRSSI
```json
[
{
"title": "MQTT Setting",
"uri": "/mqtt_setting",
"menu": true,
"element": [
{
"name": "header",
"type": "ACText",
"value": "<h2>MQTT broker settings</h2>",
"style": "text-align:center;color:#2f4f4f;padding:10px;"
},
{
"name": "caption",
"type": "ACText",
"value": "Publishing the WiFi signal strength to MQTT channel. RSSI value of ESP8266 to the channel created on ThingSpeak",
"style": "font-family:serif;color:#4682b4;"
},
{
"name": "mqttserver",
"type": "ACInput",
"value": "",
"label": "Server",
"pattern": "^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]*[a-zA-Z0-9])\\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\\-]*[A-Za-z0-9])$",
"placeholder": "MQTT broker server"
},
{
"name": "channelid",
"type": "ACInput",
"label": "Channel ID",
"pattern": "^[0-9]{6}$"
},
{
"name": "userkey",
"type": "ACInput",
"label": "User Key"
},
{
"name": "apikey",
"type": "ACInput",
"label": "API Key"
},
{
"name": "newline",
"type": "ACElement",
"value": "<hr>"
},
{
"name": "uniqueid",
"type": "ACCheckbox",
"value": "unique",
"label": "Use APID unique",
"checked": false
},
{
"name": "period",
"type": "ACRadio",
"value": [
"30 sec.",
"60 sec.",
"180 sec."
],
"label": "Update period",
"arrange": "vertical",
"checked": 1
},
{
"name": "newline",
"type": "ACElement",
"value": "<hr>"
},
{
"name": "hostname",
"type": "ACInput",
"value": "",
"label": "ESP host name",
"pattern": "^([a-zA-Z0-9]([a-zA-Z0-9-])*[a-zA-Z0-9]){1,32}$"
},
{
"name": "save",
"type": "ACSubmit",
"value": "Save&amp;Start",
"uri": "/mqtt_save"
},
{
"name": "discard",
"type": "ACSubmit",
"value": "Discard",
"uri": "/"
}
]
},
{
"title": "MQTT Setting",
"uri": "/mqtt_save",
"menu": false,
"element": [
{
"name": "caption",
"type": "ACText",
"value": "<h4>Parameters saved as:</h4>",
"style": "text-align:center;color:#2f4f4f;padding:10px;"
},
{
"name": "parameters",
"type": "ACText"
},
{
"name": "clear",
"type": "ACSubmit",
"value": "Clear channel",
"uri": "/mqtt_clear"
}
]
}
]
```
<span style="margin-right:6px;margin-top:2px;"><img align="middle" width="32" height="32" src="./images/arrow_down.png"></span><i class="fa fa-code"></i> Exclude the JSON and replace to the AutoConnectElements natively
```cpp
// In the declaration,
// Declare AutoConnectElements for the page asf /mqtt_setting
ACText(header, "<h2>MQTT broker settings</h2>", "text-align:center;color:#2f4f4f;padding:10px;");
ACText(caption, "Publishing the WiFi signal strength to MQTT channel. RSSI value of ESP8266 to the channel created on ThingSpeak", "font-family:serif;color:#4682b4;");
ACInput(mqttserver, "", "Server", "^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]*[a-zA-Z0-9])\\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\\-]*[A-Za-z0-9])$", "MQTT broker server");
ACInput(channelid, "", "Channel ID", "^[0-9]{6}$");
ACInput(userkey, "", "User Key");
ACInput(apikey, "", "API Key");
ACElement(newline, "<hr>");
ACCheckbox(uniqueid, "unique", "Use APID unique");
ACRadio(period, { "30 sec.", "60 sec.", "180 sec." }, "Update period", AC_Vertical, 1);
ACSubmit(save, "Start", "mqtt_save");
ACSubmit(discard, "Discard", "/");
// Declare the custom Web page as /mqtt_setting and contains the AutoConnectElements
AutoConnectAux mqtt_setting("/mqtt_setting", "MQTT Setting", true, {
header,
caption,
mqttserver,
channelid,
userkey,
apikey,
newline,
uniqueid,
period,
newline,
save,
discard
});
// Declare AutoConnectElements for the page as /mqtt_save
ACText(caption2, "<h4>Parameters available as:</h4>", "text-align:center;color:#2f4f4f;padding:10px;");
ACText(parameters);
ACSubmit(clear, "Clear channel", "/mqtt_clear");
// Declare the custom Web page as /mqtt_save and contains the AutoConnectElements
AutoConnectAux mqtt_save("/mqtt_save", "MQTT Setting", false, {
caption2,
parameters,
clear
});
// In the setup(),
// Join the custom Web pages and performs begin
portal.join({ mqtt_setting, mqtt_save });
portal.begin();
```
Loading…
Cancel
Save