From f7f6f2863c8f6a43551ad8fa4c4a5a45eb86d256 Mon Sep 17 00:00:00 2001 From: hjf Date: Thu, 1 Mar 2018 23:14:00 -0300 Subject: [PATCH] Support large packet publishing with ESP8266. --- Adafruit_MQTT_Client.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Adafruit_MQTT_Client.cpp b/Adafruit_MQTT_Client.cpp index e2ecc82..55bdf75 100644 --- a/Adafruit_MQTT_Client.cpp +++ b/Adafruit_MQTT_Client.cpp @@ -79,9 +79,14 @@ bool Adafruit_MQTT_Client::sendPacket(uint8_t *buffer, uint16_t len) { while (len > 0) { if (client->connected()) { + // send 250 bytes at most at a time, can adjust this later based on Client +#ifdef ESP8266 + uint16_t sendlen = len; //ESP8266's implementation can handle large packets by itself. +#else + uint16_t sendlen = len > 250 ? 250 : len; +#endif - uint16_t sendlen = len > 250 ? 250 : len; //Serial.print("Sending: "); Serial.println(sendlen); ret = client->write(buffer, sendlen); DEBUG_PRINT(F("Client sendPacket returned: ")); DEBUG_PRINTLN(ret);