From cb2bfcb9c0e73e271f45a3d6ac8cc9718810e3c9 Mon Sep 17 00:00:00 2001 From: Michael Scott Date: Mon, 8 Apr 2019 11:31:46 -0700 Subject: [PATCH] net: lwm2m: fix periodic services handling This fixes an issue where if timestamp == service_due_timestamp, we don't call the periodic service. Then the following call to engine_next_service_timeout_ms() returns 0 because the service is still due and lwm2m_engine_service() is called again. This process repeats several times until the value of k_uptime_get() changes and then the work is finally handled. Previously, the resolution of k_uptime_get() was in ms. A recent change to this API defaults Zephyr so that the resolution is set via CONFIG_SYS_CLOCK_TICKS_PER_SEC (default 100). This means the value of k_uptime_get() only changes every 10ms. Reported-by: Github User pieterjanc Signed-off-by: Michael Scott --- subsys/net/lib/lwm2m/lwm2m_engine.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subsys/net/lib/lwm2m/lwm2m_engine.c b/subsys/net/lib/lwm2m/lwm2m_engine.c index ef945ef52a5..465eae489fe 100644 --- a/subsys/net/lib/lwm2m/lwm2m_engine.c +++ b/subsys/net/lib/lwm2m/lwm2m_engine.c @@ -3804,7 +3804,7 @@ static int lwm2m_engine_service(void) service_due_timestamp = srv->last_timestamp + K_MSEC(srv->min_call_period); /* service is due */ - if (timestamp > service_due_timestamp) { + if (timestamp >= service_due_timestamp) { srv->last_timestamp = k_uptime_get(); srv->service_work(NULL); }