From a74f7d64cff5fbf59e3e32945bf5ff3c4c042140 Mon Sep 17 00:00:00 2001 From: coolneng Date: Thu, 24 Apr 2025 16:15:36 +0200 Subject: [PATCH] Replace deprecated StaticJsonDocument type --- include/config.h | 2 +- src/config.cpp | 4 ++-- src/wlan.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/config.h b/include/config.h index 176e45d..df82916 100644 --- a/include/config.h +++ b/include/config.h @@ -18,7 +18,7 @@ typedef struct { int connection_attempts; } Config; -void initialize_config(Config *config, StaticJsonDocument<512> json); +void initialize_config(Config *config, JsonDocument json); bool load_config_file(const char *file_path, Config *config); diff --git a/src/config.cpp b/src/config.cpp index 9f10c59..e91148f 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -1,6 +1,6 @@ #include "config.h" -void initialize_config(Config *config, StaticJsonDocument<512> json) { +void initialize_config(Config *config, JsonDocument json) { config->ssid = strdup(json["ssid"]); config->psk = strdup(json["psk"]); config->mqtt_host = strdup(json["mqtt_host"]); @@ -19,7 +19,7 @@ bool load_config_file(const char *file_path, Config *config) { File config_file = LittleFS.open(file_path, "r"); if (!config_file) return false; - StaticJsonDocument<512> json; + JsonDocument json; DeserializationError err = deserializeJson(json, config_file); if (err) return false; diff --git a/src/wlan.cpp b/src/wlan.cpp index f05ea0c..8778f0b 100644 --- a/src/wlan.cpp +++ b/src/wlan.cpp @@ -39,7 +39,7 @@ void disconnect_mqtt(PubSubClient &client, const char *topic) { } size_t construct_json(float *data, char *buffer, int buffer_size) { - StaticJsonDocument<100> json; + JsonDocument json; json["temperature"] = data[0]; json["humidity"] = data[1]; size_t payload_size = serializeJson(json, buffer, buffer_size);