Git Product home page Git Product logo

Comments (8)

256dpi avatar 256dpi commented on July 30, 2024

Actually this would also fix a serious bug as creating a String from the payload using String(payload) allocates another buffer with the exact copy.

from arduino-mqtt.

gibix avatar gibix commented on July 30, 2024

Is not very user friendly, but can be better!
You can add the sign if MQTTMessage in the readme or as comment in the examples?

from arduino-mqtt.

256dpi avatar 256dpi commented on July 30, 2024

What is not very user friendly? The current implementation or this proposed change?
Sorry, I read your answer now various times but still don't get it... 😄

This would be a breaking change and result in releasing a v2.

from arduino-mqtt.

gibix avatar gibix commented on July 30, 2024

Sorry for the language ;)
I'm saying that a lot's of arduino users may not be friendly with data structures and usually in the libraries are avoided, but if you don't want to hack the MQTTClient.h code I agree that use the MQTTMessage in the callback is the best way.
I suggest that in the readme we should add the structure description, like:

typedef struct {
    char * topic;
    char * payload;
    unsigned int length;
    boolean retained;
} MQTTMessage;

or in the examples as a comment.

from arduino-mqtt.

256dpi avatar 256dpi commented on July 30, 2024

Thanks for the clarifications.
I'm not yet fully convinced by my own idea, so I have to sleep on it again some time. ;)

I'll keep you updated.

from arduino-mqtt.

256dpi avatar 256dpi commented on July 30, 2024

Note to myself: To support multiple clients at the same time the signature could even be updated to something like this:

void messageReceived(MQTTMessage msg, MQTTClient* client) {
  Serial.print("incoming: ");
  Serial.print(msg.topic());
  Serial.print(" - ");
  Serial.print(msg.payload());
  Serial.println();
}

from arduino-mqtt.

sandeepmistry avatar sandeepmistry commented on July 30, 2024

Regarding #38 (comment), in general it would be nice to avoid pointers in the call back, as from my understanding most Arduino users aren't exposed to them.

from arduino-mqtt.

256dpi avatar 256dpi commented on July 30, 2024

Has been simplified in #59.

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.