Git Product home page Git Product logo

Comments (10)

256dpi avatar 256dpi commented on July 16, 2024 2

I just released a new version with the new methods included. The duplicated ID is now cleared after every publish, successful or not.

from arduino-mqtt.

gonzabrusco avatar gonzabrusco commented on July 16, 2024

Just a follow up. If you think that storing the last message ID sent per topic is too costly. It would be nice to atleast have another onpublish method like this:

bool publish(const String &topic, const String &payload, bool retained, int qos, unsigned int * messageId, bool duplicate)

The function can return true if the publish was successful or false if it failed. But also it can inform the user the message ID used for publishing that message storing it in the pointer messageID passed. Then my program could be sent again the same message passing duplicate to TRUE and the message ID.

What do you think?

from arduino-mqtt.

gonzabrusco avatar gonzabrusco commented on July 16, 2024

256dpi/lwmqtt#16

I have created a pull request adding this functionality to lwmqtt first.

from arduino-mqtt.

256dpi avatar 256dpi commented on July 16, 2024

I added the experimental methods uint16_t lastPacketID() and void prepareDuplicate(uint16_t packetID) to support this. I was reluctant to add further overloads of the publish() method with a *dup_id parameter (as in lwmqtt) and opted for this simpler design. Most users of this library do not care for this functionality and ones that do, have now a way to do it. Let me know what you think. Here is the documentation from the Readme:


Obtain the last used packet ID and prepare the publication of a duplicate message using the specified packet ID:

uint16_t lastPacketID();
void prepareDuplicate(uint16_t packetID);
  • These functions may be used to implement a retry logic for failed publications of QoS1 and QoS2 messages.
  • The lastPacketID() function can be used after calling publish() to obtain the used packet ID.
  • The prepareDuplicate() function may be called before publish() to temporarily change the next used packet ID and flag the message as a duplicate.

from arduino-mqtt.

gonzabrusco avatar gonzabrusco commented on July 16, 2024

Hi @256dpi the duplicate logic seems to be working fine. Thanks.

One thing I noticed is the following, if I use dropOverflow(true) when a very big message arrives, mqtt disconnects. Is that normal? Shouldn't it just ignore the package without disconnecting?

from arduino-mqtt.

256dpi avatar 256dpi commented on July 16, 2024

Thanks for the feedback! No, the client should not disconnect. On such an error loop() should return false and the error can be obtained using lastError(). What does it say?

from arduino-mqtt.

gonzabrusco avatar gonzabrusco commented on July 16, 2024

LWMQTT_BUFFER_TOO_SHORT

from arduino-mqtt.

gonzabrusco avatar gonzabrusco commented on July 16, 2024

Hi @256dpi I think I have a "kind of bug" in the way the duplicate is handled.

If you use the new function prepareDuplicate(duplicateID) it will publish as duplicate OK. But internally, it will not reset the class variable nextDupPacketID after publishing, thus every packet published afterwars will be marked as duplicate with the same ID unless you call prepareDuplicate(0) . Maybe it should be a good idea to reset nextDupPacketID after publish (successful or not)?

from arduino-mqtt.

256dpi avatar 256dpi commented on July 16, 2024

Yes that makes sense. I'll see if I find time to fix that this week.

from arduino-mqtt.

Decezaris avatar Decezaris commented on July 16, 2024

Any news about it?

from arduino-mqtt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.