Key-Value based Configurations

This examples shows how to use configuration service without JSON deserialization. You could simply get each parameter by fetching it with its path.
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 all parameters into an object and then extracts the required parameters individually.

// define key-value object in global
int speed = 100;
char alarm_num[64];
char alarm_msg1[64];
char alarm_msg2[64];
...
// download configs
if(otadrive_downloadConfigValues())
{
    ESP_LOGI("Configs downloaded");
    // lets decode and save config values
    char n_buf[10];
    if(otadrive_getConfigValue("speed", n_buf, sizeof(n_buf)))
    {
        ESP_LOGI("configuration parameter [speed]: %s\n", n_buf);
        speed = atoi(n_buf);
    }
    if(otadrive_getConfigValue("alarm.number", alarm_num, sizeof(alarm_num)))
        ESP_LOGI("configuration parameter [alarm.number]: %s\n", alarm_num);
    if(otadrive_getConfigValue("alarm.msg1", alarm_msg1, sizeof(alarm_msg1)))
        ESP_LOGI("configuration parameter [alarm.msg1]: %s\n", alarm_msg1);
    if(otadrive_getConfigValue("alarm.msg2", alarm_msg2, sizeof(alarm_msg2)))
        ESP_LOGI("configuration parameter [alarm.msg2]: %s\n", alarm_msg2);
}