Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SYS] Fix ESP8266 discovery publications #2100

Merged
merged 1 commit into from
Nov 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions main/User_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,14 @@
#ifndef JSON_MSG_BUFFER
# if defined(ESP32)
# define JSON_MSG_BUFFER 1024 // adjusted to minimum size covering largest home assistant discovery messages
# if MQTT_SECURE_DEFAULT
# define JSON_MSG_BUFFER_MAX 2048 // Json message buffer size increased to handle certificate changes through MQTT, used for the queue and the coming MQTT messages
# else
# define JSON_MSG_BUFFER_MAX 1024 // Minimum size for the cover MQTT discovery message
# endif
# elif defined(ESP8266)
# define JSON_MSG_BUFFER 512 // Json message max buffer size, don't put 768 or higher it is causing unexpected behaviour on ESP8266, certificates handling with ESP8266 is not tested
# endif
# if MQTT_SECURE_DEFAULT
# define JSON_MSG_BUFFER_MAX 2048 // Json message buffer size increased to handle certificate changes through MQTT, used for the queue and the coming MQTT messages
# else
# define JSON_MSG_BUFFER_MAX 1024 // Minimum size for the cover MQTT discovery message
# define JSON_MSG_BUFFER 512 // Json message max buffer size, don't put 768 or higher it is causing unexpected behaviour on ESP8266, certificates handling with ESP8266 is not tested
# define JSON_MSG_BUFFER_MAX 832 // Minimum size for MQTT discovery message
# endif
#endif

Expand Down
2 changes: 1 addition & 1 deletion main/ZmqttDiscovery.ino
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ void createDiscovery(const char* sensor_type,
const char* payload_available, const char* payload_not_available, bool gateway_entity, const char* cmd_topic,
const char* device_name, const char* device_manufacturer, const char* device_model, const char* device_id, bool retainCmd,
const char* state_class, const char* state_off, const char* state_on, const char* enum_options, const char* command_template) {
StaticJsonDocument<JSON_MSG_BUFFER_MAX> jsonBuffer;
StaticJsonDocument<JSON_MSG_BUFFER> jsonBuffer;
JsonObject sensor = jsonBuffer.to<JsonObject>();

// If a component cannot render it's state (f.i. KAKU relays) no state topic
Expand Down
2 changes: 1 addition & 1 deletion main/main.ino
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ void emptyQueue() {
return;
}
Log.trace(F("Dequeue JSON" CR));
DynamicJsonDocument jsonBuffer(JSON_MSG_BUFFER);
DynamicJsonDocument jsonBuffer(JSON_MSG_BUFFER_MAX);
JsonObject obj = jsonBuffer.to<JsonObject>();
#ifdef ESP32
if (xSemaphoreTake(xQueueMutex, pdMS_TO_TICKS(QueueSemaphoreTimeOutTask)) == pdFALSE) {
Expand Down