Skip to content

3.0.0

Latest

Choose a tag to compare

@tyeth tyeth released this 11 Nov 18:40
75008b9

What's Changed

  1. Add dynamic memory allocation for library buffers by @brentru in #243

Larger buffer size is now supported, via a new optional last constructor argument (maxBufferSz).
Note:

  • Backward-compatible with existing API, defaults to existing buffer sizes
  • Both Adafruit_MQTT and Adafruit_MQTT_Subscribe will attempt to first allocate using PSRAM (if avaliable) and fall back to heap-based allocation.
  • For subscriptions - we ensure the buffer is large enough for the expected payload.
  • Updated functions which handle MQTT packets to use the allocated buffer size instead of static variables
  • Added error handling for memory allocation failures.

Example Call:

These changes allow buffer sizes to be configured in code, and compiled prior to runtime.:

#define BUFFER_LEN 2048 // 2048-byte buffer
// Initialize a new MQTT client with a 2048-byte buffer
Adafruit_MQTT_Client mqtt(&client, MQTT_SERVER, MQTT_SERVER_PORT, "", USER, PASS, BUFFER_LEN);

Full Changelog: 2.6.6...3.0.0