net: lwm2m: notify timeout handling

Added notify_timeout_cb to struct lwm2m_ctx to allow application to
 handle notify timeout
Added lwm2m_rd_client_update to lwm2m.h to allow application to
 trigger registration update
Added notify_message_timeout_cb which calls notify_timeout_cb from
 struct lwm2m_ctx and logs an error message

Fixes #31499

Signed-off-by: John Power <john.power@xylem.com>
This commit is contained in:
John Power 2021-06-22 12:48:54 +01:00 committed by Anas Nashif
commit 3138d89fd9
3 changed files with 30 additions and 0 deletions

View file

@ -4247,6 +4247,19 @@ static int32_t retransmit_request(struct lwm2m_ctx *client_ctx,
return next_retransmission;
}
static void notify_message_timeout_cb(struct lwm2m_message *msg)
{
if (msg->ctx != NULL) {
struct lwm2m_ctx *client_ctx = msg->ctx;
if (client_ctx->notify_timeout_cb != NULL) {
client_ctx->notify_timeout_cb();
}
}
LOG_ERR("Notify Message Timed Out : %p", msg);
}
static int notify_message_reply_cb(const struct coap_packet *response,
struct coap_reply *reply,
const struct sockaddr *from)
@ -4324,6 +4337,7 @@ static int generate_notify_message(struct lwm2m_ctx *ctx,
msg->token = obs->token;
msg->tkl = obs->tkl;
msg->reply_cb = notify_message_reply_cb;
msg->message_timeout_cb = notify_message_timeout_cb;
msg->out.out_cpkt = &msg->cpkt;
ret = lwm2m_init_message(msg);