Skip to content

Commit cd3a2a0

Browse files
committed
adaptative MQTT MAX PACKET SIZE
change mqtt max packet size depending on the board and display the value on serial monitor
1 parent ace5fe7 commit cd3a2a0

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

OpenMQTTGateway.ino

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@
111111
#endif
112112
// array to store previous received RFs, IRs codes and their timestamps
113113
#if defined(ESP8266) || defined(ESP32)
114+
#define MQTT_MAX_PACKET_SIZE 1024
114115
#define array_size 12
115116
unsigned long ReceivedSignal[array_size][2] ={{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}};
116117
#else
@@ -239,25 +240,26 @@ void callback(char* topic, byte* payload, unsigned int length) {
239240

240241
void setup()
241242
{
243+
//Launch serial for debugging purposes
244+
Serial.begin(SERIAL_BAUD);
245+
242246
#if defined(ESP8266) || defined(ESP32)
243-
//Launch serial for debugging purposes
244-
#if defined(ZgatewaySRFB) || defined(ESP32)
245-
Serial.begin(SERIAL_BAUD); // in the case of sonoff RF Bridge the link to the RF emitter/receiver is made by serial and need TX/RX
246-
#else
247+
#ifdef ESP8266
248+
Serial.end();
247249
Serial.begin(SERIAL_BAUD, SERIAL_8N1, SERIAL_TX_ONLY);
248250
#endif
249251
#if defined(ESP8266) && !defined(ESPWifiManualSetup)
250252
setup_wifimanager();
251253
#else // ESP32 case we don't use Wifi manager yet
252254
setup_wifi();
253255
#endif
254-
256+
255257
trc(F("OpenMQTTGateway mac: "));
256258
trc(WiFi.macAddress());
257-
259+
258260
trc(F("OpenMQTTGateway ip: "));
259261
trc(WiFi.localIP().toString());
260-
262+
261263
// Port defaults to 8266
262264
ArduinoOTA.setPort(ota_port);
263265

@@ -375,6 +377,10 @@ void setup()
375377
#ifdef ZsensorGPIOInput
376378
setupGPIOInput();
377379
#endif
380+
381+
trc(F("MQTT_MAX_PACKET_SIZE"));
382+
trc(MQTT_MAX_PACKET_SIZE);
383+
trc(F("Setup OpenMQTTGateway end"));
378384
}
379385

380386

config_IR.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
#define repeatIRwMQTT false // do we repeat a received signal by using mqtt
4040
#define RawDirectForward false // direct repeat of IR signal with raw data
4141
#define RawFrequency 38 // raw frequency sending
42-
//#define DumpMode true // uncomment so as to see big dumps of IR codes, put also #define MQTT_MAX_PACKET_SIZE 1024 into the library pubsubclient.h by instead of #define MQTT_MAX_PACKET_SIZE 128
42+
//#define DumpMode true // uncomment so as to see big dumps of IR codes
4343

4444
#define pubIRunknownPrtcl false // key to avoid mqtt publication of unknown IR protocol (set to true if you want to publish unknown protocol)
4545
#define PanasonicAddress 0x4004 // Panasonic address (Pre data)

0 commit comments

Comments
 (0)