net: lwm2m: obj inst processing per formatter
It depends from a content formatter is there need to put constructs with a path level deeper than object instance. In other words with resource- or resource-instance-level. Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
This commit is contained in:
parent
4ea6fd4f20
commit
0032f0bcff
2 changed files with 15 additions and 12 deletions
|
@ -3366,13 +3366,10 @@ static int lwm2m_perform_read_object_instance(struct lwm2m_message *msg,
|
||||||
/* update the obj_inst_id as we move through the instances */
|
/* update the obj_inst_id as we move through the instances */
|
||||||
msg->path.obj_inst_id = obj_inst->obj_inst_id;
|
msg->path.obj_inst_id = obj_inst->obj_inst_id;
|
||||||
|
|
||||||
if (msg->path.level <= LWM2M_PATH_LEVEL_OBJECT) {
|
|
||||||
/* start instance formatting */
|
|
||||||
ret = engine_put_begin_oi(&msg->out, &msg->path);
|
ret = engine_put_begin_oi(&msg->out, &msg->path);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
for (int index = 0; index < obj_inst->resource_count; index++) {
|
for (int index = 0; index < obj_inst->resource_count; index++) {
|
||||||
if (msg->path.level > LWM2M_PATH_LEVEL_OBJECT_INST &&
|
if (msg->path.level > LWM2M_PATH_LEVEL_OBJECT_INST &&
|
||||||
|
@ -3429,13 +3426,10 @@ static int lwm2m_perform_read_object_instance(struct lwm2m_message *msg,
|
||||||
}
|
}
|
||||||
|
|
||||||
move_forward:
|
move_forward:
|
||||||
if (msg->path.level <= LWM2M_PATH_LEVEL_OBJECT) {
|
|
||||||
/* end instance formatting */
|
|
||||||
ret = engine_put_end_oi(&msg->out, &msg->path);
|
ret = engine_put_end_oi(&msg->out, &msg->path);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (msg->path.level <= LWM2M_PATH_LEVEL_OBJECT) {
|
if (msg->path.level <= LWM2M_PATH_LEVEL_OBJECT) {
|
||||||
/* advance to the next object instance */
|
/* advance to the next object instance */
|
||||||
|
|
|
@ -336,6 +336,11 @@ static int put_begin_oi(struct lwm2m_output_context *out,
|
||||||
{
|
{
|
||||||
struct tlv_out_formatter_data *fd;
|
struct tlv_out_formatter_data *fd;
|
||||||
|
|
||||||
|
/* No need for oi level TLV constructs */
|
||||||
|
if (path->level > LWM2M_PATH_LEVEL_OBJECT) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
fd = engine_get_out_user_data(out);
|
fd = engine_get_out_user_data(out);
|
||||||
if (!fd) {
|
if (!fd) {
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
@ -349,6 +354,10 @@ static int put_end_oi(struct lwm2m_output_context *out,
|
||||||
{
|
{
|
||||||
struct tlv_out_formatter_data *fd;
|
struct tlv_out_formatter_data *fd;
|
||||||
|
|
||||||
|
if (path->level > LWM2M_PATH_LEVEL_OBJECT) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
fd = engine_get_out_user_data(out);
|
fd = engine_get_out_user_data(out);
|
||||||
if (!fd) {
|
if (!fd) {
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue