Fix ESP8266 Device Group exception due to lack of stack space (#22271)

This commit is contained in:
Theo Arends 2024-12-09 15:16:30 +01:00
parent 23e5a4dec2
commit 71dfae2d9d
5 changed files with 29 additions and 14 deletions

View File

@ -41,6 +41,7 @@ All notable changes to this project will be documented in this file.
- ESP32-C2 TasmotaLED from not present I2S to SPI (#22575)
- KNX Scenes index change regression from v14.2.0.4 (#22405)
- Add GUI submenu headers and refresh configuration button text (#22592)
- ESP8266 Device Group exception due to lack of stack space (#22271)
### Removed

View File

@ -36,9 +36,9 @@ While fallback or downgrading is common practice it was never supported due to S
This release will be supported from ESP8266/Arduino library Core version **2.7.8** due to reported security and stability issues on previous Core version. This will also support gzipped binaries.
This release will be supported from ESP32/Arduino library Core version **v3.1.0.240926**.
This release will be supported from ESP32/Arduino library Core version **v3.1.0.241206**.
Support of ESP8266 Core versions before 2.7.8 and ESP32 Core versions before v3.1.0.240926 have been removed.
Support of ESP8266 Core versions before 2.7.8 and ESP32 Core versions before v3.1.0.241206 have been removed.
## Support of TLS
@ -80,7 +80,7 @@ Historical binaries can be downloaded from
The latter links can be used for OTA upgrades too like ``OtaUrl http://ota.tasmota.com/tasmota/release/tasmota.bin.gz``
### ESP32, ESP32-C2, ESP32-C3, ESP32-C6, ESP32-S2 and ESP32-S3 based
The following binary downloads have been compiled with ESP32/Arduino library core version **v3.1.0.240926**.
The following binary downloads have been compiled with ESP32/Arduino library core version **v3.1.0.241206**.
- **tasmota32.bin** = The Tasmota version with most drivers including additional sensors and KNX for 4M+ flash. **RECOMMENDED RELEASE BINARY**
- **tasmota32solo1.bin** = The Tasmota version with most drivers including additional sensors and KNX for single core ESP32 and 4M+ flash.
@ -188,6 +188,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm
- Mitsubishi Electric HVAC Standby Stage for MiElHVAC [#22430](https://github.com/arendst/Tasmota/issues/22430)
- EQ3 TRV firmware version 1.46 fails if the default true is used in subscribe on the notify characteristic [#22328](https://github.com/arendst/Tasmota/issues/22328)
- Ethernet on -DFRAMEWORK_ARDUINO_ITEAD framework regression from v14.3.0 [#22367](https://github.com/arendst/Tasmota/issues/22367)
- ESP8266 Device Group exception due to lack of stack space (#22271)[#22271](https://github.com/arendst/Tasmota/issues/22271)
- ESP32 Upgrade by file upload response based on file size [#22500](https://github.com/arendst/Tasmota/issues/22500)
- ESP32 Arduino Core IPv6 zones used by Matter [#22378](https://github.com/arendst/Tasmota/issues/22378)
- ESP32, ESP32-S2 and ESP32-S3 re-enable touch buttons [#22446](https://github.com/arendst/Tasmota/issues/22446)

View File

@ -2654,11 +2654,12 @@ void AddLogData(uint32_t loglevel, const char* log_data, const char* log_data_pa
// Each entry has this format: [index][loglevel][log data]['\1']
// Truncate log messages longer than MAX_LOGSZ which is the log buffer size minus 64 spare
char *too_long = nullptr;
uint32_t log_data_len = strlen(log_data) + strlen(log_data_payload) + strlen(log_data_retained);
char too_long[TOPSZ];
if (log_data_len > MAX_LOGSZ) {
snprintf_P(too_long, sizeof(too_long) - 20, PSTR("%s%s"), log_data, log_data_payload); // 20 = strlen("... 123456 truncated")
snprintf_P(too_long, sizeof(too_long), PSTR("%s... %d truncated"), too_long, log_data_len);
too_long = (char*)malloc(TOPSZ); // Use heap in favour of stack
snprintf_P(too_long, TOPSZ - 20, PSTR("%s%s"), log_data, log_data_payload); // 20 = strlen("... 123456 truncated")
snprintf_P(too_long, TOPSZ, PSTR("%s... %d truncated"), too_long, log_data_len);
log_data = too_long;
log_data_payload = empty;
log_data_retained = empty;
@ -2679,6 +2680,9 @@ void AddLogData(uint32_t loglevel, const char* log_data, const char* log_data_pa
}
snprintf_P(TasmotaGlobal.log_buffer, LOG_BUFFER_SIZE, PSTR("%s%c%c%s%s%s%s\1"),
TasmotaGlobal.log_buffer, TasmotaGlobal.log_buffer_pointer++, '0'+loglevel, mxtime, log_data, log_data_payload, log_data_retained);
if (too_long) {
free(too_long);
}
TasmotaGlobal.log_buffer_pointer &= 0xFF;
if (!TasmotaGlobal.log_buffer_pointer) {
TasmotaGlobal.log_buffer_pointer++; // Index 0 is not allowed as it is the end of char string

View File

@ -348,6 +348,13 @@ void ExecuteCommand(const char *cmnd, uint32_t source)
CommandHandler(stopic, svalue, strlen(svalue));
}
bool GetFallbackTopicFlag(char* topicBuf) {
// Use this function to free CommandHandler stack space from TOPSZ
char stemp1[TOPSZ];
GetFallbackTopic_P(stemp1, ""); // Full Fallback topic = cmnd/DVES_xxxxxxxx_fb/
return (!strncmp(topicBuf, stemp1, strlen(stemp1)));
}
/********************************************************************************************/
// topicBuf: /power1 dataBuf: toggle = Console command
@ -369,9 +376,7 @@ void CommandHandler(char* topicBuf, char* dataBuf, uint32_t data_len) {
}
}
char stemp1[TOPSZ];
GetFallbackTopic_P(stemp1, ""); // Full Fallback topic = cmnd/DVES_xxxxxxxx_fb/
TasmotaGlobal.fallback_topic_flag = (!strncmp(topicBuf, stemp1, strlen(stemp1)));
TasmotaGlobal.fallback_topic_flag = GetFallbackTopicFlag(topicBuf);
char *type = strrchr(topicBuf, '/'); // Last part of received topic is always the command (type)
@ -416,11 +421,13 @@ void CommandHandler(char* topicBuf, char* dataBuf, uint32_t data_len) {
}
Response_P(PSTR("_1")); // Signal error message for either Command Error or Command Unknown
char number[12];
char command_line[64];
snprintf_P(command_line, sizeof(command_line), PSTR("%s%s%s%s"),
char stemp1[16];
// char command_line[64];
// snprintf_P(command_line, sizeof(command_line), PSTR("%s%s%s%s"),
char *command_line = (char*)malloc(64); // Use heap in favour of stack
snprintf_P(command_line, 64, PSTR("%s%s%s%s"),
type,
(index != 1) ? itoa(index, number, 10) : "",
(index != 1) ? itoa(index, stemp1, 10) : "",
(data_len) ? " " : "",
(data_len) ? (binary_data) ? HexToString((uint8_t*)dataBuf, data_len).c_str() : EscapeJSONString(dataBuf).c_str() : "");
@ -483,6 +490,7 @@ void CommandHandler(char* topicBuf, char* dataBuf, uint32_t data_len) {
}
ResponseAppend_P(PSTR(",\"Input\":\"%s\"}"), command_line);
}
free(command_line);
if (ResponseLength()) {
if (TasmotaGlobal.no_mqtt_response){ // If it is activated, Tasmota will not publish MQTT messages, but it will proccess event trigger rules

View File

@ -566,7 +566,8 @@ bool MqttPublishLib(const char* topic, const uint8_t* payload, unsigned int plen
MqttClient.endPublish();
yield(); // #3313
// yield(); // #3313
delay(0);
return true;
}