diff --git a/sonoff/language/bg-BG.h b/sonoff/language/bg-BG.h index 6d44af3ff..2214634f9 100644 --- a/sonoff/language/bg-BG.h +++ b/sonoff/language/bg-BG.h @@ -220,7 +220,7 @@ // xdrv_02_webserver.ino #define D_NOSCRIPT "Разрешете JavaScript, за да използвате Tasmota" -#define D_MINIMAL_FIRMWARE_PLEASE_UPGRADE "Минимален фърмуеър - моля надградете го" +#define D_MINIMAL_FIRMWARE_PLEASE_UPGRADE "Минимален фърмуеър
моля надградете го" #define D_WEBSERVER_ACTIVE_ON "Уеб сървърът е активен на" #define D_WITH_IP_ADDRESS "с IP адрес" #define D_WEBSERVER_STOPPED "Уеб сървърът е спрян" diff --git a/sonoff/language/cs-CZ.h b/sonoff/language/cs-CZ.h index e4053ea75..41d4fc9de 100644 --- a/sonoff/language/cs-CZ.h +++ b/sonoff/language/cs-CZ.h @@ -220,7 +220,7 @@ // xdrv_02_webserver.ino #define D_NOSCRIPT "Pro používání prostředí Tasmota povolte JavaScript" -#define D_MINIMAL_FIRMWARE_PLEASE_UPGRADE "Firmware MINIMÁLNÍ - prosím zaktualizujte" +#define D_MINIMAL_FIRMWARE_PLEASE_UPGRADE "Firmware MINIMÁLNÍ
prosím zaktualizujte" #define D_WEBSERVER_ACTIVE_ON "Aktivní Web server" #define D_WITH_IP_ADDRESS "na IP adrese" #define D_WEBSERVER_STOPPED "Web server zastaven" diff --git a/sonoff/language/de-DE.h b/sonoff/language/de-DE.h index d93f77b89..0808c91c4 100644 --- a/sonoff/language/de-DE.h +++ b/sonoff/language/de-DE.h @@ -220,7 +220,7 @@ // xdrv_02_webserver.ino #define D_NOSCRIPT "JavaScript aktivieren um Tasmota benutzen zu können" -#define D_MINIMAL_FIRMWARE_PLEASE_UPGRADE "MINIMUM-Firmware - bitte upgraden" +#define D_MINIMAL_FIRMWARE_PLEASE_UPGRADE "MINIMUM-Firmware
bitte upgraden" #define D_WEBSERVER_ACTIVE_ON "Web-Server aktiv bei" #define D_WITH_IP_ADDRESS "mit IP-Adresse" #define D_WEBSERVER_STOPPED "Web-Server angehalten" diff --git a/sonoff/language/el-GR.h b/sonoff/language/el-GR.h index 8a3fe75a5..0e483759d 100644 --- a/sonoff/language/el-GR.h +++ b/sonoff/language/el-GR.h @@ -220,7 +220,7 @@ // webserver.ino #define D_NOSCRIPT "To use Tasmota, please enable JavaScript" -#define D_MINIMAL_FIRMWARE_PLEASE_UPGRADE "MINIMAL firmware - παρακαλώ αναβαθμίστε" +#define D_MINIMAL_FIRMWARE_PLEASE_UPGRADE "MINIMAL firmware
παρακαλώ αναβαθμίστε" #define D_WEBSERVER_ACTIVE_ON "Ενεργός διακομιστής Web στο" #define D_WITH_IP_ADDRESS "με διεύθυνση IP" #define D_WEBSERVER_STOPPED "Ο διακομιστής Web σταμάτησε" diff --git a/sonoff/language/en-GB.h b/sonoff/language/en-GB.h index e459cd02d..d5e792462 100644 --- a/sonoff/language/en-GB.h +++ b/sonoff/language/en-GB.h @@ -220,7 +220,7 @@ // xdrv_02_webserver.ino #define D_NOSCRIPT "To use Tasmota, please enable JavaScript" -#define D_MINIMAL_FIRMWARE_PLEASE_UPGRADE "MINIMAL firmware - please upgrade" +#define D_MINIMAL_FIRMWARE_PLEASE_UPGRADE "MINIMAL firmware
please upgrade" #define D_WEBSERVER_ACTIVE_ON "Web server active on" #define D_WITH_IP_ADDRESS "with IP address" #define D_WEBSERVER_STOPPED "Web server stopped" diff --git a/sonoff/language/es-AR.h b/sonoff/language/es-AR.h index 9f2187bbf..baf9838bf 100644 --- a/sonoff/language/es-AR.h +++ b/sonoff/language/es-AR.h @@ -220,7 +220,7 @@ // xdrv_02_webserver.ino #define D_NOSCRIPT "Habilitar JavaScript para usar Tasmota" -#define D_MINIMAL_FIRMWARE_PLEASE_UPGRADE "Firmware MÍNIMO - actualice por favor" +#define D_MINIMAL_FIRMWARE_PLEASE_UPGRADE "Firmware MÍNIMO
actualice por favor" #define D_WEBSERVER_ACTIVE_ON "Servidor web activo en" #define D_WITH_IP_ADDRESS "con dirección IP" #define D_WEBSERVER_STOPPED "Servidor web detenido" diff --git a/sonoff/language/fr-FR.h b/sonoff/language/fr-FR.h index 6b26a6212..0b7d29eb7 100644 --- a/sonoff/language/fr-FR.h +++ b/sonoff/language/fr-FR.h @@ -220,7 +220,7 @@ // xdrv_02_webserver.ino #define D_NOSCRIPT "Pour utiliser Tasmota, veuillez activer JavaScript" -#define D_MINIMAL_FIRMWARE_PLEASE_UPGRADE "Firmware MINIMAL - merci de mettre à jour" +#define D_MINIMAL_FIRMWARE_PLEASE_UPGRADE "Firmware MINIMAL
merci de mettre à jour" #define D_WEBSERVER_ACTIVE_ON "Serveur web actif sur" #define D_WITH_IP_ADDRESS "avec l'adresse IP" #define D_WEBSERVER_STOPPED "Serveur web éteint" diff --git a/sonoff/language/hu-HU.h b/sonoff/language/hu-HU.h index 649796121..e8b818029 100644 --- a/sonoff/language/hu-HU.h +++ b/sonoff/language/hu-HU.h @@ -220,7 +220,7 @@ // xdrv_02_webserver.ino #define D_NOSCRIPT "A Tasmota használatához engedélyezd a Javascriptet!" -#define D_MINIMAL_FIRMWARE_PLEASE_UPGRADE "MINIMÁLIS firmware - frissítsd!" +#define D_MINIMAL_FIRMWARE_PLEASE_UPGRADE "MINIMÁLIS firmware
frissítsd!" #define D_WEBSERVER_ACTIVE_ON "Webszerver aktív:" #define D_WITH_IP_ADDRESS "IP cím:" #define D_WEBSERVER_STOPPED "Webszerver leállítva" diff --git a/sonoff/language/it-IT.h b/sonoff/language/it-IT.h index 4d735426f..db8e58475 100644 --- a/sonoff/language/it-IT.h +++ b/sonoff/language/it-IT.h @@ -220,7 +220,7 @@ // xdrv_02_webserver.ino #define D_NOSCRIPT "Abilitare JavaScript per utilizzare Tasmota" -#define D_MINIMAL_FIRMWARE_PLEASE_UPGRADE "MINIMAL firmware - effettuare aggiornamento" +#define D_MINIMAL_FIRMWARE_PLEASE_UPGRADE "MINIMAL firmware
effettuare aggiornamento" #define D_WEBSERVER_ACTIVE_ON "Web server attivo su" #define D_WITH_IP_ADDRESS "con indirizzo IP" #define D_WEBSERVER_STOPPED "Web server arrestato" diff --git a/sonoff/language/ko-KO.h b/sonoff/language/ko-KO.h index 1ea02b01f..ddfaba8d3 100644 --- a/sonoff/language/ko-KO.h +++ b/sonoff/language/ko-KO.h @@ -220,7 +220,7 @@ // xdrv_02_webserver.ino #define D_NOSCRIPT "Tasmota를 사용하려면 JavaScript를 활성화 하십시오." -#define D_MINIMAL_FIRMWARE_PLEASE_UPGRADE "MINIMAL firmware - 업그레이드가 필요합니다" +#define D_MINIMAL_FIRMWARE_PLEASE_UPGRADE "MINIMAL firmware
업그레이드가 필요합니다" #define D_WEBSERVER_ACTIVE_ON "Web 서버 작동 중" #define D_WITH_IP_ADDRESS "IP 주소" #define D_WEBSERVER_STOPPED "Web 서버 멈춤" diff --git a/sonoff/language/nl-NL.h b/sonoff/language/nl-NL.h index dd3fb1806..9e428165d 100644 --- a/sonoff/language/nl-NL.h +++ b/sonoff/language/nl-NL.h @@ -220,7 +220,7 @@ // xdrv_02_webserver.ino #define D_NOSCRIPT "Zet JavaScript aan voor Tasmota" -#define D_MINIMAL_FIRMWARE_PLEASE_UPGRADE "MINIMAL firmware - opwaarderen" +#define D_MINIMAL_FIRMWARE_PLEASE_UPGRADE "MINIMAL firmware
opwaarderen" #define D_WEBSERVER_ACTIVE_ON "Webserver actief op" #define D_WITH_IP_ADDRESS "met IP adres" #define D_WEBSERVER_STOPPED "Webserver gestopt" diff --git a/sonoff/language/pl-PL.h b/sonoff/language/pl-PL.h index 24e2f60ae..0f13d248a 100644 --- a/sonoff/language/pl-PL.h +++ b/sonoff/language/pl-PL.h @@ -220,7 +220,7 @@ // xdrv_02_webserver.ino #define D_NOSCRIPT "Aby korzystać z Tasmota, włącz obsługę JavaScript" -#define D_MINIMAL_FIRMWARE_PLEASE_UPGRADE "Oprogramowanie MINIMAL - proszę uaktualnić" +#define D_MINIMAL_FIRMWARE_PLEASE_UPGRADE "Oprogramowanie MINIMAL
proszę uaktualnić" #define D_WEBSERVER_ACTIVE_ON "Aktywny serwer Web" #define D_WITH_IP_ADDRESS "z adresem IP" #define D_WEBSERVER_STOPPED "Serwer Web zatrzymany" diff --git a/sonoff/language/pt-BR.h b/sonoff/language/pt-BR.h index 3d24e2dbc..63efc3f1e 100644 --- a/sonoff/language/pt-BR.h +++ b/sonoff/language/pt-BR.h @@ -220,7 +220,7 @@ // xdrv_02_webserver.ino #define D_NOSCRIPT "To use Tasmota, please enable JavaScript" -#define D_MINIMAL_FIRMWARE_PLEASE_UPGRADE "Firmware mínimo - Atualizar por favor" +#define D_MINIMAL_FIRMWARE_PLEASE_UPGRADE "Firmware mínimo
Atualizar por favor" #define D_WEBSERVER_ACTIVE_ON "Servidor WEB ativo em" #define D_WITH_IP_ADDRESS "com o endereço IP" #define D_WEBSERVER_STOPPED "Servidor WEB parou" diff --git a/sonoff/language/pt-PT.h b/sonoff/language/pt-PT.h index d675efe54..171f33d9b 100644 --- a/sonoff/language/pt-PT.h +++ b/sonoff/language/pt-PT.h @@ -220,7 +220,7 @@ // xdrv_02_webserver.ino #define D_NOSCRIPT "To use Tasmota, please enable JavaScript" -#define D_MINIMAL_FIRMWARE_PLEASE_UPGRADE "MINIMO firmware - Atualizar Por favor" +#define D_MINIMAL_FIRMWARE_PLEASE_UPGRADE "MINIMO firmware
Atualizar Por favor" #define D_WEBSERVER_ACTIVE_ON "Servidor WEB ativo em" #define D_WITH_IP_ADDRESS "com o endereço IP" #define D_WEBSERVER_STOPPED "Servitor WEB parou" diff --git a/sonoff/language/ru-RU.h b/sonoff/language/ru-RU.h index 50eabbc35..e4112953c 100644 --- a/sonoff/language/ru-RU.h +++ b/sonoff/language/ru-RU.h @@ -220,7 +220,7 @@ // xdrv_02_webserver.ino #define D_NOSCRIPT "To use Tasmota, please enable JavaScript" -#define D_MINIMAL_FIRMWARE_PLEASE_UPGRADE "Прошивка MINIMAL - пожалуйста обновите" +#define D_MINIMAL_FIRMWARE_PLEASE_UPGRADE "Прошивка MINIMAL
пожалуйста обновите" #define D_WEBSERVER_ACTIVE_ON "Веб-сервер активен" #define D_WITH_IP_ADDRESS "с IP-адресом" #define D_WEBSERVER_STOPPED "Веб-сервер остановлен" diff --git a/sonoff/language/sk-SK.h b/sonoff/language/sk-SK.h index 4f741ac51..cf99703c8 100644 --- a/sonoff/language/sk-SK.h +++ b/sonoff/language/sk-SK.h @@ -220,7 +220,7 @@ // xdrv_02_webserver.ino #define D_NOSCRIPT "Pre používanie prostredia Tasmota povoľte JavaScript" -#define D_MINIMAL_FIRMWARE_PLEASE_UPGRADE "Firmware MINIMÁLNY - prosím aktualizujte" +#define D_MINIMAL_FIRMWARE_PLEASE_UPGRADE "Firmware MINIMÁLNY
prosím aktualizujte" #define D_WEBSERVER_ACTIVE_ON "Aktívny Web server" #define D_WITH_IP_ADDRESS "na IP adrese" #define D_WEBSERVER_STOPPED "Web server zastavený" diff --git a/sonoff/language/sv-SE.h b/sonoff/language/sv-SE.h index dd6b31469..6a92c1bc1 100644 --- a/sonoff/language/sv-SE.h +++ b/sonoff/language/sv-SE.h @@ -220,7 +220,7 @@ // xdrv_02_webserver.ino #define D_NOSCRIPT "För att använda Tasmota, aktivera JavaScript" -#define D_MINIMAL_FIRMWARE_PLEASE_UPGRADE "MINIMAL firmware - var god uppgradera" +#define D_MINIMAL_FIRMWARE_PLEASE_UPGRADE "MINIMAL firmware
var god uppgradera" #define D_WEBSERVER_ACTIVE_ON "Webbserver aktiv på" #define D_WITH_IP_ADDRESS "med IP-adress" #define D_WEBSERVER_STOPPED "Webbserver stoppad" diff --git a/sonoff/language/tr-TR.h b/sonoff/language/tr-TR.h index f6f61ec56..b887c89c2 100755 --- a/sonoff/language/tr-TR.h +++ b/sonoff/language/tr-TR.h @@ -220,7 +220,7 @@ // xdrv_02_webserver.ino #define D_NOSCRIPT "To use Tasmota, please enable JavaScript" -#define D_MINIMAL_FIRMWARE_PLEASE_UPGRADE "Donanım yazılımı çok düşük, lütfen yükseltin" +#define D_MINIMAL_FIRMWARE_PLEASE_UPGRADE "Donanım yazılımı çok düşük
lütfen yükseltin" #define D_WEBSERVER_ACTIVE_ON "Web sunucusu aktif" #define D_WITH_IP_ADDRESS "IP adres ile" #define D_WEBSERVER_STOPPED "Web sunucusu durdu" diff --git a/sonoff/language/uk-UK.h b/sonoff/language/uk-UK.h index 71b7665c1..0efdd1c94 100644 --- a/sonoff/language/uk-UK.h +++ b/sonoff/language/uk-UK.h @@ -220,7 +220,7 @@ // xdrv_02_webserver.ino #define D_NOSCRIPT "To use Tasmota, please enable JavaScript" -#define D_MINIMAL_FIRMWARE_PLEASE_UPGRADE "Прошивка MINIMAL - будь-ласка оновіть" +#define D_MINIMAL_FIRMWARE_PLEASE_UPGRADE "Прошивка MINIMAL
будь-ласка оновіть" #define D_WEBSERVER_ACTIVE_ON "Веб-сервер активний" #define D_WITH_IP_ADDRESS "з IP-адресом" #define D_WEBSERVER_STOPPED "Веб-сервер зупинений" diff --git a/sonoff/language/zh-CN.h b/sonoff/language/zh-CN.h index 586591278..88767053b 100644 --- a/sonoff/language/zh-CN.h +++ b/sonoff/language/zh-CN.h @@ -220,7 +220,7 @@ // webserver.ino #define D_NOSCRIPT "Tasmota要求浏览器支持 JavaScript" -#define D_MINIMAL_FIRMWARE_PLEASE_UPGRADE "当前是精简版固件 - 请升级" +#define D_MINIMAL_FIRMWARE_PLEASE_UPGRADE "当前是精简版固件
请升级" #define D_WEBSERVER_ACTIVE_ON "Web 服务器地址:" #define D_WITH_IP_ADDRESS "IP 地址:" #define D_WEBSERVER_STOPPED "Web 服务已停止" diff --git a/sonoff/language/zh-TW.h b/sonoff/language/zh-TW.h index ae6d4df07..11f85eef2 100644 --- a/sonoff/language/zh-TW.h +++ b/sonoff/language/zh-TW.h @@ -220,7 +220,7 @@ // xdrv_02_webserver.ino #define D_NOSCRIPT "To use Tasmota, please enable JavaScript" -#define D_MINIMAL_FIRMWARE_PLEASE_UPGRADE "固件版本過低 - 請升級" +#define D_MINIMAL_FIRMWARE_PLEASE_UPGRADE "固件版本過低
請升級" #define D_WEBSERVER_ACTIVE_ON "Web服務器:" #define D_WITH_IP_ADDRESS "IP地址:" #define D_WEBSERVER_STOPPED "Web 服務器已停止" diff --git a/sonoff/sonoff.ino b/sonoff/sonoff.ino index bccd057cf..51b89031c 100755 --- a/sonoff/sonoff.ino +++ b/sonoff/sonoff.ino @@ -167,7 +167,6 @@ bool i2c_flg = false; // I2C configured bool spi_flg = false; // SPI configured bool soft_spi_flg = false; // Software SPI configured bool ntp_force_sync = false; // Force NTP sync -bool reset_web_log_flag = false; // Reset web console log myio my_module; // Active copy of Module GPIOs (17 x 8 bits) gpio_flag my_module_flag; // Active copy of Module GPIO flags StateBitfield global_state; // Global states (currently Wifi and Mqtt) (8 bits) diff --git a/sonoff/sonoff_template.h b/sonoff/sonoff_template.h index c839d2a7e..cf5a1af78 100644 --- a/sonoff/sonoff_template.h +++ b/sonoff/sonoff_template.h @@ -1472,10 +1472,10 @@ const mytmplt kModules[MAXMODULE] PROGMEM = { 0, 0 }, { "Shelly 1", // Shelly1 Open Source (ESP8266 - 2MB) - https://shelly.cloud/shelly1-open-source/ - GPIO_USER, // GPIO00 - Only to be used when Shelly is connected to 12V DC - GPIO_USER, // GPIO01 Serial RXD - Only to be used when Shelly is connected to 12V DC + 0, // GPIO00 - Can be changed to GPIO_USER, only if Shelly is powered with 12V DC + 0, // GPIO01 Serial RXD - Can be changed to GPIO_USER, only if Shelly is powered with 12V DC 0, - GPIO_USER, // GPIO03 Serial TXD - Only to be used when Shelly is connected to 12V DC + 0, // GPIO03 Serial TXD - Can be changed to GPIO_USER, only if Shelly is powered with 12V DC GPIO_REL1, // GPIO04 Relay (0 = Off, 1 = On) GPIO_SWT1_NP, // GPIO05 SW pin // GPIO06 (SD_CLK Flash) diff --git a/sonoff/xdrv_01_webserver.ino b/sonoff/xdrv_01_webserver.ino index d8ab7b56e..415d14e53 100644 --- a/sonoff/xdrv_01_webserver.ino +++ b/sonoff/xdrv_01_webserver.ino @@ -383,7 +383,7 @@ const char HTTP_END[] PROGMEM = ""; const char HTTP_DEVICE_CONTROL[] PROGMEM = ""; // ?o is related to WebGetArg("o", tmp, sizeof(tmp)); -const char HTTP_DEVICE_STATE[] PROGMEM = "%s%s"; // {c} = %'>
%s
"; // {c} = %'>
"), mqtt_data); + char stemp[strlen(mqtt_data) +1]; + memcpy(stemp, mqtt_data, sizeof(stemp)); + + WSContentBegin(200, CT_HTML); + WSContentSend_P(PSTR("{t}%s"), stemp); if (devices_present) { - snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s{t}"), mqtt_data); + WSContentSend_P(PSTR("{t}")); uint8_t fsize = (devices_present < 5) ? 70 - (devices_present * 8) : 32; if (SONOFF_IFAN02 == my_module_type) { - snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_DEVICE_STATE, - mqtt_data, 36, (bitRead(power, 0)) ? "bold" : "normal", 54, GetStateText(bitRead(power, 0))); + WSContentSend_P(HTTP_DEVICE_STATE, 36, (bitRead(power, 0)) ? "bold" : "normal", 54, GetStateText(bitRead(power, 0))); uint8_t fanspeed = GetFanspeed(); snprintf_P(svalue, sizeof(svalue), PSTR("%d"), fanspeed); - snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_DEVICE_STATE, - mqtt_data, 64, (fanspeed) ? "bold" : "normal", 54, (fanspeed) ? svalue : GetStateText(0)); + WSContentSend_P(HTTP_DEVICE_STATE, 64, (fanspeed) ? "bold" : "normal", 54, (fanspeed) ? svalue : GetStateText(0)); } else { for (uint8_t idx = 1; idx <= devices_present; idx++) { snprintf_P(svalue, sizeof(svalue), PSTR("%d"), bitRead(power, idx -1)); - snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_DEVICE_STATE, - mqtt_data, 100 / devices_present, (bitRead(power, idx -1)) ? "bold" : "normal", fsize, (devices_present < 5) ? GetStateText(bitRead(power, idx -1)) : svalue); + WSContentSend_P(HTTP_DEVICE_STATE, 100 / devices_present, (bitRead(power, idx -1)) ? "bold" : "normal", fsize, (devices_present < 5) ? GetStateText(bitRead(power, idx -1)) : svalue); } } - snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s"), mqtt_data); + WSContentSend_P(PSTR("")); } - WSHeaderSend(); - WSSend(200, CT_HTML, mqtt_data); + WSContentEnd(); + return true; } @@ -987,7 +1003,7 @@ void HandleConfiguration(void) WSContentButton(BUTTON_RESTORE); WSContentSpaceButton(BUTTON_MAIN); - WSContentEnd(); + WSContentStop(); } /*-------------------------------------------------------------------------------------------*/ @@ -1005,13 +1021,12 @@ void HandleTemplateConfiguration(void) char stemp[20]; // Template number and Sensor name if (WebServer->hasArg("m")) { - String page = ""; + WSContentBegin(200, CT_PLAIN); for (uint8_t i = 0; i < MAXMODULE; i++) { // "}2'%d'>%s (%d)}3" - "}2'0'>Sonoff Basic (1)}3" uint8_t midx = pgm_read_byte(kModuleNiceList + i); - snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_MODULE_TEMPLATE_REPLACE, midx, AnyModuleName(midx).c_str(), midx +1); - page += mqtt_data; + WSContentSend_P(HTTP_MODULE_TEMPLATE_REPLACE, midx, AnyModuleName(midx).c_str(), midx +1); } - WSSend(200, CT_PLAIN, page); + WSContentEnd(); return; } @@ -1025,32 +1040,26 @@ void HandleTemplateConfiguration(void) gpio_flag flag = ModuleFlag(); Settings.module = module_save; - String page = AnyModuleName(module); // NAME: Generic - page += F("}1"); // Field separator - + WSContentBegin(200, CT_PLAIN); + WSContentSend_P(PSTR("%s}1"), AnyModuleName(module).c_str()); // NAME: Generic for (uint8_t i = 0; i < sizeof(kGpioNiceList); i++) { // GPIO: }2'0'>None (0)}3}2'17'>Button1 (17)}3... if (1 == i) { - snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_MODULE_TEMPLATE_REPLACE, 255, D_SENSOR_USER, 255); // }2'255'>User (255)}3 - page += mqtt_data; + WSContentSend_P(HTTP_MODULE_TEMPLATE_REPLACE, 255, D_SENSOR_USER, 255); // }2'255'>User (255)}3 } uint8_t midx = pgm_read_byte(kGpioNiceList + i); - snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_MODULE_TEMPLATE_REPLACE, midx, GetTextIndexed(stemp, sizeof(stemp), midx, kSensorNames), midx); - page += mqtt_data; + WSContentSend_P(HTTP_MODULE_TEMPLATE_REPLACE, midx, GetTextIndexed(stemp, sizeof(stemp), midx, kSensorNames), midx); } - page += F("}1"); // Field separator - mqtt_data[0] = '\0'; + WSContentSend_P(PSTR("}1")); // Field separator for (uint8_t i = 0; i < sizeof(cmodule); i++) { // 17,148,29,149,7,255,255,255,138,255,139,255,255 if ((i < 6) || ((i > 8) && (i != 11))) { // Ignore flash pins GPIO06, 7, 8 and 11 - snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s%s%d"), mqtt_data, (i>0)?",":"", cmodule.io[i]); + WSContentSend_P(PSTR("%s%d"), (i>0)?",":"", cmodule.io[i]); } } - snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s}1%d}1%d"), mqtt_data, flag, Settings.user_template_base); // FLAG: 1 BASE: 17 - page += mqtt_data; - - WSSend(200, CT_PLAIN, page); + WSContentSend_P(PSTR("}1%d}1%d"), flag, Settings.user_template_base); // FLAG: 1 BASE: 17 + WSContentEnd(); return; } @@ -1078,7 +1087,7 @@ void HandleTemplateConfiguration(void) WSContentSend_P(HTTP_FORM_TEMPLATE_FLAG); WSContentSend_P(HTTP_FORM_END); WSContentSpaceButton(BUTTON_CONFIGURATION); - WSContentEnd(); + WSContentStop(); } void TemplateSaveSettings(void) @@ -1132,7 +1141,7 @@ void HandleModuleConfiguration(void) ModuleGpios(&cmodule); if (WebServer->hasArg("m")) { - String page = ""; + WSContentBegin(200, CT_PLAIN); uint8_t vidx = 0; for (uint8_t i = 0; i <= MAXMODULE; i++) { // "}2'%d'>%s (%d)}3" - "}2'255'>UserTemplate (0)}3" - "}2'0'>Sonoff Basic (1)}3" if (0 == i) { @@ -1142,23 +1151,21 @@ void HandleModuleConfiguration(void) midx = pgm_read_byte(kModuleNiceList + i -1); vidx = midx +1; } - snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_MODULE_TEMPLATE_REPLACE, midx, AnyModuleName(midx).c_str(), vidx); - page += mqtt_data; + WSContentSend_P(HTTP_MODULE_TEMPLATE_REPLACE, midx, AnyModuleName(midx).c_str(), vidx); } - WSSend(200, CT_PLAIN, page); + WSContentEnd(); return; } if (WebServer->hasArg("g")) { - String page = ""; + WSContentBegin(200, CT_PLAIN); for (uint8_t j = 0; j < sizeof(kGpioNiceList); j++) { midx = pgm_read_byte(kGpioNiceList + j); if (!GetUsedInModule(midx, cmodule.io)) { - snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_MODULE_TEMPLATE_REPLACE, midx, GetTextIndexed(stemp, sizeof(stemp), midx, kSensorNames), midx); - page += mqtt_data; + WSContentSend_P(HTTP_MODULE_TEMPLATE_REPLACE, midx, GetTextIndexed(stemp, sizeof(stemp), midx, kSensorNames), midx); } } - WSSend(200, CT_PLAIN, page); + WSContentEnd(); return; } @@ -1185,7 +1192,7 @@ void HandleModuleConfiguration(void) WSContentSend_P(PSTR("")); WSContentSend_P(HTTP_FORM_END); WSContentSpaceButton(BUTTON_CONFIGURATION); - WSContentEnd(); + WSContentStop(); } void ModuleSaveSettings(void) @@ -1327,7 +1334,7 @@ void HandleWifiConfiguration(void) } else { WSContentSpaceButton(BUTTON_CONFIGURATION); } - WSContentEnd(); + WSContentStop(); } void WifiSaveSettings(void) @@ -1386,7 +1393,7 @@ void HandleLoggingConfiguration(void) WSContentSend_P(HTTP_FORM_LOG2, Settings.syslog_host, Settings.syslog_port, Settings.tele_period); WSContentSend_P(HTTP_FORM_END); WSContentSpaceButton(BUTTON_CONFIGURATION); - WSContentEnd(); + WSContentStop(); } void LoggingSaveSettings(void) @@ -1462,7 +1469,7 @@ void HandleOtherConfiguration(void) WSContentSend_P(HTTP_FORM_END); WSContentSpaceButton(BUTTON_CONFIGURATION); - WSContentEnd(); + WSContentStop(); } void OtherSaveSettings(void) @@ -1558,7 +1565,7 @@ void HandleResetConfiguration(void) WSContentSend_P(PSTR("
" D_CONFIGURATION_RESET "
")); WSContentSend_P(HTTP_MSG_RSTRT); WSContentSpaceButton(BUTTON_MAIN); - WSContentEnd(); + WSContentStop(); char command[CMDSZ]; snprintf_P(command, sizeof(command), PSTR(D_CMND_RESET " 1")); @@ -1576,7 +1583,7 @@ void HandleRestoreConfiguration(void) WSContentSend_P(HTTP_FORM_RST); WSContentSend_P(HTTP_FORM_RST_UPG, D_RESTORE); WSContentSpaceButton(BUTTON_CONFIGURATION); - WSContentEnd(); + WSContentStop(); upload_error = 0; upload_file_type = UPL_SETTINGS; @@ -1678,7 +1685,7 @@ void HandleInformation(void) "
")); // WSContentSend_P(PSTR("")); WSContentSpaceButton(BUTTON_MAIN); - WSContentEnd(); + WSContentStop(); } #endif // Not FIRMWARE_MINIMAL @@ -1695,7 +1702,7 @@ void HandleUpgradeFirmware(void) WSContentSend_P(HTTP_FORM_UPG, Settings.ota_url); WSContentSend_P(HTTP_FORM_RST_UPG, D_UPGRADE); WSContentSpaceButton(BUTTON_MAIN); - WSContentEnd(); + WSContentStop(); upload_error = 0; upload_file_type = UPL_TASMOTA; @@ -1723,7 +1730,7 @@ void HandleUpgradeFirmwareStart(void) WSContentSend_P(PSTR("
" D_UPGRADE_STARTED " ...
")); WSContentSend_P(HTTP_MSG_RSTRT); WSContentSpaceButton(BUTTON_MAIN); - WSContentEnd(); + WSContentStop(); snprintf_P(command, sizeof(command), PSTR(D_CMND_UPGRADE " 1")); ExecuteWebCommand(command, SRC_WEBGUI); @@ -1770,7 +1777,7 @@ void HandleUploadDone(void) SettingsBufferFree(); WSContentSend_P(PSTR("

")); WSContentSpaceButton(BUTTON_MAIN); - WSContentEnd(); + WSContentStop(); } void HandleUploadLoop(void) @@ -1990,7 +1997,7 @@ void HandleHttpCommand(void) if (!(!strcmp(tmp1, WEB_USERNAME) && !strcmp(tmp2, Settings.web_password))) { valid = 0; } } - String message = F("{\"" D_RSLT_WARNING "\":\""); + WSContentBegin(200, CT_JSON); if (valid) { uint8_t curridx = web_log_index; String svalue = WebServer->arg("cmnd"); @@ -1998,7 +2005,8 @@ void HandleHttpCommand(void) ExecuteWebCommand((char*)svalue.c_str(), SRC_WEBCOMMAND); if (web_log_index != curridx) { uint8_t counter = curridx; - message = F("{"); + WSContentSend_P(PSTR("{")); + bool cflg = false; do { char* tmp; size_t len; @@ -2007,28 +2015,28 @@ void HandleHttpCommand(void) // [14:49:36 MQTT: stat/wemos5/RESULT = {"POWER":"OFF"}] > [{"POWER":"OFF"}] char* JSON = (char*)memchr(tmp, '{', len); if (JSON) { // Is it a JSON message (and not only [15:26:08 MQT: stat/wemos5/POWER = O]) - if (message.length() > 1) { message += F(","); } size_t JSONlen = len - (JSON - tmp); if (JSONlen > sizeof(mqtt_data)) { JSONlen = sizeof(mqtt_data); } - strlcpy(mqtt_data, JSON +1, JSONlen -2); - message += mqtt_data; + char stemp[JSONlen]; + strlcpy(stemp, JSON +1, JSONlen -2); + WSContentSend_P(PSTR("%s%s"), (cflg) ? "," : "", stemp); + cflg = true; } } counter++; if (!counter) counter++; // Skip 0 as it is not allowed } while (counter != web_log_index); - message += F("}"); + WSContentSend_P(PSTR("}")); } else { - message += F(D_ENABLE_WEBLOG_FOR_RESPONSE "\"}"); + WSContentSend_P(PSTR("{\"" D_RSLT_WARNING "\":\"" D_ENABLE_WEBLOG_FOR_RESPONSE "\"}")); } } else { - message += F(D_ENTER_COMMAND " cmnd=\"}"); + WSContentSend_P(PSTR("{\"" D_RSLT_WARNING "\":\"" D_ENTER_COMMAND " cmnd=\"}")); } } else { - message += F(D_NEED_USER_AND_PASSWORD "\"}"); + WSContentSend_P(PSTR("{\"" D_RSLT_WARNING "\":\"" D_NEED_USER_AND_PASSWORD "\"}")); } - WSHeaderSend(); - WSSend(200, CT_JSON, message); + WSContentEnd(); } /*-------------------------------------------------------------------------------------------*/ @@ -2049,7 +2057,7 @@ void HandleConsole(void) WSContentSendStyle(); WSContentSend_P(HTTP_FORM_CMND); WSContentSpaceButton(BUTTON_MAIN); - WSContentEnd(); + WSContentStop(); } void HandleConsoleRefresh(void) @@ -2067,10 +2075,8 @@ void HandleConsoleRefresh(void) WebGetArg("c2", stmp, sizeof(stmp)); if (strlen(stmp)) { counter = atoi(stmp); } - bool last_reset_web_log_flag = reset_web_log_flag; - // mqtt_data used as scratch space - snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%d}1%d}1"), web_log_index, last_reset_web_log_flag); - String message = mqtt_data; + WSContentBegin(200, CT_PLAIN); + WSContentSend_P(PSTR("%d}1%d}1"), web_log_index, reset_web_log_flag); if (!reset_web_log_flag) { counter = 0; reset_web_log_flag = true; @@ -2085,21 +2091,18 @@ void HandleConsoleRefresh(void) size_t len; GetLog(counter, &tmp, &len); if (len) { - if (cflg) { - message += F("\n"); - } else { - cflg = true; - } if (len > sizeof(mqtt_data) -2) { len = sizeof(mqtt_data); } - strlcpy(mqtt_data, tmp, len); - message += mqtt_data; // mqtt_data used as scratch space + char stemp[len +1]; + strlcpy(stemp, tmp, len); + WSContentSend_P(PSTR("%s%s"), (cflg) ? "\n" : "", stemp); + cflg = true; } counter++; - if (!counter) { counter++; } // Skip log index 0 as it is not allowed + if (!counter) { counter++; } // Skip log index 0 as it is not allowed } while (counter != web_log_index); } - message += F("}1"); - WSSend(200, CT_PLAIN, message); + WSContentSend_P(PSTR("}1")); + WSContentEnd(); } /********************************************************************************************/ diff --git a/sonoff/xdrv_02_mqtt.ino b/sonoff/xdrv_02_mqtt.ino index 97ee79894..57086d46e 100644 --- a/sonoff/xdrv_02_mqtt.ino +++ b/sonoff/xdrv_02_mqtt.ino @@ -18,7 +18,6 @@ */ #define XDRV_02 2 -/*********************************************************************************************/ #ifdef USE_MQTT_TLS #ifdef USE_MQTT_TLS_CA_CERT @@ -441,13 +440,11 @@ void MqttReconnect(void) GetTopic_P(stopic, TELE, mqtt_topic, S_LWT); snprintf_P(mqtt_data, sizeof(mqtt_data), S_OFFLINE); -//#ifdef ARDUINO_ESP8266_RELEASE_2_4_1 #ifdef USE_MQTT_TLS EspClient = WiFiClientSecure(); // Wifi Secure Client reconnect issue 4497 (https://github.com/esp8266/Arduino/issues/4497) #else EspClient = WiFiClient(); // Wifi Client reconnect issue 4497 (https://github.com/esp8266/Arduino/issues/4497) #endif -//#endif if (2 == mqtt_initial_connection_state) { // Executed once just after power on and wifi is connected #ifdef USE_MQTT_TLS @@ -777,7 +774,7 @@ void HandleMqttConfiguration(void) Settings.mqtt_fulltopic); WSContentSend_P(HTTP_FORM_END); WSContentSpaceButton(BUTTON_CONFIGURATION); - WSContentEnd(); + WSContentStop(); } void MqttSaveSettings(void) diff --git a/sonoff/xdrv_07_domoticz.ino b/sonoff/xdrv_07_domoticz.ino index c2020176d..799b2d4b8 100644 --- a/sonoff/xdrv_07_domoticz.ino +++ b/sonoff/xdrv_07_domoticz.ino @@ -482,7 +482,7 @@ void HandleDomoticzConfiguration(void) WSContentSend_P(PSTR("")); WSContentSend_P(HTTP_FORM_END); WSContentSpaceButton(BUTTON_CONFIGURATION); - WSContentEnd(); + WSContentStop(); } void DomoticzSaveSettings(void) diff --git a/sonoff/xdrv_09_timers.ino b/sonoff/xdrv_09_timers.ino index 9a85ad3c4..a3ab51a1b 100644 --- a/sonoff/xdrv_09_timers.ino +++ b/sonoff/xdrv_09_timers.ino @@ -721,7 +721,7 @@ void HandleTimerConfiguration(void) WSContentSend_P(HTTP_FORM_TIMER4); WSContentSend_P(HTTP_FORM_END); WSContentSpaceButton(BUTTON_CONFIGURATION); - WSContentEnd(); + WSContentStop(); } void TimerSaveSettings(void) diff --git a/sonoff/xdrv_11_knx.ino b/sonoff/xdrv_11_knx.ino index 5ab0c7c88..45c9fe15f 100644 --- a/sonoff/xdrv_11_knx.ino +++ b/sonoff/xdrv_11_knx.ino @@ -934,7 +934,7 @@ void HandleKNXConfiguration(void) WSContentSend_P(PSTR("")); WSContentSend_P(HTTP_FORM_END); WSContentSpaceButton(BUTTON_CONFIGURATION); - WSContentEnd(); + WSContentStop(); } } diff --git a/sonoff/xsns_34_hx711.ino b/sonoff/xsns_34_hx711.ino index 2072dc496..c287ef3f4 100644 --- a/sonoff/xsns_34_hx711.ino +++ b/sonoff/xsns_34_hx711.ino @@ -434,7 +434,7 @@ void HandleHxAction(void) WSContentSend_P(HTTP_FORM_HX711, stemp1, stemp2); WSContentSend_P(HTTP_FORM_END); WSContentSpaceButton(BUTTON_CONFIGURATION); - WSContentEnd(); + WSContentStop(); } void HxSaveSettings(void)