update espMqttclient
This commit is contained in:
@@ -100,7 +100,7 @@ Packet::Packet(espMqttClientTypes::Error& error,
|
||||
(password ? 2 + strlen(password) : 0);
|
||||
|
||||
// allocate memory
|
||||
if (!_allocate(remainingLength)) {
|
||||
if (!_allocate(remainingLength, false)) {
|
||||
error = espMqttClientTypes::Error::OUT_OF_MEMORY;
|
||||
return;
|
||||
}
|
||||
@@ -300,8 +300,8 @@ Packet::Packet(espMqttClientTypes::Error& error, MQTTPacketType type)
|
||||
}
|
||||
|
||||
|
||||
bool Packet::_allocate(size_t remainingLength) {
|
||||
if (EMC_GET_FREE_MEMORY() < EMC_MIN_FREE_MEMORY) {
|
||||
bool Packet::_allocate(size_t remainingLength, bool check) {
|
||||
if (check && EMC_GET_FREE_MEMORY() < EMC_MIN_FREE_MEMORY) {
|
||||
emc_log_w("Packet buffer not allocated: low memory");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -12,12 +12,12 @@ the LICENSE file.
|
||||
#include <stddef.h>
|
||||
|
||||
#include "Constants.h"
|
||||
#include "Config.h"
|
||||
#include "../Config.h"
|
||||
#include "../TypeDefs.h"
|
||||
#include "../Helpers.h"
|
||||
#include "../Logging.h"
|
||||
#include "RemainingLength.h"
|
||||
#include "String.h"
|
||||
#include "StringUtil.h"
|
||||
|
||||
namespace espMqttClientInternals {
|
||||
|
||||
@@ -97,7 +97,7 @@ class Packet {
|
||||
, _payloadStartIndex(0)
|
||||
, _payloadEndIndex(0)
|
||||
, _getPayload(nullptr) {
|
||||
static_assert(sizeof...(Args) % 2 == 0);
|
||||
static_assert(sizeof...(Args) % 2 == 0, "Subscribe should be in topic/qos pairs");
|
||||
size_t numberTopics = 2 + (sizeof...(Args) / 2);
|
||||
SubscribeItem list[numberTopics] = {topic1, qos1, topic2, qos2, args...};
|
||||
_createSubscribe(error, list, numberTopics);
|
||||
@@ -133,7 +133,7 @@ class Packet {
|
||||
|
||||
private:
|
||||
// pass remainingLength = total size - header - remainingLengthLength!
|
||||
bool _allocate(size_t remainingLength);
|
||||
bool _allocate(size_t remainingLength, bool check = true);
|
||||
|
||||
// fills header and returns index of next available byte in buffer
|
||||
size_t _fillPublishHeader(uint16_t packetId,
|
||||
|
||||
@@ -6,7 +6,7 @@ For a copy, see <https://opensource.org/licenses/MIT> or
|
||||
the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "String.h"
|
||||
#include "StringUtil.h"
|
||||
|
||||
namespace espMqttClientInternals {
|
||||
|
||||
Reference in New Issue
Block a user