adafruit / Adafruit_MQTT_Library

Arduino library for MQTT support
MIT License
571 stars 292 forks source link

QOS response #131

Open nilz90 opened 5 years ago

nilz90 commented 5 years ago

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?

axelmagnus commented 5 years ago

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