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.
This commit is contained in:
Yalu Zhang 2021-12-20 16:37:38 +01:00 committed by Amin Ben Ramdhane
parent 6b1d67e6ec
commit c9955fdd9f

View file

@ -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;