GithubHelp home page GithubHelp logo

Comments (6)

scaprile avatar scaprile commented on July 22, 2024 1

Make sure your topicString[0] is a MQTTString
Execute your code step by step and pinpoint where your payload is trashed.
Remember memcpy() belongs to your system.

from paho.mqtt.embedded-c.

scaprile avatar scaprile commented on July 22, 2024 1

Execute your code step by step and pinpoint where your payload is trashed.
Remember memcpy() belongs to your system.

If you do find something in the code, I'll be happy to help (maybe others too)

from paho.mqtt.embedded-c.

scaprile avatar scaprile commented on July 22, 2024

MQTTSerialize_publish() just calls memcpy(), it does not modify your payload; see source code.
Is it the header you see is not OK ? How ? What do you do, how do you call this function, what do you see, do you actually have enough free memory where your pointer points to ? What have you checked, have you stepped the code ?
MQTT msg length can be encoded in with a different number of bytes and handle up to 256MB; the actual system memory limits will mostly come first.

from paho.mqtt.embedded-c.

hakam00ra avatar hakam00ra commented on July 22, 2024

This is how i call the function

unsigned char bufm[1500];
int bufmlen = sizeof(bufm);
rc = MQTTSerialize_publish(bufm, sizeof(bufm), dup, qos, retained, msgid, topicString[0], message, messageLen);

I get this in my console for a particular payload:

messageLen=580
sizeof bufm=1500
rc=600

The payload (bufm) is transmitted fine.

For a different payload:

messageLen=638 
sizeof bufm=1500
rc=658

And since the payload is larger than 600 bytes the payload (bufm) is now only 19 bytes and only contains some parts of the message array.
Notice how the rc is correct on both occasions.

Also there is enough memory where my pointer points to unsigned char bufm[1500];

thanks

from paho.mqtt.embedded-c.

hakam00ra avatar hakam00ra commented on July 22, 2024

yup.....
It was a stack issue. My pointer was pointing to the stack...
Sorry and thanks for the help.

from paho.mqtt.embedded-c.

scaprile avatar scaprile commented on July 22, 2024

Please close the issue, the moderator is busy

from paho.mqtt.embedded-c.

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.