Skip to content

Commit

Permalink
Optimize report begin/end in read client side (#12443)
Browse files Browse the repository at this point in the history
-- Add mIsInitialReport to signify the begin for chunk reports
-- Rename mInitialReport to mIsPrimingReports to mark the first report
for read/subscription client
  • Loading branch information
yunhanw-google authored and pull[bot] committed Apr 11, 2023
1 parent ece0f5f commit 49408f0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
14 changes: 9 additions & 5 deletions src/app/ReadClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ CHIP_ERROR ReadClient::Init(Messaging::ExchangeManager * apExchangeMgr, Callback
mMinIntervalFloorSeconds = 0;
mMaxIntervalCeilingSeconds = 0;
mSubscriptionId = 0;
mInitialReport = true;
mIsInitialReport = true;
mIsPrimingReports = true;
mInteractionType = aInteractionType;
AbortExistingExchangeContext();

Expand Down Expand Up @@ -79,7 +80,8 @@ void ReadClient::ShutdownInternal(CHIP_ERROR aError)
mInteractionType = InteractionType::Read;
mpExchangeMgr = nullptr;
mpExchangeCtx = nullptr;
mInitialReport = true;
mIsInitialReport = true;
mIsPrimingReports = true;
mPeerNodeId = kUndefinedNodeId;
mFabricIndex = kUndefinedFabricIndex;
MoveToState(ClientState::Uninitialized);
Expand Down Expand Up @@ -322,7 +324,7 @@ CHIP_ERROR ReadClient::ProcessReportData(System::PacketBufferHandle && aPayload)
err = report.GetSubscriptionId(&subscriptionId);
if (CHIP_NO_ERROR == err)
{
if (IsInitialReport())
if (mIsPrimingReports)
{
mSubscriptionId = subscriptionId;
}
Expand Down Expand Up @@ -380,9 +382,10 @@ CHIP_ERROR ReadClient::ProcessReportData(System::PacketBufferHandle && aPayload)
TLV::TLVReader attributeReportIBsReader;
attributeReportIBs.GetReader(&attributeReportIBsReader);

if (IsInitialReport())
if (mIsInitialReport)
{
mpCallback->OnReportBegin(this);
mIsInitialReport = false;
}

err = ProcessAttributeReportIBs(attributeReportIBsReader);
Expand All @@ -391,6 +394,7 @@ CHIP_ERROR ReadClient::ProcessReportData(System::PacketBufferHandle && aPayload)
if (!mPendingMoreChunks)
{
mpCallback->OnReportEnd(this);
mIsInitialReport = true;
}
}

Expand Down Expand Up @@ -420,7 +424,7 @@ CHIP_ERROR ReadClient::ProcessReportData(System::PacketBufferHandle && aPayload)
}
}

mInitialReport = false;
mIsPrimingReports = false;
return err;
}

Expand Down
4 changes: 2 additions & 2 deletions src/app/ReadClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -294,12 +294,12 @@ class ReadClient : public Messaging::ExchangeDelegate
* our exchange and don't need to manually close it.
*/
void ShutdownInternal(CHIP_ERROR aError);
bool IsInitialReport() { return mInitialReport; }
Messaging::ExchangeManager * mpExchangeMgr = nullptr;
Messaging::ExchangeContext * mpExchangeCtx = nullptr;
Callback * mpCallback = nullptr;
ClientState mState = ClientState::Uninitialized;
bool mInitialReport = true;
bool mIsInitialReport = true;
bool mIsPrimingReports = true;
bool mPendingMoreChunks = false;
uint16_t mMinIntervalFloorSeconds = 0;
uint16_t mMaxIntervalCeilingSeconds = 0;
Expand Down

0 comments on commit 49408f0

Please sign in to comment.