From c9955fdd9ff5fd30345d0afae2635f0bd4264116 Mon Sep 17 00:00:00 2001 From: Yalu Zhang Date: Mon, 20 Dec 2021 16:37:38 +0100 Subject: [PATCH] TR-104: set the index of DECT.Portable. as per the 'id' from the ubus call Each DECT handset has its own 'id' value and this shall be used as the index of DECT.Portable object. Otherwise the index of the DECT.Portable. changes if the handset prior to it is deregistered. --- dmtree/tr104/servicesvoiceservicedect.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/dmtree/tr104/servicesvoiceservicedect.c b/dmtree/tr104/servicesvoiceservicedect.c index 8ea4f03d..69803ad0 100644 --- a/dmtree/tr104/servicesvoiceservicedect.c +++ b/dmtree/tr104/servicesvoiceservicedect.c @@ -54,8 +54,16 @@ static int browseServicesVoiceServiceDECTPortableInst(struct dmctx *dmctx, DMNOD int id = 0, i = 0; dmjson_foreach_obj_in_array(res, arrobj, obj, i, 1, "handsets") { + char *str_id = dmjson_get_value(obj, 1, "id"); - inst = handle_instance_without_section(dmctx, parent_node, ++id); + /* Use the id from the UBUS call if it is found */ + if (str_id && *str_id) { + id = atoi(str_id); + } else { + id++; + } + + inst = handle_instance_without_section(dmctx, parent_node, id); if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)obj, inst) == DM_STOP) break;