From 62ae967e2d568cb4901b62dca6f664fd63f51530 Mon Sep 17 00:00:00 2001 From: Hieromon Ikasamo Date: Thu, 21 Feb 2019 23:13:45 +0900 Subject: [PATCH] Adds AutoConnectInput::isValid function --- examples/mqttRSSI/mqttRSSI.ino | 5 +++-- keywords.txt | 1 + src/AutoConnectElementBasis.h | 1 + src/AutoConnectElementBasisImpl.h | 24 ++++++++++++++++++++++++ 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/examples/mqttRSSI/mqttRSSI.ino b/examples/mqttRSSI/mqttRSSI.ino index 01cf4ff..7951f2a 100644 --- a/examples/mqttRSSI/mqttRSSI.ino +++ b/examples/mqttRSSI/mqttRSSI.ino @@ -292,8 +292,9 @@ String saveParams(AutoConnectAux& aux, PageArgument& args) { // Echo back saved parameters to AutoConnectAux page. AutoConnectText& echo = aux.getElement("parameters"); - echo.value = "Server: " + serverName + "
"; - echo.value += "Channel ID: " + channelId + "
"; + echo.value = "Server: " + serverName; + echo.value += mqttserver.isValid() ? String(" (OK)") : String(" (ERR)"); + echo.value += "
" + "Channel ID: " + channelId + "
"; echo.value += "User Key: " + userKey + "
"; echo.value += "API Key: " + apiKey + "
"; echo.value += "Update period: " + String(updateInterval / 1000) + " sec.
"; diff --git a/keywords.txt b/keywords.txt index b5be79d..f8103f9 100644 --- a/keywords.txt +++ b/keywords.txt @@ -30,6 +30,7 @@ handleClient KEYWORD2 handleRequest KEYWORD2 home KEYWORD2 host KEYWORD2 +isValid KEYWORD2 join KEYWORD2 load KEYWORD2 loadElement KEYWORD2 diff --git a/src/AutoConnectElementBasis.h b/src/AutoConnectElementBasis.h index 77e914e..589960f 100644 --- a/src/AutoConnectElementBasis.h +++ b/src/AutoConnectElementBasis.h @@ -105,6 +105,7 @@ class AutoConnectInputBasis : virtual public AutoConnectElementBasis { } virtual ~AutoConnectInputBasis() {} const String toHTML(void) const override; + bool isValid(void) const; String label; /**< A label for a subsequent input box */ String pattern; /**< Format pattern to aid validation of input value */ diff --git a/src/AutoConnectElementBasisImpl.h b/src/AutoConnectElementBasisImpl.h index 367f144..d891b96 100644 --- a/src/AutoConnectElementBasisImpl.h +++ b/src/AutoConnectElementBasisImpl.h @@ -11,6 +11,7 @@ #define _AUTOCONNECTELEMENTBASISIMPL_H_ #include "AutoConnectElementBasis.h" +#include /** * Generate an HTML