diff --git a/CHANGELOG.md b/CHANGELOG.md index 49356dc24..9d4459c12 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,9 @@ All notable changes to this project will be documented in this file. ## [9.5.0.1] ### Changed +- ESP32 core library from v1.0.6 to v1.0.7 - Force ESP32 defines USE_UFILESYS, GUI_TRASH_FILE and #define GUI_EDIT_FILE +- Speed up initial GUI console refresh ## [Released] diff --git a/RELEASENOTES.md b/RELEASENOTES.md index f13931f44..f1ee81834 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -99,7 +99,9 @@ The latter links can be used for OTA upgrades too like ``OtaUrl http://ota.tasmo ### Added ### Changed +- ESP32 core library from v1.0.6 to v1.0.7 - Force ESP32 defines USE_UFILESYS, GUI_TRASH_FILE and #define GUI_EDIT_FILE +- Speed up initial GUI console refresh ### Fixed diff --git a/tasmota/tasmota.h b/tasmota/tasmota.h index a76403d7d..8adb7da07 100644 --- a/tasmota/tasmota.h +++ b/tasmota/tasmota.h @@ -170,13 +170,12 @@ const uint16_t TOPSZ = 151; // Max number of characters in topic #ifdef ESP8266 #ifdef PIO_FRAMEWORK_ARDUINO_MMU_CACHE16_IRAM48_SECHEAP_SHARED -const uint16_t LOG_BUFFER_SIZE = 4096; // Max number of characters in logbuffer used by weblog, syslog and mqttlog -//const uint16_t LOG_BUFFER_SIZE = 6144; // Max number of characters in logbuffer used by weblog, syslog and mqttlog +const uint16_t LOG_BUFFER_SIZE = 6096; // Max number of characters in logbuffer used by weblog, syslog and mqttlog #else const uint16_t LOG_BUFFER_SIZE = 4096; // Max number of characters in logbuffer used by weblog, syslog and mqttlog #endif // PIO_FRAMEWORK_ARDUINO_MMU_CACHE16_IRAM48_SECHEAP_SHARED #else // Not ESP8266 -const uint16_t LOG_BUFFER_SIZE = 6144; // Max number of characters in logbuffer used by weblog, syslog and mqttlog +const uint16_t LOG_BUFFER_SIZE = 6096; // Max number of characters in logbuffer used by weblog, syslog and mqttlog #endif // ESP8266 #ifdef MQTT_DATA_STRING diff --git a/tasmota/xdrv_01_webserver.ino b/tasmota/xdrv_01_webserver.ino index 31ef3cef3..3e9ba57f1 100644 --- a/tasmota/xdrv_01_webserver.ino +++ b/tasmota/xdrv_01_webserver.ino @@ -47,7 +47,7 @@ #endif // If the first is true, but this is false, the device will restart but the user will see // a window telling that the WiFi Configuration was Ok and that the window can be closed. -const uint16_t CHUNKED_BUFFER_SIZE = 500; // Chunk buffer size +const uint16_t CHUNKED_BUFFER_SIZE = 500; // Chunk buffer size (needs to be well below stack space (4k for ESP8266, 8k for ESP32) but large enough to cache some small messages) const uint16_t HTTP_REFRESH_TIME = 2345; // milliseconds const uint16_t HTTP_RESTART_RECONNECT_TIME = 10000; // milliseconds - Allow time for restart and wifi reconnect @@ -710,9 +710,31 @@ void WSContentFlush(void) { } } +void _WSContentSendBufferChunk(const char* content) { + int len = strlen(content); + if (len < CHUNKED_BUFFER_SIZE) { // Append chunk buffer with small content + Web.chunk_buffer += content; + len = Web.chunk_buffer.length(); + } + if (len >= CHUNKED_BUFFER_SIZE) { // Either content or chunk buffer is oversize + WSContentFlush(); // Send chunk buffer before possible content oversize + } + if (strlen(content) >= CHUNKED_BUFFER_SIZE) { // Content is oversize + _WSContentSend(content); // Send content + } +} + void WSContentSend(const char* content, size_t size) { - WSContentFlush(); - _WSContentSend(content, size); + // To speed up transmission use chunked buffer if possible + if (size < CHUNKED_BUFFER_SIZE) { + // Terminate non-terminated content + char buffer[size +1]; + strlcpy(buffer, content, sizeof(buffer)); // Terminate with '\0' + _WSContentSendBufferChunk(buffer); + } else { + WSContentFlush(); // Flush chunk buffer + _WSContentSend(content, size); + } } void _WSContentSendBuffer(bool decimal, const char * formatP, va_list arg) { @@ -730,18 +752,7 @@ void _WSContentSendBuffer(bool decimal, const char * formatP, va_list arg) { } } - if (len < CHUNKED_BUFFER_SIZE) { // Append chunk buffer with small content - Web.chunk_buffer += content; - len = Web.chunk_buffer.length(); - } - - if (len >= CHUNKED_BUFFER_SIZE) { // Either content or chunk buffer is oversize - WSContentFlush(); // Send chunk buffer before possible content oversize - } - if (strlen(content) >= CHUNKED_BUFFER_SIZE) { // Content is oversize - _WSContentSend(content); // Send content - } - + _WSContentSendBufferChunk(content); free(content); } @@ -761,8 +772,7 @@ void WSContentSend_PD(const char* formatP, ...) { // Content send snprintf_P ch va_end(arg); } -void WSContentStart_P(const char* title, bool auth) -{ +void WSContentStart_P(const char* title, bool auth) { if (auth && !WebAuthenticate()) { return Webserver->requestAuthentication(); } @@ -774,13 +784,11 @@ void WSContentStart_P(const char* title, bool auth) } } -void WSContentStart_P(const char* title) -{ +void WSContentStart_P(const char* title) { WSContentStart_P(title, true); } -void WSContentSendStyle_P(const char* formatP, ...) -{ +void WSContentSendStyle_P(const char* formatP, ...) { if ( WifiIsInManagerMode() && (!Web.initial_config) ) { if (WifiConfigCounter()) { WSContentSend_P(HTTP_SCRIPT_COUNTER); @@ -828,8 +836,7 @@ void WSContentSendStyle_P(const char* formatP, ...) WSContentSend_P(PSTR("")); } -void WSContentSendStyle(void) -{ +void WSContentSendStyle(void) { WSContentSendStyle_P(nullptr); } @@ -837,8 +844,7 @@ void WSContentTextCenterStart(uint32_t color) { WSContentSend_P(PSTR("
"), color); } -void WSContentButton(uint32_t title_index, bool show=true) -{ +void WSContentButton(uint32_t title_index, bool show=true) { char action[4]; char title[100]; // Large to accomodate UTF-16 as used by Russian @@ -858,8 +864,7 @@ void WSContentButton(uint32_t title_index, bool show=true) } } -void WSContentSpaceButton(uint32_t title_index, bool show=true) -{ +void WSContentSpaceButton(uint32_t title_index, bool show=true) { WSContentSend_P(PSTR("
"),title_index, show ? "block":"none"); // 5px padding WSContentButton(title_index, show); } @@ -876,8 +881,7 @@ void WSContentSend_CurrentMA(const char *types, float f_current) { WSContentSend_PD(HTTP_SNS_F_CURRENT_MA, types, Settings->flag2.current_resolution, &f_current); } -void WSContentSend_THD(const char *types, float f_temperature, float f_humidity) -{ +void WSContentSend_THD(const char *types, float f_temperature, float f_humidity) { WSContentSend_Temp(types, f_temperature); char parameter[FLOATSZ]; @@ -887,14 +891,13 @@ void WSContentSend_THD(const char *types, float f_temperature, float f_humidity) WSContentSend_PD(HTTP_SNS_DEW, types, parameter, TempUnit()); } -void WSContentEnd(void) -{ - WSContentSend("", 0); // Signal end of chunked content +void WSContentEnd(void) { + WSContentFlush(); // Flush chunk buffer + _WSContentSend(""); // Signal end of chunked content Webserver->client().stop(); } -void WSContentStop(void) -{ +void WSContentStop(void) { if ( WifiIsInManagerMode() && (!Web.initial_config) ) { if (WifiConfigCounter()) { WSContentSend_P(HTTP_COUNTER);