Adafruit_MQTT_Library
Adafruit_MQTT_Library copied to clipboard
QOS response
-
Arduino board: ESP32 lolin32
-
Arduino IDE version : 1.8.5
Hey. In my code I want to make sure that the messages are really transmitted. So I put the MQTT_QOS_1 in it.
So to get a higher chance of publishing I use this code:
counter = 1;
ok = 0;
while ( counter <= 3 && ok == 0 ){
if (! Level.publish(level)){
counter ++;
Serial.print(F("Level failed "));
Serial.println(counter);
delay(2000);
} else {
ok = 1;
Serial.println(F("Level ok!"));
}
}
In some cases it can't fullfill the if loop. So I expected that no data is transmitted. But this is not true, in these cases I'll get 3 published messages on the broker.
Is this a good Idea in general? How can I improve the chance to get a positive feedback from the broker?
I changed in adafruit_MQTT.h from 500 to 800. i now get the correct QoS messages (before len=0, publish returned false, but it was transmitted):
#define PUBLISH_TIMEOUT_MS 800