Skip to content

Commit

Permalink
net: lwm2m: Request big serialization buffer for some messages
Browse files Browse the repository at this point in the history
Some messages are known have a potentionally big body. They
are serialized into a big buffer before splitting into blocks
when sending.

Signed-off-by: Lukas Woodtli <lukas.woodtli@husqvarnagroup.com>
  • Loading branch information
LukasWoodtli committed Feb 13, 2023
1 parent 4afa184 commit ac6d68c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
11 changes: 11 additions & 0 deletions subsys/net/lib/lwm2m/lwm2m_message_handling.c
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,16 @@ void lwm2m_reset_message(struct lwm2m_message *msg, bool release)
}
}

void lwm2m_use_full_body_buffer(struct lwm2m_message *msg, bool use_big_buffer)
{
#if LWM2M_COAP_BLOCK_TRANSFER_ENABLED
msg->use_full_body_buffer = use_big_buffer;
#else
ARG_UNUSED(msg);
ARG_UNUSED(use_big_buffer);
#endif
}

int lwm2m_init_message(struct lwm2m_message *msg)
{
uint8_t tokenlen = 0U;
Expand Down Expand Up @@ -2801,6 +2811,7 @@ int generate_notify_message(struct lwm2m_ctx *ctx, struct observe_node *obs, voi
msg->reply_cb = notify_message_reply_cb;
msg->message_timeout_cb = notify_message_timeout_cb;
msg->out.out_cpkt = &msg->cpkt;
lwm2m_use_full_body_buffer(msg, true);

ret = lwm2m_init_message(msg);
if (ret < 0) {
Expand Down
1 change: 1 addition & 0 deletions subsys/net/lib/lwm2m/lwm2m_message_handling.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ struct lwm2m_message *lwm2m_get_message(struct lwm2m_ctx *client_ctx);
struct lwm2m_message *find_msg(struct coap_pending *pending, struct coap_reply *reply);
void lwm2m_reset_message(struct lwm2m_message *msg, bool release);
void lm2m_message_clear_allocations(struct lwm2m_message *msg);
void lwm2m_use_full_body_buffer(struct lwm2m_message *msg, bool use_big_buffer);
int lwm2m_init_message(struct lwm2m_message *msg);
int lwm2m_send_message_async(struct lwm2m_message *msg);

Expand Down
3 changes: 3 additions & 0 deletions subsys/net/lib/lwm2m/lwm2m_rd_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,9 @@ static int sm_send_registration(bool send_obj_support_data,
msg->reply_cb = reply_cb;
msg->message_timeout_cb = timeout_cb;

/* use big buffer if we send (potentially big) payload */
lwm2m_use_full_body_buffer(msg, send_obj_support_data);

ret = lwm2m_init_message(msg);
if (ret) {
goto cleanup;
Expand Down

0 comments on commit ac6d68c

Please sign in to comment.