From 76f9ebfb72b47dbf72bedc9d9bf986811da88fa4 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Sat, 25 Apr 2020 15:34:18 +0200 Subject: [PATCH] Attempt to fix ESP32 gui page load error Attempt to fix ESP32 gui Configure Template page load error by switching large content from Ajax loading parameters to included parameters. --- tasmota/xdrv_01_webserver.ino | 80 +++++++++++++++-------------------- 1 file changed, 34 insertions(+), 46 deletions(-) diff --git a/tasmota/xdrv_01_webserver.ino b/tasmota/xdrv_01_webserver.ino index 6c01e6dc5..61f98e649 100644 --- a/tasmota/xdrv_01_webserver.ino +++ b/tasmota/xdrv_01_webserver.ino @@ -257,9 +257,10 @@ const char HTTP_SCRIPT_TEMPLATE[] PROGMEM = "if(eb('s1').value==''){" "eb('s1').value=k;" // Set NAME if not yet set "}" - "os=o.shift();" // Complete GPIO sensor list - "as=o.shift();" // Complete ADC0 list - "g=o.shift().split(',');" // Array separator + "g=o.shift().split(',');" // GPIO - Array separator + "os=\""; // }2'0'>None (0)}3}2'17'>Button1 (17)}3... +const char HTTP_SCRIPT_TEMPLATE2[] PROGMEM = + "\";" "j=0;" "for(i=0;i<" STR(MAX_USER_PINS) ";i++){" // Supports 13 GPIOs "if(6==i){j=9;}" @@ -268,7 +269,9 @@ const char HTTP_SCRIPT_TEMPLATE[] PROGMEM = "j++;" "}" "g=o.shift();" // FLAG - "os=as;" + "os=\""; // }2'0'>None (0)}3}2'17'>Analog (17)}3... +const char HTTP_SCRIPT_TEMPLATE3[] PROGMEM = + "\";" "sk(g&15," STR(ADC0_PIN) ");" // Set ADC0 "g>>=4;" "for(i=0;i<" STR(GPIO_FLAG_USED) ";i++){" @@ -286,20 +289,13 @@ const char HTTP_SCRIPT_TEMPLATE[] PROGMEM = "ld(a,x1);" // ?t related to WebGetArg("t", stemp, sizeof(stemp)); "}" - "function x2(a){" - "os=a.responseText;" + "function sl(){" + "os=\""; // }2'0'>Sonoff Basic (1)}3... +const char HTTP_SCRIPT_TEMPLATE4[] PROGMEM = + "\";" "sk(" STR(WEMOS_MODULE) ",99);" // 17 = WEMOS "st(" STR(USER_MODULE) ");" "}" - -#ifdef USE_JAVASCRIPT_ES6 - "sl=()=>ld('tp?m=1',x2);" // ?m related to Webserver->hasArg("m") -#else - "function sl(){" - "ld('tp?m=1',x2);" // ?m related to Webserver->hasArg("m") - "}" -#endif - "wl(sl);"; const char HTTP_SCRIPT_INFO_BEGIN[] PROGMEM = @@ -1405,16 +1401,6 @@ void HandleTemplateConfiguration(void) char stemp[30]; // Template number and Sensor name - if (Webserver->hasArg("m")) { - WSContentBegin(200, CT_PLAIN); - for (uint32_t i = 0; i < sizeof(kModuleNiceList); i++) { // "}2'%d'>%s (%d)}3" - "}2'0'>Sonoff Basic (1)}3" - uint32_t midx = pgm_read_byte(kModuleNiceList + i); - WSContentSend_P(HTTP_MODULE_TEMPLATE_REPLACE, midx, AnyModuleName(midx).c_str(), midx +1); - } - WSContentEnd(); - return; - } - WebGetArg("t", stemp, sizeof(stemp)); // 0 - 69 Template number if (strlen(stemp)) { uint32_t module = atoi(stemp); @@ -1427,27 +1413,7 @@ void HandleTemplateConfiguration(void) WSContentBegin(200, CT_PLAIN); WSContentSend_P(PSTR("%s}1"), AnyModuleName(module).c_str()); // NAME: Generic - - - for (uint32_t i = 0; i < sizeof(kGpioNiceList); i++) { // GPIO: }2'0'>None (0)}3}2'17'>Button1 (17)}3... - if (1 == i) { - WSContentSend_P(HTTP_MODULE_TEMPLATE_REPLACE, 255, D_SENSOR_USER, 255); // }2'255'>User (255)}3 - } - uint32_t midx = pgm_read_byte(kGpioNiceList + i); - WSContentSend_P(HTTP_MODULE_TEMPLATE_REPLACE, midx, GetTextIndexed(stemp, sizeof(stemp), midx, kSensorNames), midx); - } - WSContentSend_P(PSTR("}1")); // Field separator - - - for (uint32_t i = 0; i < ADC0_END; i++) { // FLAG: }2'0'>None (0)}3}2'17'>Analog (17)}3... - if (1 == i) { - WSContentSend_P(HTTP_MODULE_TEMPLATE_REPLACE, ADC0_USER, D_SENSOR_USER, ADC0_USER); // }2'15'>User (15)}3 - } - WSContentSend_P(HTTP_MODULE_TEMPLATE_REPLACE, i, GetTextIndexed(stemp, sizeof(stemp), i, kAdc0Names), i); - } - WSContentSend_P(PSTR("}1")); // Field separator - - for (uint32_t i = 0; i < ARRAY_SIZE(cmodule.io); i++) { // 17,148,29,149,7,255,255,255,138,255,139,255,255 + for (uint32_t i = 0; i < ARRAY_SIZE(cmodule.io); i++) { // 17,148,29,149,7,255,255,255,138,255,139,255,255 if (!FlashPin(i)) { WSContentSend_P(PSTR("%s%d"), (i>0)?",":"", cmodule.io[i]); } @@ -1461,7 +1427,29 @@ void HandleTemplateConfiguration(void) WSContentStart_P(S_CONFIGURE_TEMPLATE); WSContentSend_P(HTTP_SCRIPT_MODULE_TEMPLATE); + WSContentSend_P(HTTP_SCRIPT_TEMPLATE); + for (uint32_t i = 0; i < sizeof(kGpioNiceList); i++) { // GPIO: }2'0'>None (0)}3}2'17'>Button1 (17)}3... + if (1 == i) { + WSContentSend_P(HTTP_MODULE_TEMPLATE_REPLACE, GPIO_USER, D_SENSOR_USER, GPIO_USER); // }2'255'>User (255)}3 + } + uint32_t midx = pgm_read_byte(kGpioNiceList + i); + WSContentSend_P(HTTP_MODULE_TEMPLATE_REPLACE, midx, GetTextIndexed(stemp, sizeof(stemp), midx, kSensorNames), midx); + } + WSContentSend_P(HTTP_SCRIPT_TEMPLATE2); + for (uint32_t i = 0; i < ADC0_END; i++) { // FLAG: }2'0'>None (0)}3}2'17'>Analog (17)}3... + if (1 == i) { + WSContentSend_P(HTTP_MODULE_TEMPLATE_REPLACE, ADC0_USER, D_SENSOR_USER, ADC0_USER); // }2'15'>User (15)}3 + } + WSContentSend_P(HTTP_MODULE_TEMPLATE_REPLACE, i, GetTextIndexed(stemp, sizeof(stemp), i, kAdc0Names), i); + } + WSContentSend_P(HTTP_SCRIPT_TEMPLATE3); + for (uint32_t i = 0; i < sizeof(kModuleNiceList); i++) { // "}2'%d'>%s (%d)}3" - "}2'0'>Sonoff Basic (1)}3" + uint32_t midx = pgm_read_byte(kModuleNiceList + i); + WSContentSend_P(HTTP_MODULE_TEMPLATE_REPLACE, midx, AnyModuleName(midx).c_str(), midx +1); + } + WSContentSend_P(HTTP_SCRIPT_TEMPLATE4); + WSContentSendStyle(); WSContentSend_P(HTTP_FORM_TEMPLATE); WSContentSend_P(HTTP_TABLE100);