diff --git a/src/app/BufferedReadCallback.cpp b/src/app/BufferedReadCallback.cpp index d780504e80a6b5..91e9739e4794c4 100644 --- a/src/app/BufferedReadCallback.cpp +++ b/src/app/BufferedReadCallback.cpp @@ -36,8 +36,12 @@ void BufferedReadCallback::OnReportBegin() void BufferedReadCallback::OnReportEnd() { - mLastError = DispatchBufferedData(mBufferedPath, StatusIB(), true); - ReturnOnFailure(mLastError); + mDataBufferingError = DispatchBufferedData(mBufferedPath, StatusIB(), true); + if (mDataBufferingError != CHIP_NO_ERROR) + { + mCallback.OnError(mDataBufferingError); + return; + } mCallback.OnReportEnd(); } @@ -225,19 +229,27 @@ CHIP_ERROR BufferedReadCallback::DispatchBufferedData(const ConcreteAttributePat void BufferedReadCallback::OnAttributeData(const ConcreteDataAttributePath & aPath, TLV::TLVReader * apData, const StatusIB & aStatus) { + if (mDataBufferingError != CHIP_NO_ERROR) + { + ChipLogError(DataManagement, + "Skipping AttributeData: (%u, " ChipLogFormatMEI ", " ChipLogFormatMEI ") '%" CHIP_ERROR_FORMAT "'", + aPath.mEndpointId, ChipLogValueMEI(aPath.mClusterId), + ChipLogValueMEI(aPath.mAttributeId), mDataBufferingError.Format()); + return; + } // // First, let's dispatch to our registered callback any buffered up list data from previous calls. // - mLastError = DispatchBufferedData(aPath, aStatus); - ReturnOnFailure(mLastError); + mDataBufferingError = DispatchBufferedData(aPath, aStatus); + SuccessOrExit(mDataBufferingError); // // We buffer up list data (only if the status was successful) // if (aPath.IsListOperation() && aStatus.mStatus == Protocols::InteractionModel::Status::Success) { - mLastError = BufferData(aPath, apData); - ReturnOnFailure(mLastError); + mDataBufferingError = BufferData(aPath, apData); + SuccessOrExit(mDataBufferingError); } else { @@ -248,6 +260,12 @@ void BufferedReadCallback::OnAttributeData(const ConcreteDataAttributePath & aPa // Update our latched buffered path. // mBufferedPath = aPath; + +exit: + if (mDataBufferingError != CHIP_NO_ERROR) + { + mCallback.OnError(mDataBufferingError); + } } } // namespace app diff --git a/src/app/BufferedReadCallback.h b/src/app/BufferedReadCallback.h index 57931469bda25a..ed65646ec553e2 100644 --- a/src/app/BufferedReadCallback.h +++ b/src/app/BufferedReadCallback.h @@ -43,18 +43,6 @@ class BufferedReadCallback : public ReadClient::Callback BufferedReadCallback(Callback & callback) : mCallback(callback) {} private: - /* - * Get the last internal fatal error in BufferedReadCallback - * @retval #CHIP_NO_ERROR If the method succeeded. - * @retval #CHIP_ERROR_INVALID_TLV_ELEMENT - * If bufferred list data is not TLV Array - * @retval #CHIP_ERROR_NO_MEMORY - * If an attempt to allocate an buffer failed due to lack of - * memory. - * @retval other Other CHIP or platform-specific errors. - */ - CHIP_ERROR GetLastError() const override { return mLastError; } - /* * Generates the reconstituted TLV array from the stored individual list elements */ @@ -86,7 +74,6 @@ class BufferedReadCallback : public ReadClient::Callback void OnError(CHIP_ERROR aError) override { mBufferedList.clear(); - mLastError = CHIP_NO_ERROR; return mCallback.OnError(aError); } @@ -144,7 +131,7 @@ class BufferedReadCallback : public ReadClient::Callback ConcreteDataAttributePath mBufferedPath; std::vector mBufferedList; Callback & mCallback; - CHIP_ERROR mLastError = CHIP_NO_ERROR; + CHIP_ERROR mDataBufferingError = CHIP_NO_ERROR; }; } // namespace app diff --git a/src/app/ReadClient.cpp b/src/app/ReadClient.cpp index b2837e19ceb9d6..2d609eb1afa05a 100644 --- a/src/app/ReadClient.cpp +++ b/src/app/ReadClient.cpp @@ -868,7 +868,8 @@ CHIP_ERROR ReadClient::ProcessAttributeReportIBs(TLV::TLVReader & aAttributeRepo { err = CHIP_NO_ERROR; } - return mpCallback.GetLastError(); + + return err; } CHIP_ERROR ReadClient::ProcessEventReportIBs(TLV::TLVReader & aEventReportIBsReader) diff --git a/src/app/ReadClient.h b/src/app/ReadClient.h index a1a69f0e22ae3a..d8b8a971db8c28 100644 --- a/src/app/ReadClient.h +++ b/src/app/ReadClient.h @@ -284,11 +284,6 @@ class ReadClient : public Messaging::ExchangeDelegate * things like min/max intervals based on the session parameters). */ virtual void OnCASESessionEstablished(const SessionHandle & aSession, ReadPrepareParams & aSubscriptionParams) {} - - /* - * Get the last internal fatal error in callback - */ - virtual CHIP_ERROR GetLastError() const { return CHIP_NO_ERROR; } }; enum class InteractionType : uint8_t