Comments (3)
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.
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.
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)
- Reconnects every 4 hours HOT 2
- Sometimes payload are mixed up with topic. HOT 1
- Callback is not called when i am pubishing audio data in bytes.
- Intermittent delay of minutes between ESP publish and receipt by mosquitto in a pi HOT 1
- Anomolous performing when using along with I2S
- Issue while setting keep alive zero. HOT 2
- Bug in PubSubClient::connected HOT 1
- Retain Flag not working HOT 1
- receiving arbitrarily large messages HOT 1
- Use hostname for the MQTT broker IP HOT 2
- Library when subscribing to third topic won't connect to ethernet
- Connecting and running smoothly on mobile hotspot while rc=-2 on fiber broadband wifi router
- Future of this module HOT 7
- Reconnect Problem. HOT 11
- Different error on Ubuntu arduino ide from windows arduino ide.
- #error "This library only supports boards with an AVR, SAM, SAMD, NRF52 or STM32F4 processor." HOT 1
- Client.connected() does not return false if MQTT Broker Pc disconnects from Internet or local network. HOT 1
- Can't Connect to mqtt broker after including SPI.h
- When callback is registered to topic that contains underscore, the underscore is replaced with space HOT 1
- pubsub library not thread safe. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pubsubclient.