From a2c1acc83aeb4ffef691800d573523b315c1ea94 Mon Sep 17 00:00:00 2001 From: Hieromon Ikasamo Date: Thu, 28 Mar 2019 13:37:04 +0900 Subject: [PATCH] Resotre page transfer mode. Issue #51 --- examples/FileUpload/FileUpload.ino | 3 ++- mkdocs/achandling.md | 8 ++++++++ mkdocs/acjson.md | 2 +- src/AutoConnectDefs.h | 3 +-- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/examples/FileUpload/FileUpload.ino b/examples/FileUpload/FileUpload.ino index 6bc4c48..8552a41 100644 --- a/examples/FileUpload/FileUpload.ino +++ b/examples/FileUpload/FileUpload.ino @@ -115,7 +115,8 @@ String postUpload(AutoConnectAux& aux, PageArgument& args) { String content; // Explicitly cast to the desired element to correctly extract // the element using the operator []. - AutoConnectFile& filename = (AutoConnectFile&)auxUpload["filename"]; +// AutoConnectAux& root_page = *portal.aux("/"); + AutoConnectFile& filename = static_cast(auxUpload["filename"]); AutoConnectText& aux_filename = (AutoConnectText&)aux["filename"]; AutoConnectText& aux_size = (AutoConnectText&)aux["size"]; AutoConnectText& aux_contentType = (AutoConnectText&)aux["content_type"]; diff --git a/mkdocs/achandling.md b/mkdocs/achandling.md index 112bbd9..a8bda6a 100644 --- a/mkdocs/achandling.md +++ b/mkdocs/achandling.md @@ -101,6 +101,14 @@ AutoConenctText& text = aux->getElement("caption"); // Cast to Serial.println(text.value); ``` +You can also use the 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`. + +```cpp +AutoConnectAux& aux = *portal.aux("/page1"); +AutoConnectText& text1 = aux.getElement("caption"); +AutoConnectText& text2 = (AutoConnectText&)aux["caption"]; +``` + 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. ```cpp diff --git a/mkdocs/acjson.md b/mkdocs/acjson.md index 6ae3554..786ddc0 100644 --- a/mkdocs/acjson.md +++ b/mkdocs/acjson.md @@ -169,7 +169,7 @@ This is different for each AutoConnectElements, and the key that can be specifie : - **style** : Specifies the qualification style to give to the content and can use the style attribute format as it is. !!! caution "AutoConnect's JSON parsing process is not perfect" - It is based on ArduinoJson, but the process is simplified to save memory. As a result, even if there is an unnecessary key, it will not be an error. It is ignored. + It is based on analysis by ArduinoJson, but the semantic analysis is simplified to save memory. Consequently, it is not an error that a custom Web page JSON document to have unnecessary keys. It will be ignored. ## Loading JSON document diff --git a/src/AutoConnectDefs.h b/src/AutoConnectDefs.h index bc27efb..57baad2 100644 --- a/src/AutoConnectDefs.h +++ b/src/AutoConnectDefs.h @@ -119,8 +119,7 @@ // http response transfer method #ifndef AUTOCONNECT_HTTP_TRANSFER -//#define AUTOCONNECT_HTTP_TRANSFER PB_ByteStream // Change for Issue #51 -#define AUTOCONNECT_HTTP_TRANSFER PB_Chunk +#define AUTOCONNECT_HTTP_TRANSFER PB_ByteStream #endif // !AUTOCONNECT_HTTP_TRANSFER // Reserved buffer size to build content