Skip to content

Commit a64dcbb

Browse files
rbtchcjukkar
authored andcommitted
net: lwm2m: do not report object when object instances available
Per LwM2M specification 5.3.1 Register. When object instances are available, object ID can be ignored in registration message Signed-off-by: Robert Chou <[email protected]>
1 parent c21372e commit a64dcbb

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

subsys/net/lib/lwm2m/lwm2m_engine.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -591,15 +591,19 @@ u16_t lwm2m_get_rd_data(u8_t *client_data, u16_t size)
591591
continue;
592592
}
593593

594-
len = snprintf(temp, sizeof(temp), "%s</%u>",
595-
(pos > 0) ? "," : "", obj->obj_id);
596-
if (pos + len >= size) {
597-
/* full buffer -- exit loop */
598-
break;
599-
}
594+
/* Only report <OBJ_ID> when no instance available */
595+
if (obj->instance_count == 0) {
596+
len = snprintf(temp, sizeof(temp), "%s</%u>",
597+
(pos > 0) ? "," : "", obj->obj_id);
598+
if (pos + len >= size) {
599+
/* full buffer -- exit loop */
600+
break;
601+
}
600602

601-
memcpy(&client_data[pos], temp, len);
602-
pos += len;
603+
memcpy(&client_data[pos], temp, len);
604+
pos += len;
605+
continue;
606+
}
603607

604608
SYS_SLIST_FOR_EACH_CONTAINER(&engine_obj_inst_list,
605609
obj_inst, node) {

0 commit comments

Comments
 (0)