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

[ReadHandler] Handler Reportable if timer fired #28949

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
10 changes: 7 additions & 3 deletions src/app/reporting/ReportScheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,16 @@ class ReportScheduler : public ReadHandler::Observer, public ICDStateObserver

/// @brief Check if the Node is reportable now, meaning its readhandler was made reportable by attribute dirtying and
/// handler state, and minimal time interval since last report has elapsed, or the maximal time interval since last
/// report has elapsed
/// report has elapsed.
/// @note If a handler has been flaged as scheduled for engine run, it will be reported regardless of the timestamps. This
/// is done to guarantee that the reporting engine will see the handler as reportable if a timer fires, even if it fires
/// early.
/// @param now current time to use for the check, user must ensure to provide a valid time for this to be reliable
bool IsReportableNow(const Timestamp & now) const
{
return (mReadHandler->CanStartReporting() &&
(now >= mMinTimestamp && (mReadHandler->IsDirty() || now >= mMaxTimestamp || CanBeSynced())));
((now >= mMinTimestamp && (mReadHandler->IsDirty() || now >= mMaxTimestamp || CanBeSynced())) ||
IsEngineRunScheduled()));
lpbeliveau-silabs marked this conversation as resolved.
Show resolved Hide resolved
}

bool IsEngineRunScheduled() const { return mFlags.Has(ReadHandlerNodeFlags::EngineRunScheduled); }
Expand All @@ -114,8 +118,8 @@ class ReportScheduler : public ReadHandler::Observer, public ICDStateObserver

void TimerFired() override
{
mScheduler->ReportTimerCallback();
SetEngineRunScheduled(true);
mScheduler->ReportTimerCallback();
}

System::Clock::Timestamp GetMinTimestamp() const { return mMinTimestamp; }
Expand Down
3 changes: 2 additions & 1 deletion src/app/reporting/ReportSchedulerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,10 @@ void ReportSchedulerImpl::OnSubscriptionReportSent(ReadHandler * aReadHandler)
node->SetCanBeSynced(false);
node->SetIntervalTimeStamps(aReadHandler, now);
Milliseconds32 newTimeout;
// Reset the EngineRunScheduled flag so that the next report is scheduled correctly
node->SetEngineRunScheduled(false);
CalculateNextReportTimeout(newTimeout, node, now);
ScheduleReport(newTimeout, node, now);
node->SetEngineRunScheduled(false);
}

/// @brief When a ReadHandler is removed, unregister it, which will cancel any scheduled report
Expand Down