From 5ed22f5f3314b5adbd36f6168c7e49e8d278be5b Mon Sep 17 00:00:00 2001 From: mahesh Date: Tue, 10 Dec 2024 11:09:06 +0530 Subject: [PATCH 1/7] BDX: update reset and endLogCollection to distinguish success and failure cases --- .../diagnostic-logs-provider-delegate-impl.cpp | 4 ++-- .../diagnostic-logs-provider-delegate-impl.h | 2 +- .../include/DiagnosticLogsProviderDelegateImpl.h | 2 +- .../DiagnosticLogsProviderDelegateImpl.cpp | 4 ++-- .../diagnostic-logs-provider-delegate-impl.cpp | 4 ++-- .../diagnostic-logs-provider-delegate-impl.h | 2 +- .../BDXDiagnosticLogsProvider.cpp | 16 ++++++++-------- .../BDXDiagnosticLogsProvider.h | 2 +- .../DiagnosticLogsProviderDelegate.h | 3 ++- 9 files changed, 20 insertions(+), 19 deletions(-) diff --git a/examples/all-clusters-app/linux/diagnostic-logs-provider-delegate-impl.cpp b/examples/all-clusters-app/linux/diagnostic-logs-provider-delegate-impl.cpp index afb75a7ef666c4..9d641fc824f16c 100644 --- a/examples/all-clusters-app/linux/diagnostic-logs-provider-delegate-impl.cpp +++ b/examples/all-clusters-app/linux/diagnostic-logs-provider-delegate-impl.cpp @@ -79,7 +79,7 @@ CHIP_ERROR LogProvider::GetLogForIntent(IntentEnum intent, MutableByteSpan & out err = CollectLog(sessionHandle, outBuffer, unusedOutIsEndOfLog); VerifyOrReturnError(CHIP_NO_ERROR == err, err, outBuffer.reduce_size(0)); - err = EndLogCollection(sessionHandle); + err = EndLogCollection(sessionHandle, CHIP_NO_ERROR); VerifyOrReturnError(CHIP_NO_ERROR == err, err, outBuffer.reduce_size(0)); return CHIP_NO_ERROR; @@ -106,7 +106,7 @@ CHIP_ERROR LogProvider::StartLogCollection(IntentEnum intent, LogSessionHandle & return CHIP_NO_ERROR; } -CHIP_ERROR LogProvider::EndLogCollection(LogSessionHandle sessionHandle) +CHIP_ERROR LogProvider::EndLogCollection(LogSessionHandle sessionHandle, CHIP_ERROR error) { VerifyOrReturnValue(sessionHandle != kInvalidLogSessionHandle, CHIP_ERROR_INVALID_ARGUMENT); VerifyOrReturnValue(mFiles.count(sessionHandle), CHIP_ERROR_INVALID_ARGUMENT); diff --git a/examples/all-clusters-app/linux/include/diagnostic-logs-provider-delegate-impl.h b/examples/all-clusters-app/linux/include/diagnostic-logs-provider-delegate-impl.h index f90c8d600f4526..f52ffda3fde03a 100644 --- a/examples/all-clusters-app/linux/include/diagnostic-logs-provider-delegate-impl.h +++ b/examples/all-clusters-app/linux/include/diagnostic-logs-provider-delegate-impl.h @@ -48,7 +48,7 @@ class LogProvider : public DiagnosticLogsProviderDelegate /////////// DiagnosticLogsProviderDelegate Interface ///////// CHIP_ERROR StartLogCollection(IntentEnum intent, LogSessionHandle & outHandle, Optional & outTimeStamp, Optional & outTimeSinceBoot) override; - CHIP_ERROR EndLogCollection(LogSessionHandle sessionHandle) override; + CHIP_ERROR EndLogCollection(LogSessionHandle sessionHandle, CHIP_ERROR error) override; CHIP_ERROR CollectLog(LogSessionHandle sessionHandle, MutableByteSpan & outBuffer, bool & outIsEndOfLog) override; size_t GetSizeForIntent(IntentEnum intent) override; CHIP_ERROR GetLogForIntent(IntentEnum intent, MutableByteSpan & outBuffer, Optional & outTimeStamp, diff --git a/examples/platform/nxp/common/diagnostic_logs/include/DiagnosticLogsProviderDelegateImpl.h b/examples/platform/nxp/common/diagnostic_logs/include/DiagnosticLogsProviderDelegateImpl.h index 73d60f542aacdc..b1ff9b453563f2 100644 --- a/examples/platform/nxp/common/diagnostic_logs/include/DiagnosticLogsProviderDelegateImpl.h +++ b/examples/platform/nxp/common/diagnostic_logs/include/DiagnosticLogsProviderDelegateImpl.h @@ -41,7 +41,7 @@ class LogProvider : public DiagnosticLogsProviderDelegate /////////// DiagnosticLogsProviderDelegate Interface ///////// CHIP_ERROR StartLogCollection(IntentEnum intent, LogSessionHandle & outHandle, Optional & outTimeStamp, Optional & outTimeSinceBoot) override; - CHIP_ERROR EndLogCollection(LogSessionHandle sessionHandle) override; + CHIP_ERROR EndLogCollection(LogSessionHandle sessionHandle, CHIP_ERROR error) override; CHIP_ERROR CollectLog(LogSessionHandle sessionHandle, MutableByteSpan & outBuffer, bool & outIsEndOfLog) override; size_t GetSizeForIntent(IntentEnum intent) override; CHIP_ERROR GetLogForIntent(IntentEnum intent, MutableByteSpan & outBuffer, Optional & outTimeStamp, diff --git a/examples/platform/nxp/common/diagnostic_logs/source/DiagnosticLogsProviderDelegateImpl.cpp b/examples/platform/nxp/common/diagnostic_logs/source/DiagnosticLogsProviderDelegateImpl.cpp index 929905afad828f..12c4e0a3dac291 100644 --- a/examples/platform/nxp/common/diagnostic_logs/source/DiagnosticLogsProviderDelegateImpl.cpp +++ b/examples/platform/nxp/common/diagnostic_logs/source/DiagnosticLogsProviderDelegateImpl.cpp @@ -48,7 +48,7 @@ CHIP_ERROR LogProvider::GetLogForIntent(IntentEnum intent, MutableByteSpan & out err = CollectLog(sessionHandle, outBuffer, unusedOutIsEndOfLog); VerifyOrReturnError(CHIP_NO_ERROR == err, err, outBuffer.reduce_size(0)); - err = EndLogCollection(sessionHandle); + err = EndLogCollection(sessionHandle, CHIP_NO_ERROR); VerifyOrReturnError(CHIP_NO_ERROR == err, err, outBuffer.reduce_size(0)); return CHIP_NO_ERROR; @@ -89,7 +89,7 @@ CHIP_ERROR LogProvider::StartLogCollection(IntentEnum intent, LogSessionHandle & return CHIP_NO_ERROR; } -CHIP_ERROR LogProvider::EndLogCollection(LogSessionHandle sessionHandle) +CHIP_ERROR LogProvider::EndLogCollection(LogSessionHandle sessionHandle, CHIP_ERROR error) { VerifyOrReturnValue(sessionHandle != kInvalidLogSessionHandle, CHIP_ERROR_INVALID_ARGUMENT); VerifyOrReturnValue(mSessionSpanMap.count(sessionHandle), CHIP_ERROR_INVALID_ARGUMENT); diff --git a/examples/temperature-measurement-app/esp32/main/diagnostic-logs-provider-delegate-impl.cpp b/examples/temperature-measurement-app/esp32/main/diagnostic-logs-provider-delegate-impl.cpp index 55336ea76030dd..9ece5cee34bc20 100644 --- a/examples/temperature-measurement-app/esp32/main/diagnostic-logs-provider-delegate-impl.cpp +++ b/examples/temperature-measurement-app/esp32/main/diagnostic-logs-provider-delegate-impl.cpp @@ -65,7 +65,7 @@ CHIP_ERROR LogProvider::GetLogForIntent(IntentEnum intent, MutableByteSpan & out err = CollectLog(sessionHandle, outBuffer, unusedOutIsEndOfLog); VerifyOrReturnError(CHIP_NO_ERROR == err, err, outBuffer.reduce_size(0)); - err = EndLogCollection(sessionHandle); + err = EndLogCollection(sessionHandle, CHIP_NO_ERROR); VerifyOrReturnError(CHIP_NO_ERROR == err, err, outBuffer.reduce_size(0)); return CHIP_NO_ERROR; @@ -276,7 +276,7 @@ CHIP_ERROR LogProvider::StartLogCollection(IntentEnum intent, LogSessionHandle & return CHIP_NO_ERROR; } -CHIP_ERROR LogProvider::EndLogCollection(LogSessionHandle sessionHandle) +CHIP_ERROR LogProvider::EndLogCollection(LogSessionHandle sessionHandle, CHIP_ERROR error) { VerifyOrReturnValue(sessionHandle != kInvalidLogSessionHandle, CHIP_ERROR_INVALID_ARGUMENT); VerifyOrReturnValue(mSessionContextMap.count(sessionHandle), CHIP_ERROR_INVALID_ARGUMENT); diff --git a/examples/temperature-measurement-app/esp32/main/include/diagnostic-logs-provider-delegate-impl.h b/examples/temperature-measurement-app/esp32/main/include/diagnostic-logs-provider-delegate-impl.h index 3431a54adc86a8..fc1350ed3ec265 100644 --- a/examples/temperature-measurement-app/esp32/main/include/diagnostic-logs-provider-delegate-impl.h +++ b/examples/temperature-measurement-app/esp32/main/include/diagnostic-logs-provider-delegate-impl.h @@ -44,7 +44,7 @@ class LogProvider : public DiagnosticLogsProviderDelegate /////////// DiagnosticLogsProviderDelegate Interface ///////// CHIP_ERROR StartLogCollection(IntentEnum intent, LogSessionHandle & outHandle, Optional & outTimeStamp, Optional & outTimeSinceBoot) override; - CHIP_ERROR EndLogCollection(LogSessionHandle sessionHandle) override; + CHIP_ERROR EndLogCollection(LogSessionHandle sessionHandle, CHIP_ERROR error) override; CHIP_ERROR CollectLog(LogSessionHandle sessionHandle, MutableByteSpan & outBuffer, bool & outIsEndOfLog) override; size_t GetSizeForIntent(IntentEnum intent) override; CHIP_ERROR GetLogForIntent(IntentEnum intent, MutableByteSpan & outBuffer, Optional & outTimeStamp, diff --git a/src/app/clusters/diagnostic-logs-server/BDXDiagnosticLogsProvider.cpp b/src/app/clusters/diagnostic-logs-server/BDXDiagnosticLogsProvider.cpp index 6119652990679f..469f462b872c5e 100644 --- a/src/app/clusters/diagnostic-logs-server/BDXDiagnosticLogsProvider.cpp +++ b/src/app/clusters/diagnostic-logs-server/BDXDiagnosticLogsProvider.cpp @@ -162,7 +162,7 @@ void BDXDiagnosticLogsProvider::OnMsgToSend(TransferSession::OutputEvent & event auto err = mBDXTransferExchangeCtx->SendMessage(msgTypeData.ProtocolId, msgTypeData.MessageType, std::move(event.MsgData), sendFlags); - VerifyOrDo(CHIP_NO_ERROR == err, Reset()); + VerifyOrDo(CHIP_NO_ERROR == err, Reset(err)); } void BDXDiagnosticLogsProvider::OnAcceptReceived() @@ -191,7 +191,7 @@ void BDXDiagnosticLogsProvider::OnAckReceived() // If the buffer has empty space, end the log collection session. if (isEndOfLog) { - mDelegate->EndLogCollection(mLogSessionHandle); + mDelegate->EndLogCollection(mLogSessionHandle, CHIP_NO_ERROR); mLogSessionHandle = kInvalidLogSessionHandle; } @@ -213,7 +213,7 @@ void BDXDiagnosticLogsProvider::OnAckEOFReceived() { ChipLogProgress(BDX, "Diagnostic logs transfer: Success"); - Reset(); + Reset(CHIP_NO_ERROR); } void BDXDiagnosticLogsProvider::OnStatusReceived(TransferSession::OutputEvent & event) @@ -223,21 +223,21 @@ void BDXDiagnosticLogsProvider::OnStatusReceived(TransferSession::OutputEvent & // If a failure StatusReport is received in response to the SendInit message, the Node SHALL send a RetrieveLogsResponse command // with a Status of Denied. VerifyOrDo(mIsAcceptReceived, SendCommandResponse(StatusEnum::kDenied)); - Reset(); + Reset(CHIP_ERROR_INCORRECT_STATE); } void BDXDiagnosticLogsProvider::OnInternalError() { ChipLogError(BDX, "Internal Error"); VerifyOrDo(mIsAcceptReceived, SendCommandResponse(StatusEnum::kDenied)); - Reset(); + Reset(CHIP_ERROR_INTERNAL); } void BDXDiagnosticLogsProvider::OnTimeout() { ChipLogError(BDX, "Timeout"); VerifyOrDo(mIsAcceptReceived, SendCommandResponse(StatusEnum::kDenied)); - Reset(); + Reset(CHIP_ERROR_TIMEOUT); } void BDXDiagnosticLogsProvider::SendCommandResponse(StatusEnum status) @@ -264,7 +264,7 @@ void BDXDiagnosticLogsProvider::SendCommandResponse(StatusEnum status) commandHandle->AddResponse(mRequestPath, response); } -void BDXDiagnosticLogsProvider::Reset() +void BDXDiagnosticLogsProvider::Reset(CHIP_ERROR error) { assertChipStackLockedByCurrentThread(); @@ -279,7 +279,7 @@ void BDXDiagnosticLogsProvider::Reset() if (mDelegate != nullptr) { - mDelegate->EndLogCollection(mLogSessionHandle); + mDelegate->EndLogCollection(mLogSessionHandle, error); mDelegate = nullptr; } diff --git a/src/app/clusters/diagnostic-logs-server/BDXDiagnosticLogsProvider.h b/src/app/clusters/diagnostic-logs-server/BDXDiagnosticLogsProvider.h index 6122998eae986c..b4294fcc756759 100644 --- a/src/app/clusters/diagnostic-logs-server/BDXDiagnosticLogsProvider.h +++ b/src/app/clusters/diagnostic-logs-server/BDXDiagnosticLogsProvider.h @@ -77,7 +77,7 @@ class BDXDiagnosticLogsProvider : public bdx::Initiator * This method is called to reset state. It resets the transfer, cleans up the * exchange and ends log collection. */ - void Reset(); + void Reset(CHIP_ERROR error); Messaging::ExchangeContext * mBDXTransferExchangeCtx; DiagnosticLogsProviderDelegate * mDelegate; diff --git a/src/app/clusters/diagnostic-logs-server/DiagnosticLogsProviderDelegate.h b/src/app/clusters/diagnostic-logs-server/DiagnosticLogsProviderDelegate.h index dc511fdacadeaa..96bbae63ef558c 100644 --- a/src/app/clusters/diagnostic-logs-server/DiagnosticLogsProviderDelegate.h +++ b/src/app/clusters/diagnostic-logs-server/DiagnosticLogsProviderDelegate.h @@ -59,9 +59,10 @@ class DiagnosticLogsProviderDelegate * returned from StartLogCollection. * * @param[in] sessionHandle The unique handle for this log session returned from a call to StartLogCollection. + * @param[in] error A CHIP_ERROR value that indicates the reason for ending the log collection. * */ - virtual CHIP_ERROR EndLogCollection(LogSessionHandle sessionHandle) = 0; + virtual CHIP_ERROR EndLogCollection(LogSessionHandle sessionHandle, CHIP_ERROR error) = 0; /** * Called to get the next chunk for the log session identified by sessionHandle. From f9f21b4550559f2d2887fd08e6ea694ff34da024 Mon Sep 17 00:00:00 2001 From: mahesh Date: Wed, 11 Dec 2024 12:29:08 +0530 Subject: [PATCH 2/7] diagnostic-logs-cluster: make changes backword compatible --- .../linux/diagnostic-logs-provider-delegate-impl.cpp | 2 +- .../linux/include/diagnostic-logs-provider-delegate-impl.h | 2 +- .../include/DiagnosticLogsProviderDelegateImpl.h | 2 +- .../source/DiagnosticLogsProviderDelegateImpl.cpp | 2 +- .../esp32/main/diagnostic-logs-provider-delegate-impl.cpp | 2 +- .../main/include/diagnostic-logs-provider-delegate-impl.h | 2 +- .../diagnostic-logs-server/BDXDiagnosticLogsProvider.cpp | 4 ++-- .../diagnostic-logs-server/BDXDiagnosticLogsProvider.h | 4 +++- .../diagnostic-logs-server/DiagnosticLogsProviderDelegate.h | 5 +++-- 9 files changed, 14 insertions(+), 11 deletions(-) diff --git a/examples/all-clusters-app/linux/diagnostic-logs-provider-delegate-impl.cpp b/examples/all-clusters-app/linux/diagnostic-logs-provider-delegate-impl.cpp index 9d641fc824f16c..48ae4ae13b3863 100644 --- a/examples/all-clusters-app/linux/diagnostic-logs-provider-delegate-impl.cpp +++ b/examples/all-clusters-app/linux/diagnostic-logs-provider-delegate-impl.cpp @@ -79,7 +79,7 @@ CHIP_ERROR LogProvider::GetLogForIntent(IntentEnum intent, MutableByteSpan & out err = CollectLog(sessionHandle, outBuffer, unusedOutIsEndOfLog); VerifyOrReturnError(CHIP_NO_ERROR == err, err, outBuffer.reduce_size(0)); - err = EndLogCollection(sessionHandle, CHIP_NO_ERROR); + err = EndLogCollection(sessionHandle); VerifyOrReturnError(CHIP_NO_ERROR == err, err, outBuffer.reduce_size(0)); return CHIP_NO_ERROR; diff --git a/examples/all-clusters-app/linux/include/diagnostic-logs-provider-delegate-impl.h b/examples/all-clusters-app/linux/include/diagnostic-logs-provider-delegate-impl.h index f52ffda3fde03a..28daba63837cc3 100644 --- a/examples/all-clusters-app/linux/include/diagnostic-logs-provider-delegate-impl.h +++ b/examples/all-clusters-app/linux/include/diagnostic-logs-provider-delegate-impl.h @@ -48,7 +48,7 @@ class LogProvider : public DiagnosticLogsProviderDelegate /////////// DiagnosticLogsProviderDelegate Interface ///////// CHIP_ERROR StartLogCollection(IntentEnum intent, LogSessionHandle & outHandle, Optional & outTimeStamp, Optional & outTimeSinceBoot) override; - CHIP_ERROR EndLogCollection(LogSessionHandle sessionHandle, CHIP_ERROR error) override; + CHIP_ERROR EndLogCollection(LogSessionHandle sessionHandle, CHIP_ERROR error = CHIP_NO_ERROR) override; CHIP_ERROR CollectLog(LogSessionHandle sessionHandle, MutableByteSpan & outBuffer, bool & outIsEndOfLog) override; size_t GetSizeForIntent(IntentEnum intent) override; CHIP_ERROR GetLogForIntent(IntentEnum intent, MutableByteSpan & outBuffer, Optional & outTimeStamp, diff --git a/examples/platform/nxp/common/diagnostic_logs/include/DiagnosticLogsProviderDelegateImpl.h b/examples/platform/nxp/common/diagnostic_logs/include/DiagnosticLogsProviderDelegateImpl.h index b1ff9b453563f2..12152fb47dfddb 100644 --- a/examples/platform/nxp/common/diagnostic_logs/include/DiagnosticLogsProviderDelegateImpl.h +++ b/examples/platform/nxp/common/diagnostic_logs/include/DiagnosticLogsProviderDelegateImpl.h @@ -41,7 +41,7 @@ class LogProvider : public DiagnosticLogsProviderDelegate /////////// DiagnosticLogsProviderDelegate Interface ///////// CHIP_ERROR StartLogCollection(IntentEnum intent, LogSessionHandle & outHandle, Optional & outTimeStamp, Optional & outTimeSinceBoot) override; - CHIP_ERROR EndLogCollection(LogSessionHandle sessionHandle, CHIP_ERROR error) override; + CHIP_ERROR EndLogCollection(LogSessionHandle sessionHandle, CHIP_ERROR error = CHIP_NO_ERROR) override; CHIP_ERROR CollectLog(LogSessionHandle sessionHandle, MutableByteSpan & outBuffer, bool & outIsEndOfLog) override; size_t GetSizeForIntent(IntentEnum intent) override; CHIP_ERROR GetLogForIntent(IntentEnum intent, MutableByteSpan & outBuffer, Optional & outTimeStamp, diff --git a/examples/platform/nxp/common/diagnostic_logs/source/DiagnosticLogsProviderDelegateImpl.cpp b/examples/platform/nxp/common/diagnostic_logs/source/DiagnosticLogsProviderDelegateImpl.cpp index 12c4e0a3dac291..e684455acaf2b8 100644 --- a/examples/platform/nxp/common/diagnostic_logs/source/DiagnosticLogsProviderDelegateImpl.cpp +++ b/examples/platform/nxp/common/diagnostic_logs/source/DiagnosticLogsProviderDelegateImpl.cpp @@ -48,7 +48,7 @@ CHIP_ERROR LogProvider::GetLogForIntent(IntentEnum intent, MutableByteSpan & out err = CollectLog(sessionHandle, outBuffer, unusedOutIsEndOfLog); VerifyOrReturnError(CHIP_NO_ERROR == err, err, outBuffer.reduce_size(0)); - err = EndLogCollection(sessionHandle, CHIP_NO_ERROR); + err = EndLogCollection(sessionHandle); VerifyOrReturnError(CHIP_NO_ERROR == err, err, outBuffer.reduce_size(0)); return CHIP_NO_ERROR; diff --git a/examples/temperature-measurement-app/esp32/main/diagnostic-logs-provider-delegate-impl.cpp b/examples/temperature-measurement-app/esp32/main/diagnostic-logs-provider-delegate-impl.cpp index 9ece5cee34bc20..0fce2abd8c0ca7 100644 --- a/examples/temperature-measurement-app/esp32/main/diagnostic-logs-provider-delegate-impl.cpp +++ b/examples/temperature-measurement-app/esp32/main/diagnostic-logs-provider-delegate-impl.cpp @@ -65,7 +65,7 @@ CHIP_ERROR LogProvider::GetLogForIntent(IntentEnum intent, MutableByteSpan & out err = CollectLog(sessionHandle, outBuffer, unusedOutIsEndOfLog); VerifyOrReturnError(CHIP_NO_ERROR == err, err, outBuffer.reduce_size(0)); - err = EndLogCollection(sessionHandle, CHIP_NO_ERROR); + err = EndLogCollection(sessionHandle); VerifyOrReturnError(CHIP_NO_ERROR == err, err, outBuffer.reduce_size(0)); return CHIP_NO_ERROR; diff --git a/examples/temperature-measurement-app/esp32/main/include/diagnostic-logs-provider-delegate-impl.h b/examples/temperature-measurement-app/esp32/main/include/diagnostic-logs-provider-delegate-impl.h index fc1350ed3ec265..853086c6824b5e 100644 --- a/examples/temperature-measurement-app/esp32/main/include/diagnostic-logs-provider-delegate-impl.h +++ b/examples/temperature-measurement-app/esp32/main/include/diagnostic-logs-provider-delegate-impl.h @@ -44,7 +44,7 @@ class LogProvider : public DiagnosticLogsProviderDelegate /////////// DiagnosticLogsProviderDelegate Interface ///////// CHIP_ERROR StartLogCollection(IntentEnum intent, LogSessionHandle & outHandle, Optional & outTimeStamp, Optional & outTimeSinceBoot) override; - CHIP_ERROR EndLogCollection(LogSessionHandle sessionHandle, CHIP_ERROR error) override; + CHIP_ERROR EndLogCollection(LogSessionHandle sessionHandle, CHIP_ERROR error = CHIP_NO_ERROR) override; CHIP_ERROR CollectLog(LogSessionHandle sessionHandle, MutableByteSpan & outBuffer, bool & outIsEndOfLog) override; size_t GetSizeForIntent(IntentEnum intent) override; CHIP_ERROR GetLogForIntent(IntentEnum intent, MutableByteSpan & outBuffer, Optional & outTimeStamp, diff --git a/src/app/clusters/diagnostic-logs-server/BDXDiagnosticLogsProvider.cpp b/src/app/clusters/diagnostic-logs-server/BDXDiagnosticLogsProvider.cpp index 469f462b872c5e..bbdd826d5f3343 100644 --- a/src/app/clusters/diagnostic-logs-server/BDXDiagnosticLogsProvider.cpp +++ b/src/app/clusters/diagnostic-logs-server/BDXDiagnosticLogsProvider.cpp @@ -191,7 +191,7 @@ void BDXDiagnosticLogsProvider::OnAckReceived() // If the buffer has empty space, end the log collection session. if (isEndOfLog) { - mDelegate->EndLogCollection(mLogSessionHandle, CHIP_NO_ERROR); + mDelegate->EndLogCollection(mLogSessionHandle); mLogSessionHandle = kInvalidLogSessionHandle; } @@ -213,7 +213,7 @@ void BDXDiagnosticLogsProvider::OnAckEOFReceived() { ChipLogProgress(BDX, "Diagnostic logs transfer: Success"); - Reset(CHIP_NO_ERROR); + Reset(); } void BDXDiagnosticLogsProvider::OnStatusReceived(TransferSession::OutputEvent & event) diff --git a/src/app/clusters/diagnostic-logs-server/BDXDiagnosticLogsProvider.h b/src/app/clusters/diagnostic-logs-server/BDXDiagnosticLogsProvider.h index b4294fcc756759..ddf355b70c90ed 100644 --- a/src/app/clusters/diagnostic-logs-server/BDXDiagnosticLogsProvider.h +++ b/src/app/clusters/diagnostic-logs-server/BDXDiagnosticLogsProvider.h @@ -76,8 +76,10 @@ class BDXDiagnosticLogsProvider : public bdx::Initiator /** * This method is called to reset state. It resets the transfer, cleans up the * exchange and ends log collection. + * @param[in] error A CHIP_ERROR value indicating the reason for resetting the state. + * It is permissible to pass CHIP_NO_ERROR to indicate normal termination. */ - void Reset(CHIP_ERROR error); + void Reset(CHIP_ERROR error = CHIP_NO_ERROR); Messaging::ExchangeContext * mBDXTransferExchangeCtx; DiagnosticLogsProviderDelegate * mDelegate; diff --git a/src/app/clusters/diagnostic-logs-server/DiagnosticLogsProviderDelegate.h b/src/app/clusters/diagnostic-logs-server/DiagnosticLogsProviderDelegate.h index 96bbae63ef558c..aa03af34d02c11 100644 --- a/src/app/clusters/diagnostic-logs-server/DiagnosticLogsProviderDelegate.h +++ b/src/app/clusters/diagnostic-logs-server/DiagnosticLogsProviderDelegate.h @@ -59,10 +59,11 @@ class DiagnosticLogsProviderDelegate * returned from StartLogCollection. * * @param[in] sessionHandle The unique handle for this log session returned from a call to StartLogCollection. - * @param[in] error A CHIP_ERROR value that indicates the reason for ending the log collection. + * @param[in] error A CHIP_ERROR value indicating the reason for ending the log collection. + * It is permissible to pass CHIP_NO_ERROR to indicate normal termination. * */ - virtual CHIP_ERROR EndLogCollection(LogSessionHandle sessionHandle, CHIP_ERROR error) = 0; + virtual CHIP_ERROR EndLogCollection(LogSessionHandle sessionHandle, CHIP_ERROR error = CHIP_NO_ERROR) = 0; /** * Called to get the next chunk for the log session identified by sessionHandle. From 62a5660ac83e14445ecf5084f3a56317191c99e9 Mon Sep 17 00:00:00 2001 From: mahesh Date: Wed, 11 Dec 2024 18:23:58 +0530 Subject: [PATCH 3/7] diagnostic-logs-cluster: remove default parameter from Reset() method --- .../diagnostic-logs-server/BDXDiagnosticLogsProvider.cpp | 2 +- .../clusters/diagnostic-logs-server/BDXDiagnosticLogsProvider.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/clusters/diagnostic-logs-server/BDXDiagnosticLogsProvider.cpp b/src/app/clusters/diagnostic-logs-server/BDXDiagnosticLogsProvider.cpp index bbdd826d5f3343..83c43e3919215e 100644 --- a/src/app/clusters/diagnostic-logs-server/BDXDiagnosticLogsProvider.cpp +++ b/src/app/clusters/diagnostic-logs-server/BDXDiagnosticLogsProvider.cpp @@ -213,7 +213,7 @@ void BDXDiagnosticLogsProvider::OnAckEOFReceived() { ChipLogProgress(BDX, "Diagnostic logs transfer: Success"); - Reset(); + Reset(CHIP_NO_ERROR); } void BDXDiagnosticLogsProvider::OnStatusReceived(TransferSession::OutputEvent & event) diff --git a/src/app/clusters/diagnostic-logs-server/BDXDiagnosticLogsProvider.h b/src/app/clusters/diagnostic-logs-server/BDXDiagnosticLogsProvider.h index ddf355b70c90ed..a80b04a3d61c5c 100644 --- a/src/app/clusters/diagnostic-logs-server/BDXDiagnosticLogsProvider.h +++ b/src/app/clusters/diagnostic-logs-server/BDXDiagnosticLogsProvider.h @@ -79,7 +79,7 @@ class BDXDiagnosticLogsProvider : public bdx::Initiator * @param[in] error A CHIP_ERROR value indicating the reason for resetting the state. * It is permissible to pass CHIP_NO_ERROR to indicate normal termination. */ - void Reset(CHIP_ERROR error = CHIP_NO_ERROR); + void Reset(CHIP_ERROR error); Messaging::ExchangeContext * mBDXTransferExchangeCtx; DiagnosticLogsProviderDelegate * mDelegate; From ba2fd006d80303db136849f9b7e2e3289c7dbbcc Mon Sep 17 00:00:00 2001 From: mahesh Date: Fri, 13 Dec 2024 11:36:43 +0530 Subject: [PATCH 4/7] diagnostic-logs-delegate: Add default implementation for EndLogCollection overload - Provides a default implementation for the EndLogCollection method with an additional error parameter. - This ensures backward compatibility, reduces the need for overriding in derived classes, and supports scenarios requiring context for log collection termination. --- ...diagnostic-logs-provider-delegate-impl.cpp | 2 +- .../diagnostic-logs-provider-delegate-impl.h | 2 +- .../DiagnosticLogsProviderDelegateImpl.h | 2 +- .../DiagnosticLogsProviderDelegateImpl.cpp | 2 +- ...diagnostic-logs-provider-delegate-impl.cpp | 22 ++++++++++++++++++- .../diagnostic-logs-provider-delegate-impl.h | 3 ++- .../DiagnosticLogsProviderDelegate.h | 21 +++++++++++++++++- 7 files changed, 47 insertions(+), 7 deletions(-) diff --git a/examples/all-clusters-app/linux/diagnostic-logs-provider-delegate-impl.cpp b/examples/all-clusters-app/linux/diagnostic-logs-provider-delegate-impl.cpp index 48ae4ae13b3863..afb75a7ef666c4 100644 --- a/examples/all-clusters-app/linux/diagnostic-logs-provider-delegate-impl.cpp +++ b/examples/all-clusters-app/linux/diagnostic-logs-provider-delegate-impl.cpp @@ -106,7 +106,7 @@ CHIP_ERROR LogProvider::StartLogCollection(IntentEnum intent, LogSessionHandle & return CHIP_NO_ERROR; } -CHIP_ERROR LogProvider::EndLogCollection(LogSessionHandle sessionHandle, CHIP_ERROR error) +CHIP_ERROR LogProvider::EndLogCollection(LogSessionHandle sessionHandle) { VerifyOrReturnValue(sessionHandle != kInvalidLogSessionHandle, CHIP_ERROR_INVALID_ARGUMENT); VerifyOrReturnValue(mFiles.count(sessionHandle), CHIP_ERROR_INVALID_ARGUMENT); diff --git a/examples/all-clusters-app/linux/include/diagnostic-logs-provider-delegate-impl.h b/examples/all-clusters-app/linux/include/diagnostic-logs-provider-delegate-impl.h index 28daba63837cc3..f90c8d600f4526 100644 --- a/examples/all-clusters-app/linux/include/diagnostic-logs-provider-delegate-impl.h +++ b/examples/all-clusters-app/linux/include/diagnostic-logs-provider-delegate-impl.h @@ -48,7 +48,7 @@ class LogProvider : public DiagnosticLogsProviderDelegate /////////// DiagnosticLogsProviderDelegate Interface ///////// CHIP_ERROR StartLogCollection(IntentEnum intent, LogSessionHandle & outHandle, Optional & outTimeStamp, Optional & outTimeSinceBoot) override; - CHIP_ERROR EndLogCollection(LogSessionHandle sessionHandle, CHIP_ERROR error = CHIP_NO_ERROR) override; + CHIP_ERROR EndLogCollection(LogSessionHandle sessionHandle) override; CHIP_ERROR CollectLog(LogSessionHandle sessionHandle, MutableByteSpan & outBuffer, bool & outIsEndOfLog) override; size_t GetSizeForIntent(IntentEnum intent) override; CHIP_ERROR GetLogForIntent(IntentEnum intent, MutableByteSpan & outBuffer, Optional & outTimeStamp, diff --git a/examples/platform/nxp/common/diagnostic_logs/include/DiagnosticLogsProviderDelegateImpl.h b/examples/platform/nxp/common/diagnostic_logs/include/DiagnosticLogsProviderDelegateImpl.h index 12152fb47dfddb..73d60f542aacdc 100644 --- a/examples/platform/nxp/common/diagnostic_logs/include/DiagnosticLogsProviderDelegateImpl.h +++ b/examples/platform/nxp/common/diagnostic_logs/include/DiagnosticLogsProviderDelegateImpl.h @@ -41,7 +41,7 @@ class LogProvider : public DiagnosticLogsProviderDelegate /////////// DiagnosticLogsProviderDelegate Interface ///////// CHIP_ERROR StartLogCollection(IntentEnum intent, LogSessionHandle & outHandle, Optional & outTimeStamp, Optional & outTimeSinceBoot) override; - CHIP_ERROR EndLogCollection(LogSessionHandle sessionHandle, CHIP_ERROR error = CHIP_NO_ERROR) override; + CHIP_ERROR EndLogCollection(LogSessionHandle sessionHandle) override; CHIP_ERROR CollectLog(LogSessionHandle sessionHandle, MutableByteSpan & outBuffer, bool & outIsEndOfLog) override; size_t GetSizeForIntent(IntentEnum intent) override; CHIP_ERROR GetLogForIntent(IntentEnum intent, MutableByteSpan & outBuffer, Optional & outTimeStamp, diff --git a/examples/platform/nxp/common/diagnostic_logs/source/DiagnosticLogsProviderDelegateImpl.cpp b/examples/platform/nxp/common/diagnostic_logs/source/DiagnosticLogsProviderDelegateImpl.cpp index e684455acaf2b8..929905afad828f 100644 --- a/examples/platform/nxp/common/diagnostic_logs/source/DiagnosticLogsProviderDelegateImpl.cpp +++ b/examples/platform/nxp/common/diagnostic_logs/source/DiagnosticLogsProviderDelegateImpl.cpp @@ -89,7 +89,7 @@ CHIP_ERROR LogProvider::StartLogCollection(IntentEnum intent, LogSessionHandle & return CHIP_NO_ERROR; } -CHIP_ERROR LogProvider::EndLogCollection(LogSessionHandle sessionHandle, CHIP_ERROR error) +CHIP_ERROR LogProvider::EndLogCollection(LogSessionHandle sessionHandle) { VerifyOrReturnValue(sessionHandle != kInvalidLogSessionHandle, CHIP_ERROR_INVALID_ARGUMENT); VerifyOrReturnValue(mSessionSpanMap.count(sessionHandle), CHIP_ERROR_INVALID_ARGUMENT); diff --git a/examples/temperature-measurement-app/esp32/main/diagnostic-logs-provider-delegate-impl.cpp b/examples/temperature-measurement-app/esp32/main/diagnostic-logs-provider-delegate-impl.cpp index 0fce2abd8c0ca7..4558cf3cb65ac6 100644 --- a/examples/temperature-measurement-app/esp32/main/diagnostic-logs-provider-delegate-impl.cpp +++ b/examples/temperature-measurement-app/esp32/main/diagnostic-logs-provider-delegate-impl.cpp @@ -276,7 +276,7 @@ CHIP_ERROR LogProvider::StartLogCollection(IntentEnum intent, LogSessionHandle & return CHIP_NO_ERROR; } -CHIP_ERROR LogProvider::EndLogCollection(LogSessionHandle sessionHandle, CHIP_ERROR error) +CHIP_ERROR LogProvider::EndLogCollection(LogSessionHandle sessionHandle) { VerifyOrReturnValue(sessionHandle != kInvalidLogSessionHandle, CHIP_ERROR_INVALID_ARGUMENT); VerifyOrReturnValue(mSessionContextMap.count(sessionHandle), CHIP_ERROR_INVALID_ARGUMENT); @@ -291,6 +291,26 @@ CHIP_ERROR LogProvider::EndLogCollection(LogSessionHandle sessionHandle, CHIP_ER return CHIP_NO_ERROR; } +CHIP_ERROR LogProvider::EndLogCollection(LogSessionHandle sessionHandle, CHIP_ERROR error) +{ + if (error != CHIP_NO_ERROR) + { + // Handle the error + ChipLogError(DeviceLayer, "End log collection reason: %s", ErrorStr(error)); + } + VerifyOrReturnValue(sessionHandle != kInvalidLogSessionHandle, CHIP_ERROR_INVALID_ARGUMENT); + VerifyOrReturnValue(mSessionContextMap.count(sessionHandle), CHIP_ERROR_INVALID_ARGUMENT); + + LogContext * context = mSessionContextMap[sessionHandle]; + VerifyOrReturnError(context, CHIP_ERROR_INCORRECT_STATE); + + CleanupLogContextForIntent(context); + Platform::MemoryFree(context); + mSessionContextMap.erase(sessionHandle); + + return error; +} + CHIP_ERROR LogProvider::CollectLog(LogSessionHandle sessionHandle, MutableByteSpan & outBuffer, bool & outIsEndOfLog) { VerifyOrReturnValue(sessionHandle != kInvalidLogSessionHandle, CHIP_ERROR_INVALID_ARGUMENT); diff --git a/examples/temperature-measurement-app/esp32/main/include/diagnostic-logs-provider-delegate-impl.h b/examples/temperature-measurement-app/esp32/main/include/diagnostic-logs-provider-delegate-impl.h index 853086c6824b5e..708f8bf017d858 100644 --- a/examples/temperature-measurement-app/esp32/main/include/diagnostic-logs-provider-delegate-impl.h +++ b/examples/temperature-measurement-app/esp32/main/include/diagnostic-logs-provider-delegate-impl.h @@ -44,7 +44,8 @@ class LogProvider : public DiagnosticLogsProviderDelegate /////////// DiagnosticLogsProviderDelegate Interface ///////// CHIP_ERROR StartLogCollection(IntentEnum intent, LogSessionHandle & outHandle, Optional & outTimeStamp, Optional & outTimeSinceBoot) override; - CHIP_ERROR EndLogCollection(LogSessionHandle sessionHandle, CHIP_ERROR error = CHIP_NO_ERROR) override; + CHIP_ERROR EndLogCollection(LogSessionHandle sessionHandle) override; + CHIP_ERROR EndLogCollection(LogSessionHandle sessionHandle, CHIP_ERROR error) override; CHIP_ERROR CollectLog(LogSessionHandle sessionHandle, MutableByteSpan & outBuffer, bool & outIsEndOfLog) override; size_t GetSizeForIntent(IntentEnum intent) override; CHIP_ERROR GetLogForIntent(IntentEnum intent, MutableByteSpan & outBuffer, Optional & outTimeStamp, diff --git a/src/app/clusters/diagnostic-logs-server/DiagnosticLogsProviderDelegate.h b/src/app/clusters/diagnostic-logs-server/DiagnosticLogsProviderDelegate.h index aa03af34d02c11..f2d3a19732e2f3 100644 --- a/src/app/clusters/diagnostic-logs-server/DiagnosticLogsProviderDelegate.h +++ b/src/app/clusters/diagnostic-logs-server/DiagnosticLogsProviderDelegate.h @@ -59,11 +59,30 @@ class DiagnosticLogsProviderDelegate * returned from StartLogCollection. * * @param[in] sessionHandle The unique handle for this log session returned from a call to StartLogCollection. + * + */ + virtual CHIP_ERROR EndLogCollection(LogSessionHandle sessionHandle) = 0; + + /** + * Called to end log collection for the log session identified by sessionHandle. + * This must be called if StartLogCollection happens successfully and a valid sessionHandle has been + * returned from StartLogCollection. + * + * This overload of EndLogCollection provides additional context through the error parameter, which + * can be used to indicate the reason for ending the log collection. + * + * @param[in] sessionHandle The unique handle for this log session returned from a call to StartLogCollection. * @param[in] error A CHIP_ERROR value indicating the reason for ending the log collection. * It is permissible to pass CHIP_NO_ERROR to indicate normal termination. + * @note Derived classes can override this method to handle additional termination logic specific to their + * implementation. If not overridden, this default implementation calls EndLogCollection with only + * sessionHandle. * */ - virtual CHIP_ERROR EndLogCollection(LogSessionHandle sessionHandle, CHIP_ERROR error = CHIP_NO_ERROR) = 0; + virtual CHIP_ERROR EndLogCollection(LogSessionHandle sessionHandle, CHIP_ERROR error) + { + return EndLogCollection(sessionHandle); + } /** * Called to get the next chunk for the log session identified by sessionHandle. From 3fa183a099189187fe86e1d878987d6cbaefcee6 Mon Sep 17 00:00:00 2001 From: mahesh Date: Thu, 19 Dec 2024 12:54:52 +0530 Subject: [PATCH 5/7] diagnostic-logs-delegate: Add default implementation for EndLogCollection - The one-argument EndLogCollection method is retained for backward compatibility. - The new two-argument overloaded EndLogCollection method will serve as the primary method to be implemented in delegates. --- .../diagnostic-logs-provider-delegate-impl.cpp | 17 +---------------- .../diagnostic-logs-provider-delegate-impl.h | 1 - .../BDXDiagnosticLogsProvider.cpp | 12 ++++++++++-- .../DiagnosticLogsProviderDelegate.h | 11 ++++++----- 4 files changed, 17 insertions(+), 24 deletions(-) diff --git a/examples/temperature-measurement-app/esp32/main/diagnostic-logs-provider-delegate-impl.cpp b/examples/temperature-measurement-app/esp32/main/diagnostic-logs-provider-delegate-impl.cpp index 4558cf3cb65ac6..df0c6b589a00cc 100644 --- a/examples/temperature-measurement-app/esp32/main/diagnostic-logs-provider-delegate-impl.cpp +++ b/examples/temperature-measurement-app/esp32/main/diagnostic-logs-provider-delegate-impl.cpp @@ -65,7 +65,7 @@ CHIP_ERROR LogProvider::GetLogForIntent(IntentEnum intent, MutableByteSpan & out err = CollectLog(sessionHandle, outBuffer, unusedOutIsEndOfLog); VerifyOrReturnError(CHIP_NO_ERROR == err, err, outBuffer.reduce_size(0)); - err = EndLogCollection(sessionHandle); + err = EndLogCollection(sessionHandle, err); VerifyOrReturnError(CHIP_NO_ERROR == err, err, outBuffer.reduce_size(0)); return CHIP_NO_ERROR; @@ -276,21 +276,6 @@ CHIP_ERROR LogProvider::StartLogCollection(IntentEnum intent, LogSessionHandle & return CHIP_NO_ERROR; } -CHIP_ERROR LogProvider::EndLogCollection(LogSessionHandle sessionHandle) -{ - VerifyOrReturnValue(sessionHandle != kInvalidLogSessionHandle, CHIP_ERROR_INVALID_ARGUMENT); - VerifyOrReturnValue(mSessionContextMap.count(sessionHandle), CHIP_ERROR_INVALID_ARGUMENT); - - LogContext * context = mSessionContextMap[sessionHandle]; - VerifyOrReturnError(context, CHIP_ERROR_INCORRECT_STATE); - - CleanupLogContextForIntent(context); - Platform::MemoryFree(context); - mSessionContextMap.erase(sessionHandle); - - return CHIP_NO_ERROR; -} - CHIP_ERROR LogProvider::EndLogCollection(LogSessionHandle sessionHandle, CHIP_ERROR error) { if (error != CHIP_NO_ERROR) diff --git a/examples/temperature-measurement-app/esp32/main/include/diagnostic-logs-provider-delegate-impl.h b/examples/temperature-measurement-app/esp32/main/include/diagnostic-logs-provider-delegate-impl.h index 708f8bf017d858..fc1350ed3ec265 100644 --- a/examples/temperature-measurement-app/esp32/main/include/diagnostic-logs-provider-delegate-impl.h +++ b/examples/temperature-measurement-app/esp32/main/include/diagnostic-logs-provider-delegate-impl.h @@ -44,7 +44,6 @@ class LogProvider : public DiagnosticLogsProviderDelegate /////////// DiagnosticLogsProviderDelegate Interface ///////// CHIP_ERROR StartLogCollection(IntentEnum intent, LogSessionHandle & outHandle, Optional & outTimeStamp, Optional & outTimeSinceBoot) override; - CHIP_ERROR EndLogCollection(LogSessionHandle sessionHandle) override; CHIP_ERROR EndLogCollection(LogSessionHandle sessionHandle, CHIP_ERROR error) override; CHIP_ERROR CollectLog(LogSessionHandle sessionHandle, MutableByteSpan & outBuffer, bool & outIsEndOfLog) override; size_t GetSizeForIntent(IntentEnum intent) override; diff --git a/src/app/clusters/diagnostic-logs-server/BDXDiagnosticLogsProvider.cpp b/src/app/clusters/diagnostic-logs-server/BDXDiagnosticLogsProvider.cpp index 83c43e3919215e..82ad50f5f7039f 100644 --- a/src/app/clusters/diagnostic-logs-server/BDXDiagnosticLogsProvider.cpp +++ b/src/app/clusters/diagnostic-logs-server/BDXDiagnosticLogsProvider.cpp @@ -191,7 +191,11 @@ void BDXDiagnosticLogsProvider::OnAckReceived() // If the buffer has empty space, end the log collection session. if (isEndOfLog) { - mDelegate->EndLogCollection(mLogSessionHandle); + err = mDelegate->EndLogCollection(mLogSessionHandle, err); + if (err == CHIP_ERROR_NOT_IMPLEMENTED) + { + ChipLogError(DeviceLayer, "EndLogCollection not implemented in the delegate. Falling back to default behavior."); + } mLogSessionHandle = kInvalidLogSessionHandle; } @@ -279,7 +283,11 @@ void BDXDiagnosticLogsProvider::Reset(CHIP_ERROR error) if (mDelegate != nullptr) { - mDelegate->EndLogCollection(mLogSessionHandle, error); + CHIP_ERROR err = mDelegate->EndLogCollection(mLogSessionHandle, error); + if (err == CHIP_ERROR_NOT_IMPLEMENTED) + { + ChipLogError(DeviceLayer, "EndLogCollection not implemented in the delegate. Falling back to default behavior."); + } mDelegate = nullptr; } diff --git a/src/app/clusters/diagnostic-logs-server/DiagnosticLogsProviderDelegate.h b/src/app/clusters/diagnostic-logs-server/DiagnosticLogsProviderDelegate.h index f2d3a19732e2f3..f3076eb63be810 100644 --- a/src/app/clusters/diagnostic-logs-server/DiagnosticLogsProviderDelegate.h +++ b/src/app/clusters/diagnostic-logs-server/DiagnosticLogsProviderDelegate.h @@ -58,10 +58,13 @@ class DiagnosticLogsProviderDelegate * This must be called if StartLogCollection happens successfully and a valid sessionHandle has been * returned from StartLogCollection. * - * @param[in] sessionHandle The unique handle for this log session returned from a call to StartLogCollection. + * @note New implementations should override the two-argument version instead, as it is the primary + * method invoked during log collection. * + * @param[in] sessionHandle The unique handle for this log session returned from a call to StartLogCollection. + * @return CHIP_ERROR_NOT_IMPLEMENTED by default unless overridden. */ - virtual CHIP_ERROR EndLogCollection(LogSessionHandle sessionHandle) = 0; + virtual CHIP_ERROR EndLogCollection(LogSessionHandle sessionHandle) { return CHIP_ERROR_NOT_IMPLEMENTED; } /** * Called to end log collection for the log session identified by sessionHandle. @@ -74,9 +77,7 @@ class DiagnosticLogsProviderDelegate * @param[in] sessionHandle The unique handle for this log session returned from a call to StartLogCollection. * @param[in] error A CHIP_ERROR value indicating the reason for ending the log collection. * It is permissible to pass CHIP_NO_ERROR to indicate normal termination. - * @note Derived classes can override this method to handle additional termination logic specific to their - * implementation. If not overridden, this default implementation calls EndLogCollection with only - * sessionHandle. + * @return CHIP_ERROR_NOT_IMPLEMENTED by default unless overridden. * */ virtual CHIP_ERROR EndLogCollection(LogSessionHandle sessionHandle, CHIP_ERROR error) From 433b19d2828a9ababe29f581a7660b811864185c Mon Sep 17 00:00:00 2001 From: mahesh Date: Fri, 20 Dec 2024 12:20:31 +0530 Subject: [PATCH 6/7] fix: remove unnecessary chip log statements --- .../BDXDiagnosticLogsProvider.cpp | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/app/clusters/diagnostic-logs-server/BDXDiagnosticLogsProvider.cpp b/src/app/clusters/diagnostic-logs-server/BDXDiagnosticLogsProvider.cpp index 82ad50f5f7039f..83c43e3919215e 100644 --- a/src/app/clusters/diagnostic-logs-server/BDXDiagnosticLogsProvider.cpp +++ b/src/app/clusters/diagnostic-logs-server/BDXDiagnosticLogsProvider.cpp @@ -191,11 +191,7 @@ void BDXDiagnosticLogsProvider::OnAckReceived() // If the buffer has empty space, end the log collection session. if (isEndOfLog) { - err = mDelegate->EndLogCollection(mLogSessionHandle, err); - if (err == CHIP_ERROR_NOT_IMPLEMENTED) - { - ChipLogError(DeviceLayer, "EndLogCollection not implemented in the delegate. Falling back to default behavior."); - } + mDelegate->EndLogCollection(mLogSessionHandle); mLogSessionHandle = kInvalidLogSessionHandle; } @@ -283,11 +279,7 @@ void BDXDiagnosticLogsProvider::Reset(CHIP_ERROR error) if (mDelegate != nullptr) { - CHIP_ERROR err = mDelegate->EndLogCollection(mLogSessionHandle, error); - if (err == CHIP_ERROR_NOT_IMPLEMENTED) - { - ChipLogError(DeviceLayer, "EndLogCollection not implemented in the delegate. Falling back to default behavior."); - } + mDelegate->EndLogCollection(mLogSessionHandle, error); mDelegate = nullptr; } From 54d091682483ff0b4b94733976b62405b3a3e25e Mon Sep 17 00:00:00 2001 From: mahesh Date: Mon, 23 Dec 2024 12:07:36 +0530 Subject: [PATCH 7/7] BDX: modify EndLogCollection parameter for internal log end requests --- .../esp32/main/diagnostic-logs-provider-delegate-impl.cpp | 2 +- .../diagnostic-logs-server/BDXDiagnosticLogsProvider.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/temperature-measurement-app/esp32/main/diagnostic-logs-provider-delegate-impl.cpp b/examples/temperature-measurement-app/esp32/main/diagnostic-logs-provider-delegate-impl.cpp index df0c6b589a00cc..705c2f653c9d8f 100644 --- a/examples/temperature-measurement-app/esp32/main/diagnostic-logs-provider-delegate-impl.cpp +++ b/examples/temperature-measurement-app/esp32/main/diagnostic-logs-provider-delegate-impl.cpp @@ -281,7 +281,7 @@ CHIP_ERROR LogProvider::EndLogCollection(LogSessionHandle sessionHandle, CHIP_ER if (error != CHIP_NO_ERROR) { // Handle the error - ChipLogError(DeviceLayer, "End log collection reason: %s", ErrorStr(error)); + ChipLogProgress(DeviceLayer, "End log collection reason: %s", ErrorStr(error)); } VerifyOrReturnValue(sessionHandle != kInvalidLogSessionHandle, CHIP_ERROR_INVALID_ARGUMENT); VerifyOrReturnValue(mSessionContextMap.count(sessionHandle), CHIP_ERROR_INVALID_ARGUMENT); diff --git a/src/app/clusters/diagnostic-logs-server/BDXDiagnosticLogsProvider.cpp b/src/app/clusters/diagnostic-logs-server/BDXDiagnosticLogsProvider.cpp index 83c43e3919215e..fc231531e56d95 100644 --- a/src/app/clusters/diagnostic-logs-server/BDXDiagnosticLogsProvider.cpp +++ b/src/app/clusters/diagnostic-logs-server/BDXDiagnosticLogsProvider.cpp @@ -191,7 +191,7 @@ void BDXDiagnosticLogsProvider::OnAckReceived() // If the buffer has empty space, end the log collection session. if (isEndOfLog) { - mDelegate->EndLogCollection(mLogSessionHandle); + mDelegate->EndLogCollection(mLogSessionHandle, CHIP_ERROR_INTERNAL); mLogSessionHandle = kInvalidLogSessionHandle; }