Skip to content

Commit c1e180b

Browse files
mike-scottjukkar
authored andcommitted
net: lwm2m: return NOT_FOUND for unused multi-value resources
When attempting to read an unused multi-value resource such as "Available Power Sources", lwm2m client return a successful coap packet w/o any values. This looks like a timeout to any lwm2m servers which make sure a valid response is returned. Let's fix this by returning the correct NOT_FOUND error code instead. NOTE: To test this I commented out the portion of the lwm2m client sample which initializes the LWM2M_DEVICE_PWR_SRC_TYPE_BAT_INT and LWM2M_DEVICE_PWR_SRC_TYPE_USB values. By default, the sample will setup dummy values to be returned by the client. Signed-off-by: Michael Scott <[email protected]>
1 parent 98d6a99 commit c1e180b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

subsys/net/lib/lwm2m/lwm2m_engine.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright (c) 2017 Linaro Limited
3-
* Copyright (c) 2017 Open Source Foundries Limited.
3+
* Copyright (c) 2018 Open Source Foundries Ltd.
44
*
55
* SPDX-License-Identifier: Apache-2.0
66
*/
@@ -1897,6 +1897,11 @@ static int lwm2m_read_handler(struct lwm2m_engine_obj_inst *obj_inst,
18971897
}
18981898

18991899
if (res->multi_count_var != NULL) {
1900+
/* if multi_count_var is 0 (none assigned) return NOT_FOUND */
1901+
if (*res->multi_count_var == 0) {
1902+
return -ENOENT;
1903+
}
1904+
19001905
engine_put_begin_ri(out, path);
19011906
loop_max = *res->multi_count_var;
19021907
res_inst_id_tmp = path->res_inst_id;

0 commit comments

Comments
 (0)