Reputation: 2334
I am unable to send messages over a certain limit. I have looked at the docs and have already tried to redefine the max packet size:
#define MQTT_MAX_PACKET_SIZE 512
I've even tried increasing the limit to ridiculous limits and still the message is ignored. The size of my message is 253 characters in compressed JSON format:
{ "code_gc": [ 38000,1,69,342,171,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,63,21,21,21,21,21,21,21,63,21,63,21,63,21,63,21,63,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,63,21,63,21,63,21,1829,342,85,21,3663 ] }
It's an IR remote for anyone wondering what I'm building.
Does anyone have any ideas on what I should do to allow this message through? My only thought now is to scrap MQTT and create a REST server, which I don't want to do as MQTT is a lot faster in my experience..
Upvotes: 3
Views: 2887
Reputation: 1156
To change this value you can use this two solution
first, define MQTT_MAX_PACKET_SIZE
before including SubPubClient
this code in SubPubClint.h
, case prioritize your define variable
#ifndef MQTT_MAX_PACKET_SIZE
#define MQTT_MAX_PACKET_SIZE 255
#endif
second, and better solution is use this function to reset buffer size (default value is 255)
boolean PubSubClient::setBufferSize(uint16_t size)
like it :
mqtt.setBufferSize(newBufferValue);
Upvotes: 1
Reputation: 2334
As I was advised by the repository owner of PubSubClient
, I needed to change the MQTT_MAX_PACKET_SIZE
inside the source file of PubSubClient
as it cannot be redefined.
This fixed my issue.
Upvotes: 2