Skip to content
Permalink
Browse files

net: lwm2m: implement begin/end processing for obj inst and resources

Implement put_begin/end calls for object instance and resource
processing in lwm2m_perform_read_op()

Signed-off-by: Michael Scott <mike@foundries.io>
  • Loading branch information...
mike-scott authored and nashif committed Aug 29, 2018
1 parent 90b0986 commit 24e63f129569966ba3030c980a4628bce3a7f2ba
Showing with 19 additions and 0 deletions.
  1. +19 −0 subsys/net/lib/lwm2m/lwm2m_engine.c
@@ -2779,6 +2779,14 @@ int lwm2m_perform_read_op(struct lwm2m_engine_obj *obj,
goto move_forward;
}

/* update the obj_inst_id as we move through the instances */
path->obj_inst_id = obj_inst->obj_inst_id;

if (path->level <= 1) {
/* start instance formatting */
engine_put_begin_oi(context->out, path);
}

for (index = 0; index < obj_inst->resource_count; index++) {
if (path->level > 2 &&
path->res_id != obj_inst->resources[index].res_id) {
@@ -2800,6 +2808,9 @@ int lwm2m_perform_read_op(struct lwm2m_engine_obj *obj,
} else if (!LWM2M_HAS_PERM(obj_field, LWM2M_PERM_R)) {
ret = -EPERM;
} else {
/* start resource formatting */
engine_put_begin_r(context->out, path);

/* perform read operation on this resource */
ret = lwm2m_read_handler(obj_inst, res,
obj_field, context);
@@ -2813,6 +2824,9 @@ int lwm2m_perform_read_op(struct lwm2m_engine_obj *obj,
} else {
num_read += 1;
}

/* end resource formatting */
engine_put_end_r(context->out, path);
}

/* on single read break if errors */
@@ -2825,6 +2839,11 @@ int lwm2m_perform_read_op(struct lwm2m_engine_obj *obj,
}

move_forward:
if (path->level <= 1) {
/* end instance formatting */
engine_put_end_oi(context->out, path);
}

if (path->level <= 1) {
/* advance to the next object instance */
obj_inst = next_engine_obj_inst(path->obj_id,

0 comments on commit 24e63f1

Please sign in to comment.
You can’t perform that action at this time.