From 767bcb7aba9a0b4e81bb087c200de65c6742a8a6 Mon Sep 17 00:00:00 2001 From: nandan Date: Wed, 23 Oct 2024 18:01:19 +0530 Subject: [PATCH 1/2] FOGL-9183: Round of the microseconds to seconds for time difference Signed-off-by: nandan --- C/services/notification/notification_manager.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/C/services/notification/notification_manager.cpp b/C/services/notification/notification_manager.cpp index 9342717..8973199 100644 --- a/C/services/notification/notification_manager.cpp +++ b/C/services/notification/notification_manager.cpp @@ -780,6 +780,13 @@ bool NotificationInstance::handleState(bool evalRet) // Calculate time diff timersub(&now_tv, &m_lastSentTv, &diffTimeTv); + // round up the seconds If microseconds are greater than or equal to 500000 + if (diffTimeTv.tv_usec >= 500000) + { + diffTimeTv.tv_sec = diffTimeTv.tv_sec + 1; + diffTimeTv.tv_usec = 0; + } + switch(nType.type) { case NotificationInstance::OneShot: From 2a9b30439a8e8ec6ef4aec451bbcc06132f47fa3 Mon Sep 17 00:00:00 2001 From: nandan Date: Tue, 5 Nov 2024 20:24:17 +0530 Subject: [PATCH 2/2] FOGL-9183: send trigger if lastsent time different than current time in seconds Signed-off-by: nandan --- C/services/notification/notification_manager.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/C/services/notification/notification_manager.cpp b/C/services/notification/notification_manager.cpp index 8973199..47d9209 100644 --- a/C/services/notification/notification_manager.cpp +++ b/C/services/notification/notification_manager.cpp @@ -811,7 +811,10 @@ bool NotificationInstance::handleState(bool evalRet) // Set state depends on evalRet setTriggered = evalRet; // Try sending "triggered" when evaluation is true - ret = evalRet && timercmp(&diffTimeTv, &nType.retriggerTimeTv, >=); + if ( ( nType.retriggerTimeTv.tv_sec > 0) && (m_lastSentTv.tv_sec == now_tv.tv_sec)) + ret = false; + else + ret = evalRet && timercmp(&diffTimeTv, &nType.retriggerTimeTv, >=); break; default: