Coder Social home page Coder Social logo

Comments (3)

knolleary avatar knolleary commented on May 29, 2024

Hi, normally you would fork this repository, make your changes there and then open a pull request so I can review the code before merging or otherwise.

I currently use a uint16 for the packet length. This allows a Max message size of 65535 bytes. As this is stored in memory, a message of this size is already beyond the capabilities of the arduino - increasing this to uint64, whilst technically correct from a spec point of view, seems pointless for the platform.

Do you have a specific requirement to increase this limit?

Not sure what you mean by 'removed it from the buffer altogether'. Either provide a pull request or, if the changes are not too big, paste in here.

Do you have a particular need for >

from pubsubclient.

GreyCon avatar GreyCon commented on May 29, 2024

Hi Nick,
yes, I agree the uint16 is more than sufficient for the Arduino platform.
I only need 1000 byte messages myself. The issue is that the code fails on
messages where the combined topic and payload exceed 127 bytes. Consider an
incoming message on topic "TimerCommands", with a 113 byte payload. The
incoming bytes from the broker are:

MsgType: $30
Remaining Packet Length: $80 $01 (128 encoded over 2 bytes)
Topic Length: $00 $0d
Topic: 'TimerCommands'
Payload: ... 113 bytes.

Now, this code:

uint16_t PubSubClient::readPacket() {
uint16_t len = 0;
buffer[len++] = readByte();
uint8_t multiplier = 1;
uint16_t length = 0;
uint8_t digit = 0;
do {
digit = readByte();
* buffer[len++] = digit;*
length += (digit & 127) * multiplier;
multiplier *= 128;
} while ((digit & 128) != 0);

Encodes the 2 byte packet length into buffer[1] and buffer[2].

Later, when doing the callback, this code fails, because it assumes the
Topic Length starts at buffer[2] ;

if (type == MQTTPUBLISH) {
if (callback) {
uint16_t tl = (buffer[2]<<8)+buffer[3];
char topic[tl+1];
for (uint16_t i=0;i<tl;i++) {
topic[i] = buffer[4+i];
}
topic[tl] = 0;

I fixed this by not inserting the packet length into the buffer variable at
all, since you return this from the readpacket method anyway.

Perhaps I have an old version of the code?

Do you want me to do a pull request so you can see the changes?

By the way, many thanks for the client, you've saved me a heap of
development time.

Cheers,
Con

On Fri, Jan 3, 2014 at 6:12 PM, knolleary [email protected] wrote:

Hi, normally you would fork this repository, make your changes there and
then open a pull request so I can review the code before merging or
otherwise.

I currently use a uint16 for the packet length. This allows a Max message
size of 65535 bytes. As this is stored in memory, a message of this size is
already beyond the capabilities of the arduino - increasing this to uint64,
whilst technically correct from a spec point of view, seems pointless for
the platform.

Do you have a specific requirement to increase this limit?

Not sure what you mean by 'removed it from the buffer altogether'. Either
provide a pull request or, if the changes are not too big, paste in here.

Do you have a particular need for >


Reply to this email directly or view it on GitHubhttps://github.com//issues/35#issuecomment-31541481
.

from pubsubclient.

knolleary avatar knolleary commented on May 29, 2024

That specific issue has already been fixed in the latest version of the code - it isn't in a formal release yet, but you can grab it from here: https://github.com/knolleary/pubsubclient/archive/master.zip

You also need to update MQTT_MAX_PACKET_SIZE in PubSubClient.h as documented here: http://knolleary.net/arduino-client-for-mqtt/api/#configoptions

That should get everything working for you.

from pubsubclient.

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.