use common buffer

This commit is contained in:
technyon
2023-03-22 23:15:38 +01:00
parent 04ebf17b1a
commit 8e6b464563
5 changed files with 8 additions and 11 deletions

View File

@@ -8,7 +8,6 @@
#include <ArduinoJson.h>
#include "RestartReason.h"
#include "networkDevices/EthLan8720Device.h"
#include "CharBuffer.h"
Network* Network::_inst = nullptr;
unsigned long Network::_ignoreSubscriptionsTs = 0;
@@ -601,7 +600,7 @@ void Network::publishHASSConfig(char* deviceType, const char* baseTopic, char* n
json["stat_unlocked"] = unlockedState;
json["opt"] = "false";
serializeJson(json, reinterpret_cast<char(&)[CHAR_BUFFER_SIZE]>(*_buffer));
serializeJson(json, _buffer, _bufferSize);
String path = discoveryTopic;
path.concat("/lock/");
@@ -984,7 +983,7 @@ void Network::publishHassTopic(const String& mqttDeviceType,
if (discoveryTopic != "")
{
DynamicJsonDocument json(CHAR_BUFFER_SIZE);
DynamicJsonDocument json(_bufferSize);
// Battery level
json.clear();
@@ -1021,7 +1020,7 @@ void Network::publishHassTopic(const String& mqttDeviceType,
json[entry.first] = entry.second;
}
serializeJson(json, reinterpret_cast<char (&)[JSON_BUFFER_SIZE]>(*_buffer));
serializeJson(json, _buffer, _bufferSize);
String path = discoveryTopic;
path.concat("/");

View File

@@ -129,7 +129,7 @@ private:
long _rssiPublishInterval = 0;
char* _buffer;
size_t _bufferSize;
const size_t _bufferSize;
std::function<void()> _keepAliveCallback = nullptr;
std::vector<std::function<void()>> _reconnectedCallbacks;

View File

@@ -5,7 +5,6 @@
#include "PreferencesKeys.h"
#include "Logger.h"
#include "RestartReason.h"
#include "CharBuffer.h"
#include <ArduinoJson.h>
NetworkLock::NetworkLock(Network* network, Preferences* preferences, char* buffer, size_t bufferSize)
@@ -364,7 +363,7 @@ void NetworkLock::publishAuthorizationInfo(const std::list<NukiLock::LogEntry>&
}
}
serializeJson(json, reinterpret_cast<char(&)[CHAR_BUFFER_SIZE]>(*_buffer));
serializeJson(json, _buffer, _bufferSize);
publishString(mqtt_topic_lock_log, _buffer);
if(authFound)

View File

@@ -4,7 +4,6 @@
#include "PreferencesKeys.h"
#include "Logger.h"
#include "Config.h"
#include "CharBuffer.h"
#include <ArduinoJson.h>
NetworkOpener::NetworkOpener(Network* network, Preferences* preferences, char* buffer, size_t bufferSize)
@@ -272,7 +271,7 @@ void NetworkOpener::publishAuthorizationInfo(const std::list<NukiOpener::LogEntr
char authName[33];
memset(authName, 0, sizeof(authName));
DynamicJsonDocument json(CHAR_BUFFER_SIZE);
DynamicJsonDocument json(_bufferSize);
for(const auto& log : logEntries)
{
@@ -375,7 +374,7 @@ void NetworkOpener::publishAuthorizationInfo(const std::list<NukiOpener::LogEntr
}
}
serializeJson(json, reinterpret_cast<char(&)[CHAR_BUFFER_SIZE]>(*_buffer));
serializeJson(json, _buffer, _bufferSize);
publishString(mqtt_topic_lock_log, _buffer);
if(authFound)

View File

@@ -84,7 +84,7 @@ private:
uint8_t _queryCommands = 0;
char* _buffer;
size_t _bufferSize;
const size_t _bufferSize;
bool (*_lockActionReceivedCallback)(const char* value) = nullptr;
void (*_configUpdateReceivedCallback)(const char* path, const char* value) = nullptr;