correctly dump configuration so as to be able to restore to device

#61
This commit is contained in:
Jan-Piet Mens
2015-10-30 22:05:21 +01:00
parent 1704adade4
commit 9bacbb8726

View File

@@ -370,10 +370,23 @@ static void xx_dump(struct udata *ud, UT_string *username, UT_string *device, ch
if (pretty_js) free(pretty_js);
}
/* Dump a config payload */
/* Dump a config payload; get the 'configuration' element out of the dumped payloadstring */
void config_dump(struct udata *ud, UT_string *username, UT_string *device, char *payloadstring)
{
xx_dump(ud, username, device, payloadstring, "config", "otrc");
JsonNode *json = json_decode(payloadstring), *config;
if (json == NULL)
return;
if ((config = json_find_member(json, "configuration")) != NULL) {
char *js_string = json_stringify(config, NULL);
if (js_string) {
xx_dump(ud, username, device, js_string, "config", "otrc");
json_delete(json);
free(js_string);
}
}
}
/* Dump a waypoints (plural) payload */