From 100e95f2cf6fcc8e983e0919c4c81a13206b0566 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Wed, 19 Oct 2022 10:44:08 +0200 Subject: [PATCH] Update xdrv_02_9_mqtt.ino --- .../tasmota_xdrv_driver/xdrv_02_9_mqtt.ino | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tasmota/tasmota_xdrv_driver/xdrv_02_9_mqtt.ino b/tasmota/tasmota_xdrv_driver/xdrv_02_9_mqtt.ino index 1d328d447..a4b8b08e2 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_02_9_mqtt.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_02_9_mqtt.ino @@ -522,11 +522,30 @@ bool MqttPublishLib(const char* topic, const uint8_t* payload, unsigned int plen // AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_MQTT "Connection lost or message too large")); return false; } + uint32_t written = MqttClient.write(payload, plength); if (written != plength) { AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_MQTT "Message too large")); return false; } +/* + // Solves #6525?? + const uint8_t* write_buf = payload; + uint32_t bytes_remaining = plength; + uint32_t bytes_to_write; + uint32_t written; + while (bytes_remaining > 0) { + bytes_to_write = (bytes_remaining > 256) ? 256 : bytes_remaining; + written = MqttClient.write(write_buf, bytes_to_write); + if (written != bytes_to_write) { + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_MQTT "Message too large")); + return false; + } + write_buf += written; + bytes_remaining -= written; + } +*/ + MqttClient.endPublish(); yield(); // #3313