Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lwm2m: upstream updates #1489

Merged
merged 4 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions subsys/net/lib/lwm2m/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,13 @@ config LWM2M_QUEUE_MODE_UPTIME
defaults to 93 seconds, see RFC 7252), it does not forbid other
values though.

config LWM2M_QUEUE_MODE_NO_MSG_BUFFERING
bool "Disable buffering notifications and messages on queue mode"
select EXPERIMENTAL
help
Messages are sent right away instead of waiting for next registration update.
This might not be supported on all servers.

config LWM2M_TLS_SESSION_CACHING
bool "TLS session caching"
help
Expand Down
5 changes: 3 additions & 2 deletions subsys/net/lib/lwm2m/lwm2m_engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ int lwm2m_push_queued_buffers(struct lwm2m_ctx *client_ctx)
break;
}
msg = SYS_SLIST_CONTAINER(msg_node, msg, node);
msg->pending->t0 = k_uptime_get();
sys_slist_append(&msg->ctx->pending_sends, &msg->node);
}
#endif
Expand Down Expand Up @@ -644,7 +645,7 @@ static int64_t check_notifications(struct lwm2m_ctx *ctx, const int64_t timestam
*/
static void hint_socket_state(struct lwm2m_ctx *ctx, struct lwm2m_message *ongoing_tx)
{
if (!ctx->set_socket_state) {
if (!ctx || !ctx->set_socket_state) {
return;
}

Expand Down Expand Up @@ -1059,7 +1060,7 @@ int lwm2m_set_default_sockopt(struct lwm2m_ctx *ctx)
}
if (IS_ENABLED(CONFIG_LWM2M_DTLS_CID)) {
/* Enable CID */
int cid = TLS_DTLS_CID_ENABLED;
int cid = TLS_DTLS_CID_SUPPORTED;

ret = zsock_setsockopt(ctx->sock_fd, SOL_TLS, TLS_DTLS_CID, &cid,
sizeof(cid));
Expand Down
7 changes: 7 additions & 0 deletions subsys/net/lib/lwm2m/lwm2m_message_handling.c
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,13 @@ int lwm2m_information_interface_send(struct lwm2m_message *msg)
return ret;
}

if (IS_ENABLED(CONFIG_LWM2M_QUEUE_MODE_NO_MSG_BUFFERING)) {
sys_slist_append(&msg->ctx->pending_sends, &msg->node);
lwm2m_engine_wake_up();
lwm2m_engine_connection_resume(msg->ctx);
return 0;
}

if (msg->ctx->buffer_client_messages) {
sys_slist_append(&msg->ctx->queued_messages, &msg->node);
lwm2m_engine_wake_up();
Expand Down
7 changes: 6 additions & 1 deletion subsys/net/lib/lwm2m/lwm2m_rd_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -1726,7 +1726,12 @@ int lwm2m_rd_client_connection_resume(struct lwm2m_ctx *client_ctx)
IS_ENABLED(CONFIG_LWM2M_RD_CLIENT_LISTEN_AT_IDLE)) ||
!IS_ENABLED(CONFIG_LWM2M_DTLS_SUPPORT)) {
client.engine_state = ENGINE_REGISTRATION_DONE;
client.trigger_update = true;
if (IS_ENABLED(CONFIG_LWM2M_QUEUE_MODE_NO_MSG_BUFFERING)) {
/* Force online for a short period */
engine_update_tx_time();
} else {
client.trigger_update = true;
}
} else {
client.engine_state = ENGINE_DO_REGISTRATION;
}
Expand Down
4 changes: 4 additions & 0 deletions tests/net/lib/lwm2m/lwm2m_engine/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,11 +260,13 @@ ZTEST(lwm2m_engine, test_push_queued_buffers)
int ret;
struct lwm2m_ctx ctx;
struct lwm2m_message msg;
struct coap_pending pending;

(void)memset(&ctx, 0x0, sizeof(ctx));

sys_slist_init(&ctx.queued_messages);
msg.ctx = &ctx;
msg.pending = &pending;
sys_slist_append(&ctx.queued_messages, &msg.node);
ret = lwm2m_push_queued_buffers(&ctx);
zassert_equal(ret, 0);
Expand Down Expand Up @@ -391,13 +393,15 @@ ZTEST(lwm2m_engine, test_socket_send)
int ret;
struct lwm2m_ctx ctx;
struct lwm2m_message msg;
struct coap_pending pending;

(void)memset(&ctx, 0x0, sizeof(ctx));

ctx.remote_addr.sa_family = AF_INET;
ctx.sock_fd = -1;
sys_slist_init(&ctx.queued_messages);
msg.ctx = &ctx;
msg.pending = &pending;
msg.type = COAP_TYPE_CON;
sys_slist_append(&ctx.queued_messages, &msg.node);

Expand Down