diff --git a/src/app/ReadHandler.cpp b/src/app/ReadHandler.cpp index 380cdc9ed582bb..5772ad18691d96 100644 --- a/src/app/ReadHandler.cpp +++ b/src/app/ReadHandler.cpp @@ -58,7 +58,7 @@ CHIP_ERROR ReadHandler::Init(Messaging::ExchangeManager * apExchangeMgr, Interac mInteractionType = aInteractionType; mInitiatorNodeId = apExchangeContext->GetSessionHandle().GetPeerNodeId(); mFabricIndex = apExchangeContext->GetSessionHandle().GetFabricIndex(); - + mHoldSync = false; if (apExchangeContext != nullptr) { apExchangeContext->SetDelegate(this); @@ -110,6 +110,7 @@ void ReadHandler::Shutdown(ShutdownOptions aOptions) mActiveSubscription = false; mIsChunkedReport = false; mInitiatorNodeId = kUndefinedNodeId; + mHoldSync = false; } CHIP_ERROR ReadHandler::OnReadInitialRequest(System::PacketBufferHandle && aPayload) @@ -637,17 +638,21 @@ void ReadHandler::OnUnblockHoldReportCallback(System::Layer * apSystemLayer, voi void ReadHandler::OnRefreshSubscribeTimerSyncCallback(System::Layer * apSystemLayer, void * apAppState) { VerifyOrReturn(apAppState != nullptr); + ReadHandler * readHandler = static_cast(apAppState); + readHandler->mHoldSync = false; + ChipLogProgress(DataManagement, "Refresh subscribe timer sync after max %d seconds", readHandler->mMaxIntervalCeilingSeconds); InteractionModelEngine::GetInstance()->GetReportingEngine().ScheduleRun(); } CHIP_ERROR ReadHandler::RefreshSubscribeSyncTimer() { - ChipLogProgress(DataManagement, "ReadHandler::Refresh Subscribe Sync Timer with %d seconds", mMaxIntervalCeilingSeconds); + ChipLogProgress(DataManagement, "Refresh Subscribe Sync Timer with %d seconds", mMaxIntervalCeilingSeconds); InteractionModelEngine::GetInstance()->GetExchangeManager()->GetSessionManager()->SystemLayer()->CancelTimer( OnUnblockHoldReportCallback, this); InteractionModelEngine::GetInstance()->GetExchangeManager()->GetSessionManager()->SystemLayer()->CancelTimer( OnRefreshSubscribeTimerSyncCallback, this); mHoldReport = true; + mHoldSync = true; ReturnErrorOnFailure( InteractionModelEngine::GetInstance()->GetExchangeManager()->GetSessionManager()->SystemLayer()->StartTimer( System::Clock::Seconds16(mMinIntervalFloorSeconds), OnUnblockHoldReportCallback, this)); diff --git a/src/app/ReadHandler.h b/src/app/ReadHandler.h index 5c474ca703e76e..be6451af897027 100644 --- a/src/app/ReadHandler.h +++ b/src/app/ReadHandler.h @@ -107,7 +107,7 @@ class ReadHandler : public Messaging::ExchangeDelegate CHIP_ERROR SendReportData(System::PacketBufferHandle && aPayload, bool mMoreChunks); bool IsFree() const { return mState == HandlerState::Uninitialized; } - bool IsReportable() const { return mState == HandlerState::GeneratingReports && !mHoldReport; } + bool IsReportable() const { return mState == HandlerState::GeneratingReports && !mHoldReport && (mDirty || !mHoldSync); } bool IsGeneratingReports() const { return mState == HandlerState::GeneratingReports; } bool IsAwaitingReportResponse() const { return mState == HandlerState::AwaitingReportResponse; } virtual ~ReadHandler() = default; @@ -214,6 +214,7 @@ class ReadHandler : public Messaging::ExchangeDelegate FabricIndex mFabricIndex = 0; AttributePathExpandIterator mAttributePathExpandIterator = AttributePathExpandIterator(nullptr); bool mIsFabricFiltered = false; + bool mHoldSync = false; }; } // namespace app } // namespace chip diff --git a/src/app/tests/TestReadInteraction.cpp b/src/app/tests/TestReadInteraction.cpp index 6da78d25a274c5..40d0340048af34 100644 --- a/src/app/tests/TestReadInteraction.cpp +++ b/src/app/tests/TestReadInteraction.cpp @@ -1106,6 +1106,7 @@ void TestReadInteraction::TestSubscribeRoundtrip(nlTestSuite * apSuite, void * a // Test empty report delegate.mpReadHandler->mHoldReport = false; + delegate.mpReadHandler->mHoldSync = false; delegate.mGotReport = false; delegate.mNumAttributeResponse = 0; engine->GetReportingEngine().Run();