diff --git a/dmtree/tr181/atm.c b/dmtree/tr181/atm.c index 1ed83a78..094bd960 100644 --- a/dmtree/tr181/atm.c +++ b/dmtree/tr181/atm.c @@ -203,21 +203,25 @@ static int get_atm_stats_pack_sent(char *refparam, struct dmctx *ctx, void *data return 0; } +/*#Device.ATM.Link.{i}.Enable!UCI:dsl/atm-device,@i-1/enabled*/ static int get_atm_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - *value = "true"; + *value = dmuci_get_value_by_section_fallback_def(((struct atm_args *)data)->atm_sec, "enabled", "1"); return 0; } static int set_atm_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) { + bool b; + switch (action) { case VALUECHECK: if (dm_validate_boolean(value)) return FAULT_9007; return 0; case VALUESET: - //TODO + string_to_bool(value, &b); + dmuci_set_value_by_section(((struct atm_args *)data)->atm_sec, "enabled", b ? "1" : "0"); return 0; } return 0; diff --git a/dmtree/tr181/ptm.c b/dmtree/tr181/ptm.c index 28f1102c..09603494 100644 --- a/dmtree/tr181/ptm.c +++ b/dmtree/tr181/ptm.c @@ -100,21 +100,25 @@ static int get_ptm_stats_pack_sent(char *refparam, struct dmctx *ctx, void *data return 0; } +/*#Device.PTM.Link.{i}.Enable!UCI:dsl/ptm-device,@i-1/enabled*/ static int get_ptm_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - *value = "true"; + *value = dmuci_get_value_by_section_fallback_def(((struct ptm_args *)data)->ptm_sec, "enabled", "1"); return 0; } static int set_ptm_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) { + bool b; + switch (action) { case VALUECHECK: if (dm_validate_boolean(value)) return FAULT_9007; return 0; case VALUESET: - //TODO + string_to_bool(value, &b); + dmuci_set_value_by_section(((struct ptm_args *)data)->ptm_sec, "enabled", b ? "1" : "0"); return 0; } return 0; diff --git a/json/tr181.json b/json/tr181.json index 0b3b2b21..2f7cc04b 100644 --- a/json/tr181.json +++ b/json/tr181.json @@ -17361,7 +17361,22 @@ "cwmp", "usp" ], - "datatype": "boolean" + "datatype": "boolean", + "mapping": [ + { + "type": "uci", + "uci": { + "file": "dsl", + "section": { + "type": "atm-device", + "index": "@i-1" + }, + "option": { + "name": "enabled" + } + } + } + ] }, "Status": { "type": "string", @@ -18235,7 +18250,22 @@ "cwmp", "usp" ], - "datatype": "boolean" + "datatype": "boolean", + "mapping": [ + { + "type": "uci", + "uci": { + "file": "dsl", + "section": { + "type": "ptm-device", + "index": "@i-1" + }, + "option": { + "name": "enabled" + } + } + } + ] }, "Status": { "type": "string",