From 52a3dbfbf166b2988f4a54c1398784eeb950a08b Mon Sep 17 00:00:00 2001 From: yunhanw-google Date: Thu, 17 Nov 2022 12:42:14 -0800 Subject: [PATCH] improve get last report data path api in cluster cache (#23431) -- Return not found error if the last report data path is not concrete cluster path -- Add doxygen --- src/app/ClusterStateCache.cpp | 8 ++++++-- src/app/ClusterStateCache.h | 4 ++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/app/ClusterStateCache.cpp b/src/app/ClusterStateCache.cpp index 1ccff3e5567f67..5497dfd453098c 100644 --- a/src/app/ClusterStateCache.cpp +++ b/src/app/ClusterStateCache.cpp @@ -534,8 +534,12 @@ CHIP_ERROR ClusterStateCache::OnUpdateDataVersionFilterList(DataVersionFilterIBs CHIP_ERROR ClusterStateCache::GetLastReportDataPath(ConcreteClusterPath & aPath) { - aPath = mLastReportDataPath; - return CHIP_NO_ERROR; + if (mLastReportDataPath.IsValidConcreteClusterPath()) + { + aPath = mLastReportDataPath; + return CHIP_NO_ERROR; + } + return CHIP_ERROR_INCORRECT_STATE; } } // namespace app } // namespace chip diff --git a/src/app/ClusterStateCache.h b/src/app/ClusterStateCache.h index c6c545e501a9da..4b88b054e1c2a8 100644 --- a/src/app/ClusterStateCache.h +++ b/src/app/ClusterStateCache.h @@ -483,6 +483,10 @@ class ClusterStateCache : protected ReadClient::Callback mEventStatusCache.clear(); } + /* + * Get the last concrete report data path, if path is not concrete cluster path, return CHIP_ERROR_NOT_FOUND + * + */ CHIP_ERROR GetLastReportDataPath(ConcreteClusterPath & aPath); private: