Skip to content

Commit

Permalink
[ReadHandler] Handler Reportable if timer fired (#28949)
Browse files Browse the repository at this point in the history
* Now using the EngineRunScheduled to assess reportability in the scheduler

* Added note to IsReportableNow to explain the use of IsEngineRunScheduled flag
  • Loading branch information
lpbeliveau-silabs authored and pull[bot] committed Dec 15, 2023
1 parent 9160341 commit 1116164
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
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()));
}

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

0 comments on commit 1116164

Please sign in to comment.