diff --git a/src/AutoConnect.h b/src/AutoConnect.h index b1e98b4..f94ea6e 100644 --- a/src/AutoConnect.h +++ b/src/AutoConnect.h @@ -189,8 +189,9 @@ class AutoConnect { /** For AutoConnectAux described in JSON */ #ifdef AUTOCONNECT_USE_JSON - bool load(const String& aux); + bool load(PGM_P aux); bool load(const __FlashStringHelper* aux); + bool load(const String& aux); bool load(Stream& aux); #endif // !AUTOCONNECT_USE_JSON diff --git a/src/AutoConnectAux.cpp b/src/AutoConnectAux.cpp index 691d5d4..f62326e 100644 --- a/src/AutoConnectAux.cpp +++ b/src/AutoConnectAux.cpp @@ -495,14 +495,14 @@ void AutoConnectAux::_storeElements(WebServerClass* webServer) { #ifdef AUTOCONNECT_USE_JSON /** - * Load AutoConnectAux page from JSON description stored in the sketch. + * Load AutoConnectAux page from JSON description stored in PROGMEM. * This function can load AutoConnectAux for multiple AUX pages written * in JSON and is registered in AutoConnect. * @param aux JSON description to be load. * @return true Successfully loaded. */ -bool AutoConnect::load(const String& aux) { - return _parseJson(aux); +bool AutoConnect::load(PGM_P aux) { + return _parseJson(reinterpret_cast(aux)); } /** @@ -516,6 +516,17 @@ bool AutoConnect::load(const __FlashStringHelper* aux) { return _parseJson(aux); } +/** + * Load AutoConnectAux page from JSON description stored in the sketch. + * This function can load AutoConnectAux for multiple AUX pages written + * in JSON and is registered in AutoConnect. + * @param aux JSON description to be load. + * @return true Successfully loaded. + */ +bool AutoConnect::load(const String& aux) { + return _parseJson(aux); +} + /** * Load AutoConnectAux page from JSON description from the stream. * This function can load AutoConnectAux for multiple AUX pages written @@ -622,6 +633,18 @@ bool AutoConnectAux::load(const String& in) { return _parseJson(in); } +/** + * Constructs an AutoConnectAux instance by reading all the + * AutoConnectElements of the specified URI from the elements passing + * pointer to JSON stored in pgm_data array. + * @param in AutoConnectAux element data which is described by JSON. + * @return true The element collection successfully loaded. + * @return false Invalid JSON data occurred. + */ +bool AutoConnectAux::load(PGM_P in) { + return _parseJson(reinterpret_cast(in)); +} + /** * Constructs an AutoConnectAux instance by reading all the * AutoConnectElements of the specified URI from the elements defined @@ -672,26 +695,33 @@ bool AutoConnectAux::_load(JsonObject& jb) { * elements are to be loaded. * @return A reference of loaded AutoConnectElement instance. */ -bool AutoConnectAux::loadElement(const String& in, const String& name) { - return _parseElement(in, name); +bool AutoConnectAux::loadElement(PGM_P in, const String& name) { + return _parseElement(reinterpret_cast(in), name); } bool AutoConnectAux::loadElement(const __FlashStringHelper* in, const String& name) { return _parseElement(in, name); } +bool AutoConnectAux::loadElement(const String& in, const String& name) { + return _parseElement(in, name); +} bool AutoConnectAux::loadElement(Stream& in, const String& name) { return _parseElement(in, name); } -bool AutoConnectAux::loadElement(const String& in, std::vector const& names) { - return _parseElement const&>(in, names); +bool AutoConnectAux::loadElement(PGM_P in, std::vector const& names) { + return _parseElement const&>(reinterpret_cast(in), names); } bool AutoConnectAux::loadElement(const __FlashStringHelper* in, std::vector const& names) { return _parseElement const&>(in, names); } +bool AutoConnectAux::loadElement(const String& in, std::vector const& names) { + return _parseElement const&>(in, names); +} + bool AutoConnectAux::loadElement(Stream& in, std::vector const& names) { return _parseElement const&>(in, names); } diff --git a/src/AutoConnectAux.h b/src/AutoConnectAux.h index 7bd2b02..284e36a 100644 --- a/src/AutoConnectAux.h +++ b/src/AutoConnectAux.h @@ -71,13 +71,16 @@ class AutoConnectAux : public PageBuilder { } #ifdef AUTOCONNECT_USE_JSON - bool load(const String& in); /**< Load whole elements to AutoConnectAux Page */ + bool load(PGM_P in); /**< Load whole elements to AutoConnectAux Page */ bool load(const __FlashStringHelper* in); /**< Load whole elements to AutoConnectAux Page */ + bool load(const String& in); /**< Load whole elements to AutoConnectAux Page */ bool load(Stream& in); /**< Load whole elements to AutoConnectAux Page */ - bool loadElement(const String& in, const String& name = String("")); /**< Load specified element */ - bool loadElement(const String& in, std::vector const& names);/**< Load any specified elements */ + bool loadElement(PGM_P in, const String& name = String("")); /**< Load specified element */ + bool loadElement(PGM_P in, std::vector const& names); /**< Load any specified elements */ bool loadElement(const __FlashStringHelper* in, const String& name = String("")); /**< Load specified element */ bool loadElement(const __FlashStringHelper* in, std::vector const& names); /**< Load any specified elements */ + bool loadElement(const String& in, const String& name = String("")); /**< Load specified element */ + bool loadElement(const String& in, std::vector const& names);/**< Load any specified elements */ bool loadElement(Stream& in, const String& name = String("")); /**< Load specified element */ bool loadElement(Stream& in, std::vector const& names); /**< Load any specified elements */ size_t saveElement(Stream& out, std::vector const& names = {}); /**< Write elements of AutoConnectAux to the stream */