Skip to content

Commit

Permalink
[SYS] Fix ESP8266 discovery publications
Browse files Browse the repository at this point in the history
  • Loading branch information
1technophile committed Nov 9, 2024
1 parent e2641f4 commit a5ad8e4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
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

0 comments on commit a5ad8e4

Please sign in to comment.