message: Added functionality to toggle between ArduinoJson 5 and 6
diff: #include <ArduinoJson.h> //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];
  char mqtt_port[6] = "8080";
  -char blynk_token[33] = "YOUR_BLYNK_TOKEN";
  +char blynk_token[34] = "YOUR_BLYNK_TOKEN";
  //default custom static IP
  char static_ip[16] = "10.0.1.56";
  char static_gw[16] = "10.0.1.1";
  @@ -52,10 +55,17 @@ void setup() {
  std::unique_ptr<char[]> buf(new char[size]);
  configFile.readBytes(buf.get(), size);
  +#ifdef UseJsonV6
  + DynamicJsonDocument json(1024);
  + auto deserializeError = deserializeJson(json, buf.get());
  + serializeJson(json, Serial);
  + if ( ! deserializeError ) {
  +#else
  DynamicJsonBuffer jsonBuffer;
  JsonObject& json = jsonBuffer.parseObject(buf.get());
  json.printTo(Serial);
  if (json.success()) {
  +#endif
  Serial.println("\nparsed json");
  strcpy(mqtt_server, json["mqtt_server"]);
  @@ -64,17 +74,10 @@ void setup() {
  if (json["ip"]) {
  Serial.println("setting custom ip from config");
  - //static_ip = json["ip"];
  strcpy(static_ip, json["ip"]);
  strcpy(static_gw, json["gateway"]);
  strcpy(static_sn, json["subnet"]);
  - //strcat(static_ip, json["ip"]);
  - //static_gw = json["gateway"];
  - //static_sn = json["subnet"];
  Serial.println(static_ip);
  -/* Serial.println("converting ip");
  - IPAddress ip = ipFromCharArray(static_ip);
  - Serial.println(ip);*/
  } else {
  Serial.println("no custom ip in config");
  }
  @@ -154,8 +157,12 @@ void setup() {
  //save the custom parameters to FS
  if (shouldSaveConfig) {
  Serial.println("saving config");
  +#ifdef UseJsonV6
  + DynamicJsonDocument json(1024);
  +#else
  DynamicJsonBuffer jsonBuffer;
  JsonObject& json = jsonBuffer.createObject();
  +#endif
  json["mqtt_server"] = mqtt_server;
  json["mqtt_port"] = mqtt_port;
  json["blynk_token"] = blynk_token;
  @@ -169,8 +176,13 @@ void setup() {
  Serial.println("failed to open config file for writing");
  }
  - json.prettyPrintTo(Serial);
  +#ifdef UseJsonV6
  + serializeJson(json, Serial);
  + serializeJson(json, configFile);
  +#else
  + json.printTo(Serial);
  json.printTo(configFile);
  +#endif
  configFile.close();
  //end save
  }
  @@ -183,6 +195,4 @@ void setup() {
  void loop() {
  // put your main code here, to run repeatedly:
  -
  -
  }
  