Arduino Core 3 (#407)

* Add and remove libs and components for Arduino Core 3

* Arduino Core 3

* Add back Solo1

* Change ESP32-S3 to 4MB build

* Update README.md

* Fix retain and number of retries

* Fix rolling log

* Fix defaults

* Fix BleScanner on Solo1

* Export settings

* Import settings

* Fix HA Battery voltage

* Change submodule

* Update espMqttClient and AsyncTCP

* Webserial and MQTT/Network reconnecting

* Update nuki_ble

---------

Co-authored-by: iranl <iranl@github.com>
This commit is contained in:
iranl
2024-07-05 18:45:39 +02:00
committed by GitHub
parent 193ebb5f91
commit 6b0100fd61
236 changed files with 16390 additions and 9740 deletions

View File

@@ -10,8 +10,16 @@ the LICENSE file.
namespace espMqttClientInternals {
#if EMC_USE_MEMPOOL
MemoryPool::Variable<EMC_NUM_POOL_ELEMENTS, EMC_SIZE_POOL_ELEMENTS> Packet::_memPool;
#endif
Packet::~Packet() {
#if EMC_USE_MEMPOOL
_memPool.free(_data);
#else
free(_data);
#endif
}
size_t Packet::available(size_t index) {
@@ -178,7 +186,7 @@ Packet::Packet(espMqttClientTypes::Error& error,
_packetId = 0;
}
if (!_allocate(remainingLength)) {
if (!_allocate(remainingLength, true)) {
error = espMqttClientTypes::Error::OUT_OF_MEMORY;
return;
}
@@ -215,7 +223,7 @@ Packet::Packet(espMqttClientTypes::Error& error,
_packetId = 0;
}
if (!_allocate(remainingLength - payloadLength + std::min(payloadLength, static_cast<size_t>(EMC_RX_BUFFER_SIZE)))) {
if (!_allocate(remainingLength - payloadLength + std::min(payloadLength, static_cast<size_t>(EMC_RX_BUFFER_SIZE)), true)) {
error = espMqttClientTypes::Error::OUT_OF_MEMORY;
return;
}
@@ -251,7 +259,7 @@ Packet::Packet(espMqttClientTypes::Error& error, MQTTPacketType type, uint16_t p
, _payloadStartIndex(0)
, _payloadEndIndex(0)
, _getPayload(nullptr) {
if (!_allocate(2)) {
if (!_allocate(2, true)) {
error = espMqttClientTypes::Error::OUT_OF_MEMORY;
return;
}
@@ -290,7 +298,7 @@ Packet::Packet(espMqttClientTypes::Error& error, MQTTPacketType type)
, _payloadStartIndex(0)
, _payloadEndIndex(0)
, _getPayload(nullptr) {
if (!_allocate(0)) {
if (!_allocate(0, true)) {
error = espMqttClientTypes::Error::OUT_OF_MEMORY;
return;
}
@@ -301,12 +309,20 @@ Packet::Packet(espMqttClientTypes::Error& error, MQTTPacketType type)
bool Packet::_allocate(size_t remainingLength, bool check) {
#if EMC_USE_MEMPOOL
(void) check;
#else
if (check && EMC_GET_FREE_MEMORY() < EMC_MIN_FREE_MEMORY) {
emc_log_w("Packet buffer not allocated: low memory");
return false;
}
#endif
_size = 1 + remainingLengthLength(remainingLength) + remainingLength;
#if EMC_USE_MEMPOOL
_data = reinterpret_cast<uint8_t*>(_memPool.malloc(_size));
#else
_data = reinterpret_cast<uint8_t*>(malloc(_size));
#endif
if (!_data) {
_size = 0;
emc_log_w("Alloc failed (l:%zu)", _size);
@@ -357,7 +373,7 @@ void Packet::_createSubscribe(espMqttClientTypes::Error& error,
size_t remainingLength = 2 + payload; // packetId + payload
// allocate memory
if (!_allocate(remainingLength)) {
if (!_allocate(remainingLength, true)) {
error = espMqttClientTypes::Error::OUT_OF_MEMORY;
return;
}
@@ -387,7 +403,7 @@ void Packet::_createUnsubscribe(espMqttClientTypes::Error& error,
size_t remainingLength = 2 + payload; // packetId + payload
// allocate memory
if (!_allocate(remainingLength)) {
if (!_allocate(remainingLength, true)) {
error = espMqttClientTypes::Error::OUT_OF_MEMORY;
return;
}

View File

@@ -19,6 +19,10 @@ the LICENSE file.
#include "RemainingLength.h"
#include "StringUtil.h"
#if EMC_USE_MEMPOOL
#include "MemoryPool/src/MemoryPool.h"
#endif
namespace espMqttClientInternals {
class Packet {
@@ -133,7 +137,7 @@ class Packet {
private:
// pass remainingLength = total size - header - remainingLengthLength!
bool _allocate(size_t remainingLength, bool check = true);
bool _allocate(size_t remainingLength, bool check);
// fills header and returns index of next available byte in buffer
size_t _fillPublishHeader(uint16_t packetId,
@@ -150,6 +154,10 @@ class Packet {
size_t _chunkedAvailable(size_t index);
const uint8_t* _chunkedData(size_t index) const;
#if EMC_USE_MEMPOOL
static MemoryPool::Variable<EMC_NUM_POOL_ELEMENTS, EMC_SIZE_POOL_ELEMENTS> _memPool;
#endif
};
} // end namespace espMqttClientInternals