From 1bb0975d89ceab759ed39f634205ab65e77674f2 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Tue, 4 May 2021 16:35:21 +0200 Subject: [PATCH] Refactor Gui Save Settings to unlimited (heap) parameter size --- tasmota/xdrv_01_webserver.ino | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/tasmota/xdrv_01_webserver.ino b/tasmota/xdrv_01_webserver.ino index d45e97fe9..066ba4773 100644 --- a/tasmota/xdrv_01_webserver.ino +++ b/tasmota/xdrv_01_webserver.ino @@ -421,6 +421,7 @@ static void WebGetArg(const char* arg, char* out, size_t max) } String AddWebCommand(const char* command, const char* arg, const char* dflt) { +/* // OK but fixed max argument char param[200]; // Allow parameter with lenght up to 199 characters WebGetArg(arg, param, sizeof(param)); @@ -428,7 +429,7 @@ String AddWebCommand(const char* command, const char* arg, const char* dflt) { char cmnd[232]; snprintf_P(cmnd, sizeof(cmnd), PSTR(";%s %s"), command, (0 == len) ? dflt : (StrCaseStr_P(command, PSTR("Password")) && (len < 5)) ? "" : param); return String(cmnd); - +*/ /* // Any argument size (within stack space) +48 bytes String param = Webserver->arg((const __FlashStringHelper *)arg); @@ -438,21 +439,30 @@ String AddWebCommand(const char* command, const char* arg, const char* dflt) { snprintf_P(cmnd, sizeof(cmnd), PSTR(";%s %s"), command, (0 == len) ? dflt : (StrCaseStr_P(command, PSTR("Password")) && (len < 5)) ? "" : param.c_str()); return String(cmnd); */ -/* - // Exception (3) +24 bytes + // Any argument size (within heap space) +24 bytes + // Exception (3) if not first moved from flash to stack + // Exception (3) if not using __FlashStringHelper + // Exception (3) if not FPSTR() +// char rcommand[strlen_P(command) +1]; +// snprintf_P(rcommand, sizeof(rcommand), command); +// char rdflt[strlen_P(dflt) +1]; +// snprintf_P(rdflt, sizeof(rdflt), dflt); String result = F(";"); - result += command; +// result += rcommand; +// result += (const __FlashStringHelper *)command; + result += FPSTR(command); result += F(" "); - String param = Webserver->arg((const __FlashStringHelper *)arg); + String param = Webserver->arg(FPSTR(arg)); uint32_t len = param.length(); if (0 == len) { - result += dflt; +// result += rdflt; +// result += (const __FlashStringHelper *)dflt; + result += FPSTR(dflt); } else if (!(StrCaseStr_P(command, PSTR("Password")) && (len < 5))) { result += param; } return result; -*/ } static bool WifiIsInManagerMode(){