From 1b9f52b1fcb12f7e32fc8b4a3b22d93e1e64b479 Mon Sep 17 00:00:00 2001 From: lucian Date: Sun, 7 Apr 2019 22:19:47 +0300 Subject: [PATCH] Fix publish_P return value --- src/PubSubClient.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/PubSubClient.cpp b/src/PubSubClient.cpp index 0fa420d..b1d338e 100755 --- a/src/PubSubClient.cpp +++ b/src/PubSubClient.cpp @@ -412,6 +412,7 @@ boolean PubSubClient::publish_P(const char* topic, const uint8_t* payload, unsig unsigned int i; uint8_t header; unsigned int len; + int expectedLength; if (!connected()) { return false; @@ -445,7 +446,9 @@ boolean PubSubClient::publish_P(const char* topic, const uint8_t* payload, unsig lastOutActivity = millis(); - return rc == tlen + 4 + plength; + expectedLength = 1 + llen + 2 + tlen + plength; + + return (rc == expectedLength); } boolean PubSubClient::beginPublish(const char* topic, unsigned int plength, boolean retained) {