diff --git a/libbbfdm-api/dmapi.h b/libbbfdm-api/dmapi.h index f9988eee..3c41f773 100644 --- a/libbbfdm-api/dmapi.h +++ b/libbbfdm-api/dmapi.h @@ -122,7 +122,6 @@ typedef struct dm_leaf_s { int (*setvalue)(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action); int bbfdm_type; char version[10] __attribute__((deprecated)); - char *default_value; } DMLEAF; typedef struct dm_obj_s { diff --git a/libbbfdm-api/dmbbf.c b/libbbfdm-api/dmbbf.c index 0c4e2f4a..de690674 100644 --- a/libbbfdm-api/dmbbf.c +++ b/libbbfdm-api/dmbbf.c @@ -1419,10 +1419,7 @@ static int get_value_param(DMPARAM_ARGS) if (value && *value) { value = check_value_by_type(value, leaf->type); } else { - if (leaf->default_value) - value = check_value_by_type(leaf->default_value, leaf->type); - else - value = get_default_value_by_type(leaf->type); + value = get_default_value_by_type(leaf->type); } add_list_parameter(dmctx, full_param, value, DMT_TYPE[leaf->type], NULL); @@ -1467,10 +1464,7 @@ static int mparam_get_value_in_param(DMPARAM_ARGS) if (value && *value) { value = check_value_by_type(value, leaf->type); } else { - if (leaf->default_value) - value = check_value_by_type(leaf->default_value, leaf->type); - else - value = get_default_value_by_type(leaf->type); + value = get_default_value_by_type(leaf->type); } add_list_parameter(dmctx, full_param, value, DMT_TYPE[leaf->type], NULL); diff --git a/libbbfdm-api/plugin/json_plugin.c b/libbbfdm-api/plugin/json_plugin.c index 128b1f92..3350e899 100644 --- a/libbbfdm-api/plugin/json_plugin.c +++ b/libbbfdm-api/plugin/json_plugin.c @@ -851,11 +851,18 @@ end: static char *get_value_from_mapping(json_object *param_obj, int json_version, char *refparam, struct dmctx *ctx, void *data, char *instance) { - struct json_object *mapping_arr = NULL, *mapping = NULL; + struct json_object *mapping_arr = NULL, *mapping = NULL, *def_value = NULL; if (!param_obj) return ""; + // Check if default value option exists + json_object_object_get_ex(param_obj, "default", &def_value); + if (def_value) { + char *val = json_object_get_string(def_value); + return val ? dm_dynamic_strdup(&json_memhead, val) : ""; + } + json_object_object_get_ex(param_obj, "mapping", &mapping_arr); if (mapping_arr && json_object_get_type(mapping_arr) == json_type_array) { @@ -1605,7 +1612,7 @@ static char** fill_unique_keys(size_t count, struct json_object *obj) static void parse_param(char *object, char *param, json_object *jobj, DMLEAF *pleaf, int i, int json_version, struct list_head *list) { /* PARAM, permission, type, getvalue, setvalue, bbfdm_type(6)*/ - struct json_object *type = NULL, *protocols = NULL, *write = NULL, *async = NULL, *def_value = NULL; + struct json_object *type = NULL, *protocols = NULL, *write = NULL, *async = NULL; char full_param[512] = {0}; size_t n_proto; char **in_p = NULL, **out_p = NULL, **ev_arg = NULL, **tmp = NULL; @@ -1653,14 +1660,6 @@ static void parse_param(char *object, char *param, json_object *jobj, DMLEAF *pl pleaf[i].permission = (write && json_object_get_boolean(write)) ? &DMWRITE : &DMREAD; } - //default value - json_object_object_get_ex(jobj, "default", &def_value); - char *val = json_object_get_string(def_value); - if (val != NULL) - pleaf[i].default_value = dm_dynamic_strdup(&json_memhead, val); - else - pleaf[i].default_value = NULL; - //getvalue if (pleaf[i].type == DMT_EVENT) { int param_count = 0;