[ReadHandler] Rename and comment (#27269)
* Updated function names and description related to the scheduling of subcription reports in the ReadHandler to explicit its functionnality
* Apply suggestions from code review
Co-authored-by: mkardous-silabs <84793247+mkardous-silabs@users.noreply.github.com>
* Fixed the syntax for the IsReportableNow description
* Added missing parameter and return description in comments
* Apply suggestions from code review
Co-authored-by: Boris Zbarsky <bzbarsky@apple.com>
* Reverted name changes for flag set and clear, reworded comments as suggested
* Apply suggestions from code review
Co-authored-by: Boris Zbarsky <bzbarsky@apple.com>
* Restyled by clang-format
---------
Co-authored-by: mkardous-silabs <84793247+mkardous-silabs@users.noreply.github.com>
Co-authored-by: Boris Zbarsky <bzbarsky@apple.com>
Co-authored-by: Restyled.io <commits@restyled.io>
diff --git a/examples/all-clusters-app/nxp/mw320/main.cpp b/examples/all-clusters-app/nxp/mw320/main.cpp
index 2367505..b8b1fe8 100644
--- a/examples/all-clusters-app/nxp/mw320/main.cpp
+++ b/examples/all-clusters-app/nxp/mw320/main.cpp
@@ -14,8 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-//#include "FreeRTOS.h"
-//#include "task.h"
+// #include "FreeRTOS.h"
+// #include "task.h"
#include <lib/shell/Engine.h>
@@ -28,7 +28,7 @@
#include <lib/support/CHIPArgParser.hpp>
#include <lib/support/CodeUtils.h>
-//#include <lib/support/RandUtils.h> //==> rm from TE7.5
+// #include <lib/support/RandUtils.h> //==> rm from TE7.5
#include <app-common/zap-generated/attributes/Accessors.h>
#include <app-common/zap-generated/ids/Attributes.h>
#include <app-common/zap-generated/ids/Clusters.h>
@@ -59,9 +59,9 @@
#include "app/clusters/ota-requestor/DefaultOTARequestor.h"
#include "app/clusters/ota-requestor/DefaultOTARequestorDriver.h"
#include "app/clusters/ota-requestor/DefaultOTARequestorStorage.h"
-//#include <app/clusters/ota-requestor/DefaultOTARequestorUserConsent.h>
+// #include <app/clusters/ota-requestor/DefaultOTARequestorUserConsent.h>
#include "platform/nxp/mw320/OTAImageProcessorImpl.h"
-//#include "app/clusters/ota-requestor/OTARequestorDriver.h"
+// #include "app/clusters/ota-requestor/OTARequestorDriver.h"
// for ota module test
#include "mw320_ota.h"
@@ -1528,7 +1528,7 @@
ReadHandler * phandler = pimEngine->ActiveHandlerAt(i);
if (phandler->IsType(chip::app::ReadHandler::InteractionType::Subscribe) &&
(phandler->IsGeneratingReports() || phandler->IsAwaitingReportResponse())) {
- phandler->UnblockUrgentEventDelivery();
+ phandler->ForceDirtyState();
do_sendrpt = true;
break;
}
diff --git a/src/app/ReadHandler.cpp b/src/app/ReadHandler.cpp
index 1c2511b..4a92fcf 100644
--- a/src/app/ReadHandler.cpp
+++ b/src/app/ReadHandler.cpp
@@ -124,10 +124,10 @@
if (IsType(InteractionType::Subscribe))
{
InteractionModelEngine::GetInstance()->GetExchangeManager()->GetSessionManager()->SystemLayer()->CancelTimer(
- OnUnblockHoldReportCallback, this);
+ MinIntervalExpiredCallback, this);
InteractionModelEngine::GetInstance()->GetExchangeManager()->GetSessionManager()->SystemLayer()->CancelTimer(
- OnRefreshSubscribeTimerSyncCallback, this);
+ MaxIntervalExpiredCallback, this);
}
if (IsAwaitingReportResponse())
@@ -248,7 +248,7 @@
CHIP_ERROR ReadHandler::SendStatusReport(Protocols::InteractionModel::Status aStatus)
{
- VerifyOrReturnLogError(IsReportable(), CHIP_ERROR_INCORRECT_STATE);
+ VerifyOrReturnLogError(IsReportableNow(), CHIP_ERROR_INCORRECT_STATE);
if (IsPriming() || IsChunkedReport())
{
mSessionHandle.Grab(mExchangeCtx->GetSessionHandle());
@@ -272,7 +272,7 @@
CHIP_ERROR ReadHandler::SendReportData(System::PacketBufferHandle && aPayload, bool aMoreChunks)
{
- VerifyOrReturnLogError(IsReportable(), CHIP_ERROR_INCORRECT_STATE);
+ VerifyOrReturnLogError(IsReportableNow(), CHIP_ERROR_INCORRECT_STATE);
VerifyOrDie(!IsAwaitingReportResponse()); // Should not be reportable!
if (IsPriming() || IsChunkedReport())
{
@@ -319,10 +319,10 @@
if (IsType(InteractionType::Subscribe) && !IsPriming())
{
- // Ignore the error from RefreshSubscribeSyncTimer. If we've
+ // Ignore the error from UpdateReportTimer. If we've
// successfully sent the message, we need to return success from
// this method.
- RefreshSubscribeSyncTimer();
+ UpdateReportTimer();
}
}
if (!aMoreChunks)
@@ -591,7 +591,7 @@
// If we just unblocked sending reports, let's go ahead and schedule the reporting
// engine to run to kick that off.
//
- if (aTargetState == HandlerState::GeneratingReports && IsReportable())
+ if (aTargetState == HandlerState::GeneratingReports && IsReportableNow())
{
InteractionModelEngine::GetInstance()->GetReportingEngine().ScheduleRun();
}
@@ -634,7 +634,7 @@
ReturnErrorOnFailure(writer.Finalize(&packet));
VerifyOrReturnLogError(mExchangeCtx, CHIP_ERROR_INCORRECT_STATE);
- ReturnErrorOnFailure(RefreshSubscribeSyncTimer());
+ ReturnErrorOnFailure(UpdateReportTimer());
ClearStateFlag(ReadHandlerFlags::PrimingReports);
return mExchangeCtx->SendMessage(Protocols::InteractionModel::MsgType::SubscribeResponse, std::move(packet));
@@ -753,42 +753,42 @@
}
}
-void ReadHandler::OnUnblockHoldReportCallback(System::Layer * apSystemLayer, void * apAppState)
+void ReadHandler::MinIntervalExpiredCallback(System::Layer * apSystemLayer, void * apAppState)
{
VerifyOrReturn(apAppState != nullptr);
ReadHandler * readHandler = static_cast<ReadHandler *>(apAppState);
ChipLogDetail(DataManagement, "Unblock report hold after min %d seconds", readHandler->mMinIntervalFloorSeconds);
- readHandler->ClearStateFlag(ReadHandlerFlags::HoldReport);
+ readHandler->ClearStateFlag(ReadHandlerFlags::WaitingUntilMinInterval);
InteractionModelEngine::GetInstance()->GetExchangeManager()->GetSessionManager()->SystemLayer()->StartTimer(
- System::Clock::Seconds16(readHandler->mMaxInterval - readHandler->mMinIntervalFloorSeconds),
- OnRefreshSubscribeTimerSyncCallback, readHandler);
+ System::Clock::Seconds16(readHandler->mMaxInterval - readHandler->mMinIntervalFloorSeconds), MaxIntervalExpiredCallback,
+ readHandler);
}
-void ReadHandler::OnRefreshSubscribeTimerSyncCallback(System::Layer * apSystemLayer, void * apAppState)
+void ReadHandler::MaxIntervalExpiredCallback(System::Layer * apSystemLayer, void * apAppState)
{
VerifyOrReturn(apAppState != nullptr);
ReadHandler * readHandler = static_cast<ReadHandler *>(apAppState);
- readHandler->ClearStateFlag(ReadHandlerFlags::HoldSync);
+ readHandler->ClearStateFlag(ReadHandlerFlags::WaitingUntilMaxInterval);
ChipLogProgress(DataManagement, "Refresh subscribe timer sync after %d seconds",
readHandler->mMaxInterval - readHandler->mMinIntervalFloorSeconds);
}
-CHIP_ERROR ReadHandler::RefreshSubscribeSyncTimer()
+CHIP_ERROR ReadHandler::UpdateReportTimer()
{
InteractionModelEngine::GetInstance()->GetExchangeManager()->GetSessionManager()->SystemLayer()->CancelTimer(
- OnUnblockHoldReportCallback, this);
+ MinIntervalExpiredCallback, this);
InteractionModelEngine::GetInstance()->GetExchangeManager()->GetSessionManager()->SystemLayer()->CancelTimer(
- OnRefreshSubscribeTimerSyncCallback, this);
+ MaxIntervalExpiredCallback, this);
if (!IsChunkedReport())
{
ChipLogProgress(DataManagement, "Refresh Subscribe Sync Timer with min %d seconds and max %d seconds",
mMinIntervalFloorSeconds, mMaxInterval);
- SetStateFlag(ReadHandlerFlags::HoldReport);
- SetStateFlag(ReadHandlerFlags::HoldSync);
+ SetStateFlag(ReadHandlerFlags::WaitingUntilMinInterval);
+ SetStateFlag(ReadHandlerFlags::WaitingUntilMaxInterval);
ReturnErrorOnFailure(
InteractionModelEngine::GetInstance()->GetExchangeManager()->GetSessionManager()->SystemLayer()->StartTimer(
- System::Clock::Seconds16(mMinIntervalFloorSeconds), OnUnblockHoldReportCallback, this));
+ System::Clock::Seconds16(mMinIntervalFloorSeconds), MinIntervalExpiredCallback, this));
}
return CHIP_NO_ERROR;
@@ -800,13 +800,13 @@
mAttributeEncoderState = AttributeValueEncoder::AttributeEncodeState();
}
-void ReadHandler::SetDirty(const AttributePathParams & aAttributeChanged)
+void ReadHandler::AttributePathIsDirty(const AttributePathParams & aAttributeChanged)
{
ConcreteAttributePath path;
mDirtyGeneration = InteractionModelEngine::GetInstance()->GetReportingEngine().GetDirtySetGeneration();
- // We won't reset the path iterator for every SetDirty call to reduce the number of full data reports.
+ // We won't reset the path iterator for every AttributePathIsDirty call to reduce the number of full data reports.
// The iterator will be reset after finishing each report session.
//
// Here we just reset the iterator to the beginning of the current cluster, if the dirty path affects it.
@@ -829,7 +829,7 @@
mAttributeEncoderState = AttributeValueEncoder::AttributeEncodeState();
}
- if (IsReportable())
+ if (IsReportableNow())
{
InteractionModelEngine::GetInstance()->GetReportingEngine().ScheduleRun();
}
@@ -844,17 +844,17 @@
return mSessionHandle->AsSecureSession();
}
-void ReadHandler::UnblockUrgentEventDelivery()
+void ReadHandler::ForceDirtyState()
{
SetStateFlag(ReadHandlerFlags::ForceDirty);
}
void ReadHandler::SetStateFlag(ReadHandlerFlags aFlag, bool aValue)
{
- bool oldReportable = IsReportable();
+ bool oldReportable = IsReportableNow();
mFlags.Set(aFlag, aValue);
// If we became reportable, schedule a reporting run.
- if (!oldReportable && IsReportable())
+ if (!oldReportable && IsReportableNow())
{
InteractionModelEngine::GetInstance()->GetReportingEngine().ScheduleRun();
}
diff --git a/src/app/ReadHandler.h b/src/app/ReadHandler.h
index a933aa7..f460188 100644
--- a/src/app/ReadHandler.h
+++ b/src/app/ReadHandler.h
@@ -212,15 +212,15 @@
enum class ReadHandlerFlags : uint8_t
{
- // mHoldReport is used to prevent subscription data delivery while we are
+ // WaitingUntilMinInterval is used to prevent subscription data delivery while we are
// waiting for the min reporting interval to elapse.
- HoldReport = (1 << 0),
+ WaitingUntilMinInterval = (1 << 0),
- // mHoldSync is used to prevent subscription empty report delivery while we
- // are waiting for the max reporting interval to elaps. When mHoldSync
+ // WaitingUntilMaxInterval is used to prevent subscription empty report delivery while we
+ // are waiting for the max reporting interval to elaps. When WaitingUntilMaxInterval
// becomes false, we are allowed to send an empty report to keep the
// subscription alive on the client.
- HoldSync = (1 << 1),
+ WaitingUntilMaxInterval = (1 << 1),
// The flag indicating we are in the middle of a series of chunked report messages, this flag will be cleared during
// sending last chunked message.
@@ -290,13 +290,16 @@
bool IsFromSubscriber(Messaging::ExchangeContext & apExchangeContext) const;
bool IsIdle() const { return mState == HandlerState::Idle; }
- bool IsReportable() const
+
+ /// @brief Returns whether the ReadHandler is in a state where it can immediately send a report. This function
+ /// is used to determine whether a report generation should be scheduled for the handler.
+ bool IsReportableNow() const
{
- // Important: Anything that changes the state IsReportable depends on in
- // a way that causes IsReportable to become true must call ScheduleRun
+ // Important: Anything that changes the state IsReportableNow depends on in
+ // a way that causes IsReportableNow to become true must call ScheduleRun
// on the reporting engine.
- return mState == HandlerState::GeneratingReports && !mFlags.Has(ReadHandlerFlags::HoldReport) &&
- (IsDirty() || !mFlags.Has(ReadHandlerFlags::HoldSync));
+ return mState == HandlerState::GeneratingReports && !mFlags.Has(ReadHandlerFlags::WaitingUntilMinInterval) &&
+ (IsDirty() || !mFlags.Has(ReadHandlerFlags::WaitingUntilMaxInterval));
}
bool IsGeneratingReports() const { return mState == HandlerState::GeneratingReports; }
bool IsAwaitingReportResponse() const { return mState == HandlerState::AwaitingReportResponse; }
@@ -323,10 +326,10 @@
void GetSubscriptionId(SubscriptionId & aSubscriptionId) const { aSubscriptionId = mSubscriptionId; }
AttributePathExpandIterator * GetAttributePathExpandIterator() { return &mAttributePathExpandIterator; }
- /**
- * Notify the read handler that a set of attribute paths has been marked dirty.
- */
- void SetDirty(const AttributePathParams & aAttributeChanged);
+ /// @brief Notifies the read handler that a set of attribute paths has been marked dirty. This will schedule a reporting engine
+ /// run if the change to the attribute path makes the ReadHandler reportable.
+ /// @param aAttributeChanged Path to the attribute that was changed.
+ void AttributePathIsDirty(const AttributePathParams & aAttributeChanged);
bool IsDirty() const
{
return (mDirtyGeneration > mPreviousReportsBeginGeneration) || mFlags.Has(ReadHandlerFlags::ForceDirty);
@@ -349,7 +352,10 @@
auto GetTransactionStartGeneration() const { return mTransactionStartGeneration; }
- void UnblockUrgentEventDelivery();
+ /// @brief Forces the read handler into a dirty state, regardless of what's going on with attributes.
+ /// This can lead to scheduling of a reporting run immediately, if the min interval has been reached,
+ /// or after the min interval is reached if it has not yet been reached.
+ void ForceDirtyState();
const AttributeValueEncoder::AttributeEncodeState & GetAttributeEncodeState() const { return mAttributeEncoderState; }
void SetAttributeEncodeState(const AttributeValueEncoder::AttributeEncodeState & aState) { mAttributeEncoderState = aState; }
@@ -396,9 +402,12 @@
*/
void Close(CloseOptions options = CloseOptions::kDropPersistedSubscription);
- static void OnUnblockHoldReportCallback(System::Layer * apSystemLayer, void * apAppState);
- static void OnRefreshSubscribeTimerSyncCallback(System::Layer * apSystemLayer, void * apAppState);
- CHIP_ERROR RefreshSubscribeSyncTimer();
+ /// @brief This function is called when the min interval timer has expired, it restarts the timer on a timeout equal to the
+ /// difference between the max interval and the min interval.
+ static void MinIntervalExpiredCallback(System::Layer * apSystemLayer, void * apAppState);
+ static void MaxIntervalExpiredCallback(System::Layer * apSystemLayer, void * apAppState);
+ /// @brief This function is called when a report is sent and it restarts the min interval timer.
+ CHIP_ERROR UpdateReportTimer();
CHIP_ERROR SendSubscribeResponse();
CHIP_ERROR ProcessSubscribeRequest(System::PacketBufferHandle && aPayload);
CHIP_ERROR ProcessReadRequest(System::PacketBufferHandle && aPayload);
@@ -416,8 +425,15 @@
void PersistSubscription();
- // Helpers for managing our state flags properly.
+ /// @brief Modifies a state flag in the read handler. If the read handler went from a
+ /// non-reportable state to a reportable state, schedules a reporting engine run.
+ /// @param aFlag Flag to set
+ /// @param aValue Flag new value
void SetStateFlag(ReadHandlerFlags aFlag, bool aValue = true);
+
+ /// @brief This function call SetStateFlag with the flag value set to false, thus possibly emitting a report
+ /// generation.
+ /// @param aFlag Flag to clear
void ClearStateFlag(ReadHandlerFlags aFlag);
// Helpers for continuing the subscription resumption
@@ -436,7 +452,7 @@
// current generation when we started sending the last set reports that we completed.
//
// This allows us to reset the iterator to the beginning of the current
- // cluster instead of the beginning of the whole report in SetDirty, without
+ // cluster instead of the beginning of the whole report in AttributePathIsDirty, without
// permanently missing dirty any paths.
uint64_t mDirtyGeneration = 0;
@@ -450,14 +466,14 @@
/*
* (mDirtyGeneration = b > a, this is a dirty read handler)
* +- Start Report -> mCurrentReportsBeginGeneration = c
- * | +- SetDirty (Attribute Y) -> mDirtyGeneration = d
+ * | +- AttributePathIsDirty (Attribute Y) -> mDirtyGeneration = d
* | | +- Last Chunk -> mPreviousReportsBeginGeneration = mCurrentReportsBeginGeneration = c
* | | | +- (mDirtyGeneration = d) > (mPreviousReportsBeginGeneration = c), this is a dirty read handler
* | | | | Attribute X has a dirty generation less than c, Attribute Y has a dirty generation larger than c
* | | | | So Y will be included in the report but X will not be inclued in this report.
* -a--b--c------d-----e---f---> Generation
* | |
- * | +- SetDirty (Attribute X) (mDirtyGeneration = b)
+ * | +- AttributePathIsDirty (Attribute X) (mDirtyGeneration = b)
* +- mPreviousReportsBeginGeneration
* For read handler, if mDirtyGeneration > mPreviousReportsBeginGeneration, then we regard it as a dirty read handler, and it
* should generate report on timeout reached.
diff --git a/src/app/reporting/Engine.cpp b/src/app/reporting/Engine.cpp
index 0f9d592..a985321 100644
--- a/src/app/reporting/Engine.cpp
+++ b/src/app/reporting/Engine.cpp
@@ -636,7 +636,7 @@
ReadHandler * readHandler = imEngine->ActiveHandlerAt(mCurReadHandlerIdx % (uint32_t) imEngine->mReadHandlers.Allocated());
VerifyOrDie(readHandler != nullptr);
- if (readHandler->IsReportable())
+ if (readHandler->IsReportableNow())
{
mRunningReadHandler = readHandler;
CHIP_ERROR err = BuildAndSendSingleReportData(readHandler);
@@ -826,16 +826,16 @@
bool intersectsInterestPath = false;
InteractionModelEngine::GetInstance()->mReadHandlers.ForEachActiveObject(
[&aAttributePath, &intersectsInterestPath](ReadHandler * handler) {
- // We call SetDirty for both read interactions and subscribe interactions, since we may send inconsistent attribute data
- // between two chunks. SetDirty will be ignored automatically by read handlers which are waiting for a response to the
- // last message chunk for read interactions.
+ // We call AttributePathIsDirty for both read interactions and subscribe interactions, since we may send inconsistent
+ // attribute data between two chunks. AttributePathIsDirty will not schedule a new run for read handlers which are
+ // waiting for a response to the last message chunk for read interactions.
if (handler->IsGeneratingReports() || handler->IsAwaitingReportResponse())
{
for (auto object = handler->GetAttributePathList(); object != nullptr; object = object->mpNext)
{
if (object->mValue.Intersects(aAttributePath))
{
- handler->SetDirty(aAttributePath);
+ handler->AttributePathIsDirty(aAttributePath);
intersectsInterestPath = true;
break;
}
@@ -937,7 +937,7 @@
if (interestedPath->mValue.IsEventPathSupersetOf(aPath) && interestedPath->mValue.mIsUrgentEvent)
{
isUrgentEvent = true;
- handler->UnblockUrgentEventDelivery();
+ handler->ForceDirtyState();
break;
}
}
@@ -967,7 +967,7 @@
return Loop::Continue;
}
- handler->UnblockUrgentEventDelivery();
+ handler->ForceDirtyState();
return Loop::Continue;
});
diff --git a/src/app/tests/TestReadInteraction.cpp b/src/app/tests/TestReadInteraction.cpp
index fe0d2a0..9ec3d59 100644
--- a/src/app/tests/TestReadInteraction.cpp
+++ b/src/app/tests/TestReadInteraction.cpp
@@ -1587,7 +1587,7 @@
dirtyPath5.mAttributeId = 4;
// Test report with 2 different path
- delegate.mpReadHandler->SetStateFlag(ReadHandler::ReadHandlerFlags::HoldReport, false);
+ delegate.mpReadHandler->SetStateFlag(ReadHandler::ReadHandlerFlags::WaitingUntilMinInterval, false);
delegate.mGotReport = false;
delegate.mGotEventResponse = false;
delegate.mNumAttributeResponse = 0;
@@ -1604,7 +1604,7 @@
NL_TEST_ASSERT(apSuite, delegate.mNumAttributeResponse == 2);
// Test report with 2 different path, and 1 same path
- delegate.mpReadHandler->SetStateFlag(ReadHandler::ReadHandlerFlags::HoldReport, false);
+ delegate.mpReadHandler->SetStateFlag(ReadHandler::ReadHandlerFlags::WaitingUntilMinInterval, false);
delegate.mGotReport = false;
delegate.mNumAttributeResponse = 0;
err = engine->GetReportingEngine().SetDirty(dirtyPath1);
@@ -1620,7 +1620,7 @@
NL_TEST_ASSERT(apSuite, delegate.mNumAttributeResponse == 2);
// Test report with 3 different path, and one path is overlapped with another
- delegate.mpReadHandler->SetStateFlag(ReadHandler::ReadHandlerFlags::HoldReport, false);
+ delegate.mpReadHandler->SetStateFlag(ReadHandler::ReadHandlerFlags::WaitingUntilMinInterval, false);
delegate.mGotReport = false;
delegate.mNumAttributeResponse = 0;
err = engine->GetReportingEngine().SetDirty(dirtyPath1);
@@ -1636,7 +1636,7 @@
NL_TEST_ASSERT(apSuite, delegate.mNumAttributeResponse == 2);
// Test report with 3 different path, all are not overlapped, one path is not interested for current subscription
- delegate.mpReadHandler->SetStateFlag(ReadHandler::ReadHandlerFlags::HoldReport, false);
+ delegate.mpReadHandler->SetStateFlag(ReadHandler::ReadHandlerFlags::WaitingUntilMinInterval, false);
delegate.mGotReport = false;
delegate.mNumAttributeResponse = 0;
err = engine->GetReportingEngine().SetDirty(dirtyPath1);
@@ -1652,8 +1652,8 @@
NL_TEST_ASSERT(apSuite, delegate.mNumAttributeResponse == 2);
// Test empty report
- delegate.mpReadHandler->SetStateFlag(ReadHandler::ReadHandlerFlags::HoldReport, false);
- delegate.mpReadHandler->SetStateFlag(ReadHandler::ReadHandlerFlags::HoldSync, false);
+ delegate.mpReadHandler->SetStateFlag(ReadHandler::ReadHandlerFlags::WaitingUntilMinInterval, false);
+ delegate.mpReadHandler->SetStateFlag(ReadHandler::ReadHandlerFlags::WaitingUntilMaxInterval, false);
NL_TEST_ASSERT(apSuite, engine->GetReportingEngine().IsRunScheduled());
delegate.mGotReport = false;
delegate.mNumAttributeResponse = 0;
@@ -1740,12 +1740,13 @@
GenerateEvents(apSuite, apContext);
- NL_TEST_ASSERT(apSuite, delegate.mpReadHandler->mFlags.Has(ReadHandler::ReadHandlerFlags::HoldReport));
+ NL_TEST_ASSERT(apSuite, delegate.mpReadHandler->mFlags.Has(ReadHandler::ReadHandlerFlags::WaitingUntilMinInterval));
NL_TEST_ASSERT(apSuite, delegate.mpReadHandler->IsDirty());
delegate.mGotEventResponse = false;
delegate.mGotReport = false;
- NL_TEST_ASSERT(apSuite, nonUrgentDelegate.mpReadHandler->mFlags.Has(ReadHandler::ReadHandlerFlags::HoldReport));
+ NL_TEST_ASSERT(apSuite,
+ nonUrgentDelegate.mpReadHandler->mFlags.Has(ReadHandler::ReadHandlerFlags::WaitingUntilMinInterval));
NL_TEST_ASSERT(apSuite, !nonUrgentDelegate.mpReadHandler->IsDirty());
nonUrgentDelegate.mGotEventResponse = false;
nonUrgentDelegate.mGotReport = false;
@@ -1781,13 +1782,14 @@
// Since we just sent a report for our urgent subscription, we should have our min interval timer
// running again.
- NL_TEST_ASSERT(apSuite, delegate.mpReadHandler->mFlags.Has(ReadHandler::ReadHandlerFlags::HoldReport));
+ NL_TEST_ASSERT(apSuite, delegate.mpReadHandler->mFlags.Has(ReadHandler::ReadHandlerFlags::WaitingUntilMinInterval));
NL_TEST_ASSERT(apSuite, !delegate.mpReadHandler->IsDirty());
delegate.mGotEventResponse = false;
// For our non-urgent subscription, we did not send anything, so we
// should not have a min interval timer running there.
- NL_TEST_ASSERT(apSuite, !nonUrgentDelegate.mpReadHandler->mFlags.Has(ReadHandler::ReadHandlerFlags::HoldReport));
+ NL_TEST_ASSERT(apSuite,
+ !nonUrgentDelegate.mpReadHandler->mFlags.Has(ReadHandler::ReadHandlerFlags::WaitingUntilMinInterval));
NL_TEST_ASSERT(apSuite, !nonUrgentDelegate.mpReadHandler->IsDirty());
// Wait for the min interval timer to fire.
@@ -1807,15 +1809,16 @@
// min-interval timer should have fired, and our handler should still
// not be dirty or even reportable.
- NL_TEST_ASSERT(apSuite, !delegate.mpReadHandler->mFlags.Has(ReadHandler::ReadHandlerFlags::HoldReport));
+ NL_TEST_ASSERT(apSuite, !delegate.mpReadHandler->mFlags.Has(ReadHandler::ReadHandlerFlags::WaitingUntilMinInterval));
NL_TEST_ASSERT(apSuite, !delegate.mpReadHandler->IsDirty());
- NL_TEST_ASSERT(apSuite, !delegate.mpReadHandler->IsReportable());
+ NL_TEST_ASSERT(apSuite, !delegate.mpReadHandler->IsReportableNow());
// And the non-urgent one should not have changed state either, since
// it's waiting for the max-interval.
- NL_TEST_ASSERT(apSuite, !nonUrgentDelegate.mpReadHandler->mFlags.Has(ReadHandler::ReadHandlerFlags::HoldReport));
+ NL_TEST_ASSERT(apSuite,
+ !nonUrgentDelegate.mpReadHandler->mFlags.Has(ReadHandler::ReadHandlerFlags::WaitingUntilMinInterval));
NL_TEST_ASSERT(apSuite, !nonUrgentDelegate.mpReadHandler->IsDirty());
- NL_TEST_ASSERT(apSuite, !nonUrgentDelegate.mpReadHandler->IsReportable());
+ NL_TEST_ASSERT(apSuite, !nonUrgentDelegate.mpReadHandler->IsReportableNow());
// There should be no reporting run scheduled. This is very important;
// otherwise we can get a false-positive pass below because the run was
@@ -1827,11 +1830,11 @@
// Urgent read handler should now be dirty, and reportable.
NL_TEST_ASSERT(apSuite, delegate.mpReadHandler->IsDirty());
- NL_TEST_ASSERT(apSuite, delegate.mpReadHandler->IsReportable());
+ NL_TEST_ASSERT(apSuite, delegate.mpReadHandler->IsReportableNow());
// Non-urgent read handler should not be reportable.
NL_TEST_ASSERT(apSuite, !nonUrgentDelegate.mpReadHandler->IsDirty());
- NL_TEST_ASSERT(apSuite, !nonUrgentDelegate.mpReadHandler->IsReportable());
+ NL_TEST_ASSERT(apSuite, !nonUrgentDelegate.mpReadHandler->IsReportableNow());
// Still no reporting should have happened.
NL_TEST_ASSERT(apSuite, !delegate.mGotEventResponse);
@@ -1914,7 +1917,7 @@
// Set a concrete path dirty
{
- delegate.mpReadHandler->SetStateFlag(ReadHandler::ReadHandlerFlags::HoldReport, false);
+ delegate.mpReadHandler->SetStateFlag(ReadHandler::ReadHandlerFlags::WaitingUntilMinInterval, false);
delegate.mGotReport = false;
delegate.mNumAttributeResponse = 0;
@@ -1935,7 +1938,7 @@
// Set a endpoint dirty
{
- delegate.mpReadHandler->SetStateFlag(ReadHandler::ReadHandlerFlags::HoldReport, false);
+ delegate.mpReadHandler->SetStateFlag(ReadHandler::ReadHandlerFlags::WaitingUntilMinInterval, false);
delegate.mGotReport = false;
delegate.mNumAttributeResponse = 0;
delegate.mNumArrayItems = 0;
@@ -2027,7 +2030,7 @@
// Set a partial overlapped path dirty
{
- delegate.mpReadHandler->SetStateFlag(ReadHandler::ReadHandlerFlags::HoldReport, false);
+ delegate.mpReadHandler->SetStateFlag(ReadHandler::ReadHandlerFlags::WaitingUntilMinInterval, false);
delegate.mGotReport = false;
delegate.mNumAttributeResponse = 0;
@@ -2104,7 +2107,7 @@
// Set a full overlapped path dirty and expect to receive one E2C3A1
{
- delegate.mpReadHandler->SetStateFlag(ReadHandler::ReadHandlerFlags::HoldReport, false);
+ delegate.mpReadHandler->SetStateFlag(ReadHandler::ReadHandlerFlags::WaitingUntilMinInterval, false);
delegate.mGotReport = false;
delegate.mNumAttributeResponse = 0;
@@ -2225,8 +2228,8 @@
NL_TEST_ASSERT(apSuite, engine->ActiveHandlerAt(0) != nullptr);
delegate.mpReadHandler = engine->ActiveHandlerAt(0);
- delegate.mpReadHandler->SetStateFlag(ReadHandler::ReadHandlerFlags::HoldReport, false);
- delegate.mpReadHandler->SetStateFlag(ReadHandler::ReadHandlerFlags::HoldSync, false);
+ delegate.mpReadHandler->SetStateFlag(ReadHandler::ReadHandlerFlags::WaitingUntilMinInterval, false);
+ delegate.mpReadHandler->SetStateFlag(ReadHandler::ReadHandlerFlags::WaitingUntilMaxInterval, false);
NL_TEST_ASSERT(apSuite, engine->GetReportingEngine().IsRunScheduled());
ctx.DrainAndServiceIO();
@@ -2401,7 +2404,7 @@
dirtyPath2.mAttributeId = 2;
// Test report with 2 different path
- delegate.mpReadHandler->SetStateFlag(ReadHandler::ReadHandlerFlags::HoldReport, false);
+ delegate.mpReadHandler->SetStateFlag(ReadHandler::ReadHandlerFlags::WaitingUntilMinInterval, false);
delegate.mGotReport = false;
delegate.mNumAttributeResponse = 0;
@@ -2415,8 +2418,8 @@
NL_TEST_ASSERT(apSuite, delegate.mGotReport);
NL_TEST_ASSERT(apSuite, delegate.mNumAttributeResponse == 2);
- delegate.mpReadHandler->SetStateFlag(ReadHandler::ReadHandlerFlags::HoldReport, false);
- delegate.mpReadHandler->SetStateFlag(ReadHandler::ReadHandlerFlags::HoldSync, false);
+ delegate.mpReadHandler->SetStateFlag(ReadHandler::ReadHandlerFlags::WaitingUntilMinInterval, false);
+ delegate.mpReadHandler->SetStateFlag(ReadHandler::ReadHandlerFlags::WaitingUntilMaxInterval, false);
delegate.mGotReport = false;
delegate.mNumAttributeResponse = 0;
ctx.ExpireSessionBobToAlice();
@@ -2763,8 +2766,8 @@
dirtyPath1.mEndpointId = Test::kMockEndpoint3;
dirtyPath1.mAttributeId = Test::MockAttributeId(4);
- delegate.mpReadHandler->SetStateFlag(ReadHandler::ReadHandlerFlags::HoldReport, false);
- delegate.mpReadHandler->SetStateFlag(ReadHandler::ReadHandlerFlags::HoldSync, false);
+ delegate.mpReadHandler->SetStateFlag(ReadHandler::ReadHandlerFlags::WaitingUntilMinInterval, false);
+ delegate.mpReadHandler->SetStateFlag(ReadHandler::ReadHandlerFlags::WaitingUntilMaxInterval, false);
err = engine->GetReportingEngine().SetDirty(dirtyPath1);
NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
delegate.mGotReport = false;
@@ -2865,8 +2868,8 @@
dirtyPath1.mEndpointId = Test::kMockEndpoint3;
dirtyPath1.mAttributeId = Test::MockAttributeId(4);
- delegate.mpReadHandler->SetStateFlag(ReadHandler::ReadHandlerFlags::HoldReport, false);
- delegate.mpReadHandler->SetStateFlag(ReadHandler::ReadHandlerFlags::HoldSync, false);
+ delegate.mpReadHandler->SetStateFlag(ReadHandler::ReadHandlerFlags::WaitingUntilMinInterval, false);
+ delegate.mpReadHandler->SetStateFlag(ReadHandler::ReadHandlerFlags::WaitingUntilMaxInterval, false);
err = engine->GetReportingEngine().SetDirty(dirtyPath1);
NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
delegate.mGotReport = false;
@@ -4246,7 +4249,7 @@
NL_TEST_ASSERT(apSuite, SessionHandle(*readHandler->GetSession()) == ctx.GetSessionAliceToBob());
// Test that we send reports as needed.
- readHandler->SetStateFlag(ReadHandler::ReadHandlerFlags::HoldReport, false);
+ readHandler->SetStateFlag(ReadHandler::ReadHandlerFlags::WaitingUntilMinInterval, false);
delegate.mGotReport = false;
delegate.mNumAttributeResponse = 0;
engine->GetReportingEngine().SetDirty(subscribePath);
@@ -4262,7 +4265,7 @@
// Test that if the session is defunct we don't send reports and clean
// up properly.
readHandler->GetSession()->MarkAsDefunct();
- readHandler->SetStateFlag(ReadHandler::ReadHandlerFlags::HoldReport, false);
+ readHandler->SetStateFlag(ReadHandler::ReadHandlerFlags::WaitingUntilMinInterval, false);
delegate.mGotReport = false;
delegate.mNumAttributeResponse = 0;
engine->GetReportingEngine().SetDirty(subscribePath);