From 00d4b1715522da5c37fe3451b5a16082b713fe9d Mon Sep 17 00:00:00 2001 From: Hieromon Ikasamo Date: Fri, 25 Jan 2019 17:58:18 +0900 Subject: [PATCH] Adds AutoConnect::where function --- keywords.txt | 1 + src/AutoConnect.cpp | 7 ++++--- src/AutoConnect.h | 4 +++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/keywords.txt b/keywords.txt index 6d7d59e..b5be79d 100644 --- a/keywords.txt +++ b/keywords.txt @@ -46,6 +46,7 @@ setTitle KEYWORD2 toHTML KEYWORD2 typeOf KEYWORD2 value KEYWORD2 +where KEYWORD2 ####################################### # Literals (KEYWORD3) diff --git a/src/AutoConnect.cpp b/src/AutoConnect.cpp index de76fda..570a017 100644 --- a/src/AutoConnect.cpp +++ b/src/AutoConnect.cpp @@ -58,6 +58,7 @@ void AutoConnect::_initialize() { _disconnectEventId = -1; // The member available for ESP32 only #endif _aux.release(); + _auxUri = String(""); } /** @@ -781,11 +782,11 @@ bool AutoConnect::_classifyHandle(HTTPMethod method, String uri) { // the form data of the AutoConnectAux page and with this timing save // the value of each element. if (_webServer->hasArg(AUTOCONNECT_AUXURI_PARAM)) { - String auxUri = _webServer->arg(AUTOCONNECT_AUXURI_PARAM); - auxUri.replace("/", "/"); + _auxUri = _webServer->arg(AUTOCONNECT_AUXURI_PARAM); + _auxUri.replace("/", "/"); AutoConnectAux* aux = _aux.get(); while (aux) { - if (aux->_uriStr == auxUri) { + if (aux->_uriStr == _auxUri) { aux->_storeElements(_webServer.get()); break; } diff --git a/src/AutoConnect.h b/src/AutoConnect.h index a54b81f..35af7f0 100644 --- a/src/AutoConnect.h +++ b/src/AutoConnect.h @@ -181,6 +181,7 @@ class AutoConnect { void join(AutoConnectAux& aux); void join(AutoConnectAuxVT auxVector); bool on(const String& uri, const AuxHandlerFunctionT handler, AutoConnectExitOrder_t order = AC_EXIT_AHEAD); + AutoConnectAux* where(void) const { return aux(_auxUri); } /** For AutoConnectAux described in JSON */ #ifdef AUTOCONNECT_USE_JSON @@ -255,6 +256,7 @@ class AutoConnect { /** Extended pages made up with AutoConnectAux */ std::unique_ptr _aux; + String _auxUri; /**< Last accessed AutoConnectAux */ /** Saved configurations */ AutoConnectConfig _apConfig; @@ -273,9 +275,9 @@ class AutoConnect { #endif /** HTTP header information of the currently requested page. */ + IPAddress _currentHostIP; /**< host IP address */ String _uri; /**< Requested URI */ String _redirectURI; /**< Redirect destination */ - IPAddress _currentHostIP; /**< host IP address */ String _menuTitle; /**< Title string of the page */ /** PegeElements of AutoConnect site. */