use common buffer
This commit is contained in:
@@ -8,7 +8,6 @@
|
|||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
#include "RestartReason.h"
|
#include "RestartReason.h"
|
||||||
#include "networkDevices/EthLan8720Device.h"
|
#include "networkDevices/EthLan8720Device.h"
|
||||||
#include "CharBuffer.h"
|
|
||||||
|
|
||||||
Network* Network::_inst = nullptr;
|
Network* Network::_inst = nullptr;
|
||||||
unsigned long Network::_ignoreSubscriptionsTs = 0;
|
unsigned long Network::_ignoreSubscriptionsTs = 0;
|
||||||
@@ -601,7 +600,7 @@ void Network::publishHASSConfig(char* deviceType, const char* baseTopic, char* n
|
|||||||
json["stat_unlocked"] = unlockedState;
|
json["stat_unlocked"] = unlockedState;
|
||||||
json["opt"] = "false";
|
json["opt"] = "false";
|
||||||
|
|
||||||
serializeJson(json, reinterpret_cast<char(&)[CHAR_BUFFER_SIZE]>(*_buffer));
|
serializeJson(json, _buffer, _bufferSize);
|
||||||
|
|
||||||
String path = discoveryTopic;
|
String path = discoveryTopic;
|
||||||
path.concat("/lock/");
|
path.concat("/lock/");
|
||||||
@@ -984,7 +983,7 @@ void Network::publishHassTopic(const String& mqttDeviceType,
|
|||||||
|
|
||||||
if (discoveryTopic != "")
|
if (discoveryTopic != "")
|
||||||
{
|
{
|
||||||
DynamicJsonDocument json(CHAR_BUFFER_SIZE);
|
DynamicJsonDocument json(_bufferSize);
|
||||||
|
|
||||||
// Battery level
|
// Battery level
|
||||||
json.clear();
|
json.clear();
|
||||||
@@ -1021,7 +1020,7 @@ void Network::publishHassTopic(const String& mqttDeviceType,
|
|||||||
json[entry.first] = entry.second;
|
json[entry.first] = entry.second;
|
||||||
}
|
}
|
||||||
|
|
||||||
serializeJson(json, reinterpret_cast<char (&)[JSON_BUFFER_SIZE]>(*_buffer));
|
serializeJson(json, _buffer, _bufferSize);
|
||||||
|
|
||||||
String path = discoveryTopic;
|
String path = discoveryTopic;
|
||||||
path.concat("/");
|
path.concat("/");
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ private:
|
|||||||
long _rssiPublishInterval = 0;
|
long _rssiPublishInterval = 0;
|
||||||
|
|
||||||
char* _buffer;
|
char* _buffer;
|
||||||
size_t _bufferSize;
|
const size_t _bufferSize;
|
||||||
|
|
||||||
std::function<void()> _keepAliveCallback = nullptr;
|
std::function<void()> _keepAliveCallback = nullptr;
|
||||||
std::vector<std::function<void()>> _reconnectedCallbacks;
|
std::vector<std::function<void()>> _reconnectedCallbacks;
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
#include "PreferencesKeys.h"
|
#include "PreferencesKeys.h"
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
#include "RestartReason.h"
|
#include "RestartReason.h"
|
||||||
#include "CharBuffer.h"
|
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
|
|
||||||
NetworkLock::NetworkLock(Network* network, Preferences* preferences, char* buffer, size_t bufferSize)
|
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);
|
publishString(mqtt_topic_lock_log, _buffer);
|
||||||
|
|
||||||
if(authFound)
|
if(authFound)
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
#include "PreferencesKeys.h"
|
#include "PreferencesKeys.h"
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
#include "CharBuffer.h"
|
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
|
|
||||||
NetworkOpener::NetworkOpener(Network* network, Preferences* preferences, char* buffer, size_t bufferSize)
|
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];
|
char authName[33];
|
||||||
memset(authName, 0, sizeof(authName));
|
memset(authName, 0, sizeof(authName));
|
||||||
|
|
||||||
DynamicJsonDocument json(CHAR_BUFFER_SIZE);
|
DynamicJsonDocument json(_bufferSize);
|
||||||
|
|
||||||
for(const auto& log : logEntries)
|
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);
|
publishString(mqtt_topic_lock_log, _buffer);
|
||||||
|
|
||||||
if(authFound)
|
if(authFound)
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ private:
|
|||||||
uint8_t _queryCommands = 0;
|
uint8_t _queryCommands = 0;
|
||||||
|
|
||||||
char* _buffer;
|
char* _buffer;
|
||||||
size_t _bufferSize;
|
const size_t _bufferSize;
|
||||||
|
|
||||||
bool (*_lockActionReceivedCallback)(const char* value) = nullptr;
|
bool (*_lockActionReceivedCallback)(const char* value) = nullptr;
|
||||||
void (*_configUpdateReceivedCallback)(const char* path, const char* value) = nullptr;
|
void (*_configUpdateReceivedCallback)(const char* path, const char* value) = nullptr;
|
||||||
|
|||||||
Reference in New Issue
Block a user