` tag. A `#!html style` attribute
###
Constructor
```cpp
-AutoConnectText(const char* name, const char* value, const char* style)
+AutoConnectText(const char* name, const char* value, const char* style, const char* format)
```
###
name
@@ -318,6 +343,10 @@ It becomes content and also can contain the native HTML code, but remember that
A `style` specifies the qualification style to give to the content and can use the style attribute format as it is.
+###
format
+
+A `format` is a pointer to a null-terminated multibyte string specifying how to interpret the value. It specifies the conversion format when outputting values. The format string conforms to C-style printf library functions, but depends on the espressif sdk implementation. The conversion specification is valid only in **%s** format. (Left and Right justification, width are also valid.)
+
## How to coding for the elements
###
Declaration for the elements in Sketches
@@ -332,6 +361,8 @@ ACButton ( *name*
\[ , *value*
\] \[ \[ , *value*
\] \[ , *label*
\] \[ , **true** | **false**
\] )
+ACFile ( *name*
\[ , *value*
\] \[ , *label*
\] \[ , **AC\_File\_FS** | **AC\_File\_SD** | **AC\_File\_Ext**
\] )
+
ACInput ( *name*
\[ , *value*
\] \[ , *label*
\] \[ , *pattern*
\] \[ , *placeholder*
\] )
ACRadio ( *name*
\[ , *values*
\] \[ , *label*
\] \[ , **AC\_Horizontal** | **AC\_Vertical**
\] \[ , *checked*
\] )
@@ -340,7 +371,7 @@ ACSelect ( *name*
\[ , *options*
\] \[\[ , *value*
\] \[ , *uri*
\] )
-ACText ( *name*
\[ , *value*
\] \[ , *style*
\] )
+ACText ( *name*
\[ , *value*
\] \[ , *style*
\] \[ , *format*
\] )
!!! memo "Declaration macro usage"
For example, *AutoConnectText* can be declared using macros.
diff --git a/mkdocs/achandling.md b/mkdocs/achandling.md
index 6c3a8eb..95200b2 100644
--- a/mkdocs/achandling.md
+++ b/mkdocs/achandling.md
@@ -77,7 +77,21 @@ T& AutoConenctAux::getElement
(const String& name)
AutoConnectElementVT* AutoConnectAux::getElements(void)
```
-The [**getElement**](apiaux.md#getelement) function returns an AutoConnectElement with the specified name as a key. When you use this function, you need to know the type of AutoConnectElement in advance. To retrieve an AutoConnectElement by specifying its type, use the following method.
+The [**getElement**](apiaux.md#getelement) function returns an AutoConnectElement with the specified name as a key. When you use this function, you need to know the type of AutoConnectElement in advance and specify its type to an argument of the getElement. A type of can be specified as follows.
+
+```cpp
+AutoConnectButton& AutoConnectAux::getElement(const String& name)
+AutoConnectCheckbox& AutoConnectAux::getElement(const String& name)
+AutoConnectElement& AutoConnectAux::getElement(const String& name)
+AutoConnectFile& AutoConnectAux::getElement(const String& name)
+AutoConnectInput& AutoConnectAux::getElement(const String& name)
+AutoConnectRadio& AutoConnectAux::getElement(const String& name)
+AutoConnectSelect& AutoConnectAux::getElement(const String& name)
+AutoConnectSubmit& AutoConnectAux::getElement(const String& name)
+AutoConnectText& AutoConnectAux::getElement(const String& name)
+```
+
+To retrieve an AutoConnectElement by specifying its type, use the following method.
```cpp
AutoConnectAux aux;
@@ -101,18 +115,29 @@ AutoConenctText& text = aux->getElement("caption"); // Cast to
Serial.println(text.value);
```
-You can also use the [operator **`[]`** of AutoConnectAux](apiaux.md#operator) as another way to get the desired element. An operator **`[]`** is a shortcut for [getElement](apiaux.me#getelement) function with the reference casting and makes simplify the code. Its argument is the name of the element to be acquired similarly to getElement function. For example, the following sketch code returns the same as reference of AutoConnectText element as `caption`.
+You can also use the [operator **`[]`** of AutoConnectAux](apiaux.md#operator) as another way to get the desired element. An operator **`[]`** is a shortcut for [getElement](apiaux.md#getelement) function with the reference casting and makes simplify the sketch code and treats like an array with the elements placed on a custom Web page. Its argument is the name of the element to be acquired similarly to getElement function. In the sketch, by combining the [**AutoConnectElement::as**](apielements.md#ast62) function with the operator `[]`, you can access the AutoConnectElements reference according to its actual type. For example, the following sketch code returns the same as a reference of AutoConnectText element as the `caption`.
```cpp hl_lines="4 5"
AutoConnect portal;
portal.load(auxJson);
AutoConnectAux& aux = *portal.aux("/page1");
AutoConnectText& text1 = aux.getElement("caption");
-AutoConnectText& text2 = (AutoConnectText&)aux["caption"];
+AutoConnectText& text2 = aux["caption"].as();
```
!!! note "Need cast to convert to the actual type"
- An operator `[]` returns a referene of an AutoConnectElement. It is necessary to convert the type according to the actual element type.
+ An operator `[]` returns a referene of an AutoConnectElement. It is necessary to convert the type according to the actual element type with [AutoConnectElement::as](apielements.md#ast62) functon.
+ ```cpp
+ AutoConnectButton& AutoConnectElement::as()
+ AutoConnectCheckbox& AutoConnectElement::as()
+ AutoConnectElement& AutoConnectElement::as()
+ AutoConnectFile& AutoConnectElement::as()
+ AutoConnectInput& AutoConnectElement::as()
+ AutoConnectRadio& AutoConnectElement::as()
+ AutoConnectSelect& AutoConnectElement::as()
+ AutoConnectSubmit& AutoConnectElement::as()
+ AutoConnectText& AutoConnectElement::as()
+ ```
To get all the AutoConnectElements in an AutoConnectAux object use the [**getElements**](apiaux.md#getelements) function. This function returns the vector of the reference wrapper as **AutoConnectElementVT** to all AutoConnectElements registered in the AutoConnectAux.
diff --git a/mkdocs/acjson.md b/mkdocs/acjson.md
index 786ddc0..611a872 100644
--- a/mkdocs/acjson.md
+++ b/mkdocs/acjson.md
@@ -120,6 +120,7 @@ JSON description for AutoConnectElements describes as an array in the *element*
: - AutoConnectButton: [**ACButton**](#acbutton)
: - AutoConnectCheckbox: [**ACCheckbox** ](#accheckbox)
: - AutoConnectElement: [**ACElement**](#acelement)
+: - AutoConnectFile: [**ACFile**](#acfile)
: - AutoConnectInput: [**ACInput**](#acinput)
: - AutoConnectRadio: [**ACRadio**](#acradio)
: - AutoConnectSelect: [**ACSelect**](#acselect)
@@ -142,6 +143,8 @@ This is different for each AutoConnectElements, and the key that can be specifie
#### ACElement
: - **value** : Specifies the source code of generating HTML. The value is native HTML code and is output as HTML as it is.
+#### ACFile
+
#### ACInput
: - **value** : Specifies the initial text string of the input box. If this value is omitted, placeholder is displayed as the initial string.
: - **label** : Specifies a label of the input box. Its placement is always to the left of the input box.
diff --git a/mkdocs/apiaux.md b/mkdocs/apiaux.md
index bc30842..04d8bf9 100644
--- a/mkdocs/apiaux.md
+++ b/mkdocs/apiaux.md
@@ -53,7 +53,7 @@ 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.
**Parameters**
- T 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).
+ T Actual type name of AutoConnectElements as [AutoConnectButton](apielements.md#autoconnectbutton), [AutoConnectCheckbox](apielements.md#autoconnectcheckbox), [AutoConnectElement](apielements.md#autoconnectelement), [AutoConnectFile](apielements.md#autoconnectfile), [AutoConnectInput](apielements.md#autoconnectinput), [AutoConnectRadio](apielements.md#autoconnectradio), [AutoConnectSelect](apielements.md#autoconnectselect), [AutoConnectSubmit](apielements.md#autoconnectsubmit), [AutoConnectText](apielements.md#autoconnecttext).
name Name of the AutoConnectElements to be retrieved.
**Return value** A reference of the AutoConnectElements. If a type is not specified returns a pointer.
@@ -182,6 +182,17 @@ Register the handler function of the AutoConnectAux.
Called even before generating HTML and after generated.
+### onUpload
+
+```cpp
+void onUpload(PageBuilder::UploadFuncT uploadFunc)
+```
+Register the upload handler of the AutoConnectAux.
+
+ **Parameters**
+ uploadFunc A function that behaves when request to upload with the AutoConnectAux page. UploadFuncT type is defined by the following declaration.`void(const String&, const HTTPUpload&)`
+
+
### release
```cpp
diff --git a/mkdocs/apielements.md b/mkdocs/apielements.md
index 40074ca..a5ddb50 100644
--- a/mkdocs/apielements.md
+++ b/mkdocs/apielements.md
@@ -159,6 +159,103 @@ Returns type of AutoConnectElement.
AC_Element
+#### as
+
+```cpp
+AutoConnectElement& as(void)
+```
+Casts the reference to the AutoConnectElement the specified type.
+
+ **Parameters**
+ T The element type. AutoConnectElements type such as [AutoConnectButton](apielements.md#autoconnectbutton), [AutoConnectCheckbox](apielements.md#autoconnectcheckbox), [AutoConnectFile](apielements.md#autoconnectfile), [AutoConnectInput](apielements.md#autoconnectinput), [AutoConnectRadio](apielements.md#autoconnectradio), [AutoConnectSelect](apielements.md#autoconnectselect), [AutoConnectSubmit](apielements.md#autoconnectsubmit), [AutoConnectText](apielements.md#autoconnecttext).
+ **Return value**
+ A reference to the AutoConnectElement with actual type.
+
+
+## AutoConnectFile
+
+### Constructor
+
+```cpp
+AutoConnectFile(const char* name = "", const char* value = "", const char* label = "", const ACFile_t store = AC_File_FS)
+```
+
+ **Parameters**
+ name The element name.
+ value File name to be upload.
+ label Label string.
+ store The **ACFile_t** enumerator that represents the media to save the uploaded file.
+
+
+
+### Public member variables
+
+#### name
+
+The element name.
+
+ **Type**
+ String
+
+
+#### value
+
+File name to be upload. This attribute is read only.
+
+ **Type**
+ String
+
+
+#### label
+
+A label is an optional string. A label is always arranged on the left side of the file input box. Specification of a label will generate an HTML `#!html ` tag with an id attribute. The file input box and the label are connected by the id attribute.
+
+ **Type**
+ String
+
+
+#### store
+
+Specifies the save destination of the uploaded file. You can use the built-in uploader to save uploaded file to the flash of the ESP8266/ESP32 module or external SD media without writing a dedicated sketch code. It also supports saving to any destination using a custom uploader that inherits from the AutoConnectUploadHandler class.
+
+ **Type**
+ ACFile_t
+
+- **`AC_File_FS`** : Save the uploaded file to SPIFFS in the flash.
+- **`AC_File_SD`** : Save the uploaded file to SD.
+- **`AC_File_Ext`** : Save the file using your own upload handler.
+
+
+
+#### mimeType
+
+The mime type of the upload file which included as Media type in the http post request. Set by the client (usually the browser) that requested the upload. It is determined by the file type as `application/octet-stream`, `text` etc. which is described in [IANA Media Type](https://www.iana.org/assignments/media-types/media-types.xhtml).
+
+ **Type**
+ String
+
+
+#### size
+
+Size of the uploading file.
+
+ **Type**
+ size_t
+
+
+### Public member functions
+
+#### typeOf
+
+```cpp
+ACElement_t typeOf(void)
+```
+Returns type of AutoConnectFile.
+
+ **Return value**
+ AC_File
+
+
## AutoConnectInput
### Constructor
diff --git a/mkdocs/index.md b/mkdocs/index.md
index 257bf62..a9d4dbc 100644
--- a/mkdocs/index.md
+++ b/mkdocs/index.md
@@ -85,19 +85,16 @@ Install third-party platform using the *Boards Manager* of Arduino IDE. You can
Additional library (Required)
The [PageBuilder](https://github.com/Hieromon/PageBuilder) library to build HTML for ESP8266WebServer is needed.
-To install the PageBuilder library into your Arduino IDE, you can use the *Library Manager*. Select the board of ESP8266 series in the Arduino IDE, open the library manager and search keyword '**PageBuilder**' with the topic '**Communication**', then you can see the *PageBuilder*. The latest version is required **1.3.2** **later**.[^1]
+To install the PageBuilder library into your Arduino IDE, you can use the *Library Manager*. Select the board of ESP8266 series in the Arduino IDE, open the library manager and search keyword '**PageBuilder**' with the topic '**Communication**', then you can see the *PageBuilder*. The latest version is required **1.3.3** **later**.[^1]
[^1]:Since AutoConnect v0.9.8, PageBuilder v1.3.3 later is required.
Additional library (Optional)
-By adding the [ArduinoJson](https://github.com/bblanchon/ArduinoJson) library, AutoConnect will be able to handle the [**custom Web pages**](acintro.md) described with JSON. With AutoConnect v0.9.7 you can insert user-owned web pages that can consist of representative HTML elements as styled TEXT, INPUT, BUTTON, CHECKBOX, SELECT, SUBMIT and invoke them from the AutoConnect menu. These HTML elements can be added by sketches using the AutoConnect API. Further it possible importing the custom Web pages declarations described with JSON which stored in PROGMEM, SPIFFS, or SD. [ArduinoJson version 5](https://arduinojson.org/v5/doc/) is required to use this feature.[^2]
+By adding the [ArduinoJson](https://github.com/bblanchon/ArduinoJson) library, AutoConnect will be able to handle the [**custom Web pages**](acintro.md) described with JSON. With AutoConnect v0.9.7 you can insert user-owned web pages that can consist of representative HTML elements as styled TEXT, INPUT, BUTTON, CHECKBOX, SELECT, SUBMIT and invoke them from the AutoConnect menu. These HTML elements can be added by sketches using the AutoConnect API. Further it possible importing the custom Web pages declarations described with JSON which stored in PROGMEM, SPIFFS, or SD. [ArduinoJson](https://arduinojson.org/) is required to use this feature.[^2] AutoConnect can work with ArduinoJson both [version 5](https://arduinojson.org/v5/doc/) and [version 6](https://arduinojson.org/v6/doc/).
[^2]:Using the AutoConnect API natively allows you to sketch custom Web pages without JSON.
-!!! info "AutoConnect supports ArduinoJson version 5 only"
- ArduinoJson version 6 is just released, Arduino Library Manager installs the ArduinoJson version 6 by default. Open the Arduino Library Manager and make sure that ArduinoJson version 5 is installed.
-
### Install the AutoConnect
Clone or download from the [AutoConnect GitHub repository](https://github.com/Hieromon/AutoConnect).
diff --git a/mkdocs/lsbegin.md b/mkdocs/lsbegin.md
index 7212b7f..0c63726 100644
--- a/mkdocs/lsbegin.md
+++ b/mkdocs/lsbegin.md
@@ -1,6 +1,6 @@
## AutoConnect::begin logic sequence
-Several parameters as follows of [AutoConnectConfig](apiconfig.md) affect the behavior of [AutoConnect::begin](api.md#begin) function. Each parameter affects the behaves in interacted order with the priority and apply to the logic sequence of AutoConnect::begin.
+Several parameters as follows of [AutoConnectConfig](apiconfig.md) affect the behavior of [AutoConnect::begin](api.md#begin) function. Each parameter affects the behaves in interacted order with the priority and apply to the logic sequence of [AutoConnect::begin](api.md#begin).
- [immediateStart](apiconfig.md#immediatestart) : The captive portal start immediately, without first WiFi.begin.
- [autoReconenct](apiconfig.md#autoreconnect) : Attempt re-connect with past SSID by saved credential.
@@ -11,14 +11,13 @@ You can use these parameters in combination with sketch requirements and need to
-For example, AutoConnect::begin will not exits without the **portalTimeout** while the connection not establishes, but WebServer will start to work. A DNS server that detects the probe of the captive portal is also effective. So, your sketch may work seemingly, but it will close with inside a loop of the AutoConnect::begin function. Especially when invoking AutoConnect::begin in the **setup()**, execution control does not pass to the **loop()**.
+For example, [AutoConnect::begin](api.md#begin) will not exits without the [**portalTimeout**](apiconfig.md#portaltimeout) while the connection not establishes, but WebServer will start to work. A DNS server that detects the probe of the captive portal is also effective. So, your sketch may work seemingly, but it will close with inside a loop of the [AutoConnect::begin](api.md#begin) function. Especially when invoking [AutoConnect::begin](api.md#begin) in the **setup()**, execution control does not pass to the **loop()**.
-As different scenes, you may use the **immediateStart** effectively. Equipped the external switch to activate the captive portal with the ESP module, combined with the **portalTime** and the **retainPortal** it will become WiFi active connection feature. You can start AutoConnect::begin at any point in the **loop()**, which allows your sketch can behave both the offline mode and the online mode.
+As different scenes, you may use the [**immediateStart**](apiconfig.md#immediatestart) effectively. Equipped the external switch to activate the captive portal with the ESP module, combined with the [**portalTime**](apiconfig.md#portaltimeout) and the [**retainPortal**](apiconfig.md#retainportal) it will become WiFi active connection feature. You can start [AutoConnect::begin](api.md#begin) at any point in the **loop()**, which allows your sketch can behave both the offline mode and the online mode.
-The **retainPortal** option allows the DNS server to continue operation after exiting from AutoConnect::begin. AutoConnect traps captive portal detection from the client and redirects it to the AutoConnect menu. That trap will answer all unresolved addresses with SoftAP's IP address. If the URI handler for the source request is undefined, it returns a 302 response with `SoftAPIP/_ac` to the client. This is the mechanism of AutoConnect's captive portal. Captive portal probes will frequently occur while you are attempting on the client device's WiFi connection Apps and these implementations are varied each OS, so it not realistic to identify all probing URIs. Therefore, while retainPortal is enabled, it is not preferable to executing the sketch under the WiFi connection Apps on the client device. (Probably not work correctly) You need to exit from the WiFi connection Apps once.
+The [**retainPortal**](apiconfig.md#retainportal) option allows the DNS server to continue operation after exiting from [AutoConnect::begin](api.md#begin). AutoConnect traps captive portal detection from the client and redirects it to the AutoConnect menu. That trap will answer all unresolved addresses with SoftAP's IP address. If the URI handler for the source request is undefined, it returns a 302 response with `SoftAPIP/_ac` to the client. This is the mechanism of AutoConnect's captive portal. Captive portal probes will frequently occur while you are attempting on the client device's WiFi connection Apps and these implementations are varied each OS, so it not realistic to identify all probing URIs. Therefore, while retainPortal is enabled, it is not preferable to executing the sketch under the WiFi connection Apps on the client device. (Probably not work correctly) You need to exit from the WiFi connection Apps once.
Please consider these kinds of influence when you make sketches.
!!! info "The AutoConnect::begin 3rd parameter"
Another parameter as the [3rd parameter](api.md#begin) of AutoConnect::begin related to timeout constrains the connection wait time after WiFi.begin. It is the **CONNECTED** judgment of the above chart that it has an effect.
-