JSON Configurations

This examples shows how to use configuration service with JSON deserialization. You could get json object of the configurations from the server as a string, then pars the parameters one by one.
You can find the example here or download full examples files.

Download Settings

First define this JSON object in your product and assign to the group of your device.

{
    "speed":180,
    "alarm":{
        "number":"+188554436",
        "msg1":"Fire, please help",
        "msg2":"Emergency, please help"
    }
}

Alt text

The code below downloads the json configurations into a string and then extracts the required parameters individually.

#include <ArduinoJson.h>
int speed = 100;
String alarm_num;
String alarm_msg1;

// get latest config
String payload = OTADRIVE.getJsonConfigs();
DynamicJsonDocument doc(512);
deserializeJson(doc, payload);

// extract values
if (doc.containsKey("speed"))
  speed = doc["speed"].as<int>();

if (doc.containsKey("alarm"))
{
  if (doc["alarm"].containsKey("number"))
    alarm_num = doc["alarm"]["number"].as<String>();

  if (doc["alarm"].containsKey("msg1"))
    alarm_msg1 = doc["alarm"]["msg1"].as<String>();
}

Final Result