Skip to content

Commit

Permalink
net: lwm2m: Fix composite read on SenML-CBOR
Browse files Browse the repository at this point in the history
Composite read was incorrectly trying to parse CoAP packet
instead of payload of the packet.

Signed-off-by: Seppo Takalo <[email protected]>
  • Loading branch information
SeppoTakalo authored and carlescufi committed Sep 27, 2023
1 parent 69cd597 commit ebb90c5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
6 changes: 0 additions & 6 deletions subsys/net/lib/lwm2m/lwm2m_message_handling.c
Original file line number Diff line number Diff line change
Expand Up @@ -417,12 +417,6 @@ STATIC int prepare_msg_for_send(struct lwm2m_message *msg)

#endif

bool lwm2m_outgoing_is_part_of_blockwise(struct lwm2m_message *msg)
{
return msg->block_send;
}


void lwm2m_engine_context_close(struct lwm2m_ctx *client_ctx)
{
struct lwm2m_message *msg;
Expand Down
6 changes: 5 additions & 1 deletion subsys/net/lib/lwm2m/lwm2m_message_handling.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ enum coap_block_size lwm2m_default_block_size(void);

int lwm2m_parse_peerinfo(char *url, struct lwm2m_ctx *client_ctx, bool is_firmware_uri);
void lwm2m_clear_block_contexts(void);
bool lwm2m_outgoing_is_part_of_blockwise(struct lwm2m_message *msg);

static inline bool lwm2m_outgoing_is_part_of_blockwise(struct lwm2m_message *msg)
{
return msg->block_send;
}

#endif /* LWM2M_MESSAGE_HANDLING_H */
5 changes: 4 additions & 1 deletion subsys/net/lib/lwm2m/lwm2m_rw_senml_cbor.c
Original file line number Diff line number Diff line change
Expand Up @@ -836,12 +836,15 @@ static uint8_t parse_composite_read_paths(struct lwm2m_message *msg,
uint_fast8_t dret;
int len;
int ret;
char *payload;
uint16_t in_len;

setup_in_fmt_data(msg);

fd = engine_get_in_user_data(&msg->in);
payload = (char *)coap_packet_get_payload(msg->in.in_cpkt, &in_len);

dret = cbor_decode_lwm2m_senml(ICTX_BUF_R_REGION(&msg->in), &fd->dcd, &isize);
dret = cbor_decode_lwm2m_senml(payload, in_len, &fd->dcd, &isize);

if (dret != ZCBOR_SUCCESS) {
__ASSERT_NO_MSG(false);
Expand Down

0 comments on commit ebb90c5

Please sign in to comment.