From a6438edb3ce27e9bfebabba67f897021820c3e2f Mon Sep 17 00:00:00 2001 From: Ruan de Villiers Date: Wed, 15 Jan 2020 07:24:28 +0200 Subject: [PATCH] Auto check ArduinoJson rather than using a #define --- .../AutoConnectWithFSParameters.ino | 9 +++------ .../AutoConnectWithFSParametersAndCustomIP.ino | 9 +++------ 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/examples/AutoConnectWithFSParameters/AutoConnectWithFSParameters.ino b/examples/AutoConnectWithFSParameters/AutoConnectWithFSParameters.ino index f262901..c62ca7b 100644 --- a/examples/AutoConnectWithFSParameters/AutoConnectWithFSParameters.ino +++ b/examples/AutoConnectWithFSParameters/AutoConnectWithFSParameters.ino @@ -7,9 +7,6 @@ #include //https://github.com/bblanchon/ArduinoJson -//Comment out this line if you are still using ArduinoJsonV5 -#define UseJsonV6 - //define your default values here, if there are different values in config.json, they are overwritten. char mqtt_server[40]; char mqtt_port[6] = "8080"; @@ -49,7 +46,7 @@ void setup() { configFile.readBytes(buf.get(), size); -#ifdef UseJsonV6 +#ifdef ARDUINOJSON_VERSION_MAJOR >= 6 DynamicJsonDocument json(1024); auto deserializeError = deserializeJson(json, buf.get()); serializeJson(json, Serial); @@ -136,7 +133,7 @@ void setup() { //save the custom parameters to FS if (shouldSaveConfig) { Serial.println("saving config"); -#ifdef UseJsonV6 +#ifdef ARDUINOJSON_VERSION_MAJOR >= 6 DynamicJsonDocument json(1024); #else DynamicJsonBuffer jsonBuffer; @@ -151,7 +148,7 @@ void setup() { Serial.println("failed to open config file for writing"); } -#ifdef UseJsonV6 +#ifdef ARDUINOJSON_VERSION_MAJOR >= 6 serializeJson(json, Serial); serializeJson(json, configFile); #else diff --git a/examples/AutoConnectWithFSParametersAndCustomIP/AutoConnectWithFSParametersAndCustomIP.ino b/examples/AutoConnectWithFSParametersAndCustomIP/AutoConnectWithFSParametersAndCustomIP.ino index b29cfa7..e510a74 100644 --- a/examples/AutoConnectWithFSParametersAndCustomIP/AutoConnectWithFSParametersAndCustomIP.ino +++ b/examples/AutoConnectWithFSParametersAndCustomIP/AutoConnectWithFSParametersAndCustomIP.ino @@ -9,9 +9,6 @@ #include //https://github.com/bblanchon/ArduinoJson -//Comment out this line if you are still using ArduinoJsonV5 -#define UseJsonV6 - //define your default values here, if there are different values in config.json, they are overwritten. //length should be max size + 1 char mqtt_server[40]; @@ -55,7 +52,7 @@ void setup() { std::unique_ptr buf(new char[size]); configFile.readBytes(buf.get(), size); -#ifdef UseJsonV6 +#ifdef ARDUINOJSON_VERSION_MAJOR >= 6 DynamicJsonDocument json(1024); auto deserializeError = deserializeJson(json, buf.get()); serializeJson(json, Serial); @@ -157,7 +154,7 @@ void setup() { //save the custom parameters to FS if (shouldSaveConfig) { Serial.println("saving config"); -#ifdef UseJsonV6 +#ifdef ARDUINOJSON_VERSION_MAJOR >= 6 DynamicJsonDocument json(1024); #else DynamicJsonBuffer jsonBuffer; @@ -176,7 +173,7 @@ void setup() { Serial.println("failed to open config file for writing"); } -#ifdef UseJsonV6 +#ifdef ARDUINOJSON_VERSION_MAJOR >= 6 serializeJson(json, Serial); serializeJson(json, configFile); #else