From 71593628237e962cc2de8f87680aa7bb7e19b294 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Fri, 5 Feb 2021 17:05:13 +0100 Subject: [PATCH] Fix long SwitchText message logging --- tasmota/support_command.ino | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tasmota/support_command.ino b/tasmota/support_command.ino index c79566c12..683808960 100644 --- a/tasmota/support_command.ino +++ b/tasmota/support_command.ino @@ -119,11 +119,18 @@ void ResponseCmndIdxError(void) { void ResponseCmndAll(uint32_t text_index, uint32_t count) { uint32_t real_index = text_index; ResponseClear(); + bool jsflg = false; for (uint32_t i = 0; i < count; i++) { if ((SET_MQTT_GRP_TOPIC == text_index) && (1 == i)) { real_index = SET_MQTT_GRP_TOPIC2 -1; } - ResponseAppend_P(PSTR("%c\"%s%d\":\"%s\""), (i) ? ',' : '{', XdrvMailbox.command, i +1, EscapeJSONString(SettingsText(real_index +i)).c_str()); + if ((ResponseAppend_P(PSTR("%c\"%s%d\":\"%s\""), (jsflg)?',':'{', XdrvMailbox.command, i +1, EscapeJSONString(SettingsText(real_index +i)).c_str()) > (MAX_LOGSZ - TOPSZ)) || (i == count -1)) { + ResponseJsonEnd(); + MqttPublishPrefixTopic_P(RESULT_OR_STAT, XdrvMailbox.command); + ResponseClear(); + jsflg = false; + } else { + jsflg = true; + } } - ResponseJsonEnd(); } /********************************************************************************************/