From 3221a1e8e703f94593c021c3434e135d05797f57 Mon Sep 17 00:00:00 2001 From: Markus Rekdal Date: Thu, 1 Jul 2021 10:58:43 +0200 Subject: [PATCH] net: lwm2m: Fix handling of multi instance resources with one instance This will fix a bug caused by creating a multi instance resource with only a single resource. Previously this was treated as a single instance resource. This is now properly treated as a multi instance resource with one instance Signed-off-by: Markus Rekdal --- subsys/net/lib/lwm2m/lwm2m_engine.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/subsys/net/lib/lwm2m/lwm2m_engine.c b/subsys/net/lib/lwm2m/lwm2m_engine.c index aa3a5f50d2c..fca6133e7aa 100644 --- a/subsys/net/lib/lwm2m/lwm2m_engine.c +++ b/subsys/net/lib/lwm2m/lwm2m_engine.c @@ -2299,7 +2299,7 @@ static int lwm2m_read_handler(struct lwm2m_engine_obj_inst *obj_inst, } loop_max = res->res_inst_count; - if (loop_max > 1) { + if (res->multi_res_inst) { /* search for valid resource instances */ for (i = 0; i < loop_max; i++) { if (res->res_instances[i].res_inst_id != @@ -2427,7 +2427,7 @@ static int lwm2m_read_handler(struct lwm2m_engine_obj_inst *obj_inst, } } - if (res->res_inst_count > 1) { + if (res->multi_res_inst) { engine_put_end_ri(&msg->out, &msg->path); msg->path.res_inst_id = res_inst_id_tmp; }