Skip to content

Commit

Permalink
Appplied change to method name and fixe condition in SetStateFlag
Browse files Browse the repository at this point in the history
  • Loading branch information
lpbeliveau-silabs committed Aug 10, 2023
1 parent 9b177eb commit 6a6806f
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
12 changes: 6 additions & 6 deletions src/app/ReadHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ CHIP_ERROR ReadHandler::OnStatusResponse(Messaging::ExchangeContext * apExchange
{
appCallback->OnSubscriptionEstablished(*this);
}
mObserver->OnReadHandlerSubscribed(this);
mObserver->OnSubscriptionEstablished(this);
}
}
else
Expand Down Expand Up @@ -882,14 +882,14 @@ void ReadHandler::SetStateFlag(ReadHandlerFlags aFlag, bool aValue)
// If we became reportable, schedule a reporting run.
if (!oldReportable && ShouldStartReporting())
{
if (IsActiveSubscription())
if (ShouldReportUnscheduled())
{
// If we became reportable, the scheduler will schedule a run as soon as allowed
mObserver->OnBecameReportable(this);
InteractionModelEngine::GetInstance()->GetReportingEngine().ScheduleRun();
}
else if (ShouldReportUnscheduled())
else
{
InteractionModelEngine::GetInstance()->GetReportingEngine().ScheduleRun();
// If we became reportable, the scheduler will schedule a run as soon as allowed
mObserver->OnBecameReportable(this);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/ReadHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ class ReadHandler : public Messaging::ExchangeDelegate
/// without consulting the report scheduler.
bool ShouldReportUnscheduled() const
{
return CanStartReporting() && (IsType(ReadHandler::InteractionType::Read) || IsPriming()) && !IsActiveSubscription();
return CanStartReporting() && (IsType(ReadHandler::InteractionType::Read) || IsPriming());
}
bool IsAwaitingReportResponse() const { return mState == HandlerState::AwaitingReportResponse; }

Expand Down
2 changes: 1 addition & 1 deletion src/app/reporting/ReportSchedulerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void ReportSchedulerImpl::OnEnterActiveMode()
/// @brief When a ReadHandler is added, register it in the scheduler node pool. Scheduling the report here is un-necessary since the
/// ReadHandler will call MoveToState(HandlerState::CanStartReporting);, which will call OnBecameReportable() and schedule the
/// report.
void ReportSchedulerImpl::OnReadHandlerSubscribed(ReadHandler * aReadHandler)
void ReportSchedulerImpl::OnSubscriptionEstablished(ReadHandler * aReadHandler)
{
ReadHandlerNode * newNode = FindReadHandlerNode(aReadHandler);
// Handler must not be registered yet; it's just being constructed.
Expand Down
2 changes: 1 addition & 1 deletion src/app/reporting/ReportSchedulerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class ReportSchedulerImpl : public ReportScheduler
void OnEnterActiveMode() override;

// ReadHandlerObserver
void OnReadHandlerSubscribed(ReadHandler * aReadHandler) final;
void OnSubscriptionEstablished(ReadHandler * aReadHandler) final;
void OnBecameReportable(ReadHandler * aReadHandler) final;
void OnSubscriptionReportSent(ReadHandler * aReadHandler) final;
void OnReadHandlerDestroyed(ReadHandler * aReadHandler) override;
Expand Down
8 changes: 4 additions & 4 deletions src/app/tests/TestReportScheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,10 @@ class TestReportScheduler
{
ReturnErrorOnFailure(readHandler->SetMaxReportingInterval(max_interval_seconds));
ReturnErrorOnFailure(readHandler->SetMinReportingIntervalForTests(min_interval_seconds));
scheduler->OnReadHandlerSubscribed(readHandler);
readHandler->ClearStateFlag(ReadHandler::ReadHandlerFlags::PrimingReports);
readHandler->SetStateFlag(ReadHandler::ReadHandlerFlags::ActiveSubscription);
scheduler->OnSubscriptionEstablished(readHandler);
readHandler->MoveToState(ReadHandler::HandlerState::CanStartReporting);
readHandler->ClearStateFlag(ReadHandler::ReadHandlerFlags::PrimingReports);

return CHIP_NO_ERROR;
}
Expand Down Expand Up @@ -299,7 +299,7 @@ class TestReportScheduler
{
ReadHandler * readHandler =
readHandlerPool.CreateObject(nullCallback, exchangeCtx, ReadHandler::InteractionType::Subscribe, &sScheduler);
sScheduler.OnReadHandlerSubscribed(readHandler);
sScheduler.OnSubscriptionEstablished(readHandler);
NL_TEST_ASSERT(aSuite, nullptr != readHandler);
VerifyOrReturn(nullptr != readHandler);
NL_TEST_ASSERT(aSuite, nullptr != sScheduler.FindReadHandlerNode(readHandler));
Expand Down Expand Up @@ -431,7 +431,7 @@ class TestReportScheduler
readHandlerPool.CreateObject(nullCallback, exchangeCtx, ReadHandler::InteractionType::Subscribe, &sScheduler);
NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == MockReadHandlerSubscriptionTransation(readHandler, &sScheduler, 1, 2));

// Verifies OnReadHandlerSubscribed registered the ReadHandler in the scheduler
// Verifies OnSubscriptionEstablished registered the ReadHandler in the scheduler
NL_TEST_ASSERT(aSuite, nullptr != sScheduler.FindReadHandlerNode(readHandler));

// Should have registered the read handler in the scheduler and scheduled a report
Expand Down

0 comments on commit 6a6806f

Please sign in to comment.