From 5ce58a1e032577aef66a61f43aa87d5c7c6b72b1 Mon Sep 17 00:00:00 2001 From: lpbeliveau-silabs Date: Thu, 20 Jul 2023 09:49:22 -0400 Subject: [PATCH 01/10] Added mechanism to emit report when switching to active mode if necessary --- src/app/icd/ICDManager.cpp | 2 + src/app/reporting/ReportScheduler.h | 62 ++++++++++++++++++++++++----- 2 files changed, 54 insertions(+), 10 deletions(-) diff --git a/src/app/icd/ICDManager.cpp b/src/app/icd/ICDManager.cpp index 853fd044d36732..183a95ba498301 100644 --- a/src/app/icd/ICDManager.cpp +++ b/src/app/icd/ICDManager.cpp @@ -152,6 +152,8 @@ void ICDManager::UpdateOperationState(OperationalState state) { ChipLogError(AppServer, "Failed to set Polling Interval: err %" CHIP_ERROR_FORMAT, err.Format()); } + + InteractionModelEngine::GetInstance()->GetReportScheduler()->OnActiveModeEntered(); } else { diff --git a/src/app/reporting/ReportScheduler.h b/src/app/reporting/ReportScheduler.h index d691e4b36889ed..971cf86a11a4a8 100644 --- a/src/app/reporting/ReportScheduler.h +++ b/src/app/reporting/ReportScheduler.h @@ -69,8 +69,14 @@ class ReportScheduler : public ReadHandler::Observer MinIntervalElapsed = (1 << 0), MaxIntervalElapsed = (1 << 1), }; - void SetTestFlags(TestFlags aFlag, bool aValue) { mFlags.Set(aFlag, aValue); } - bool GetTestFlags(TestFlags aFlag) const { return mFlags.Has(aFlag); } + void SetTestFlags(TestFlags aFlag, bool aValue) + { + mFlags.Set(aFlag, aValue); + } + bool GetTestFlags(TestFlags aFlag) const + { + return mFlags.Has(aFlag); + } #endif // CONFIG_BUILD_FOR_HOST_UNIT_TEST ReadHandlerNode(ReadHandler * aReadHandler, TimerDelegate * aTimerDelegate, ReportScheduler * aScheduler) : @@ -83,7 +89,10 @@ class ReportScheduler : public ReadHandler::Observer mReadHandler = aReadHandler; SetIntervalTimeStamps(aReadHandler); } - ReadHandler * GetReadHandler() const { return mReadHandler; } + ReadHandler * GetReadHandler() const + { + return mReadHandler; + } /// @brief Check if the Node is reportable now, meaning its readhandler was made reportable by attribute dirtying and /// handler state, and minimal time interval since last report has elapsed, or the maximal time interval since last @@ -102,7 +111,10 @@ class ReportScheduler : public ReadHandler::Observer #endif // CONFIG_BUILD_FOR_HOST_UNIT_TEST } - bool IsEngineRunScheduled() const { return mEngineRunScheduled; } + bool IsEngineRunScheduled() const + { + return mEngineRunScheduled; + } void SetEngineRunScheduled(bool aEngineRunScheduled) { mEngineRunScheduled = aEngineRunScheduled; @@ -140,9 +152,18 @@ class ReportScheduler : public ReadHandler::Observer mSyncTimestamp = aSyncTimestamp; } - System::Clock::Timestamp GetMinTimestamp() const { return mMinTimestamp; } - System::Clock::Timestamp GetMaxTimestamp() const { return mMaxTimestamp; } - System::Clock::Timestamp GetSyncTimestamp() const { return mSyncTimestamp; } + System::Clock::Timestamp GetMinTimestamp() const + { + return mMinTimestamp; + } + System::Clock::Timestamp GetMaxTimestamp() const + { + return mMaxTimestamp; + } + System::Clock::Timestamp GetSyncTimestamp() const + { + return mSyncTimestamp; + } private: #ifdef CONFIG_BUILD_FOR_HOST_UNIT_TEST @@ -167,14 +188,35 @@ class ReportScheduler : public ReadHandler::Observer virtual void ReportTimerCallback() = 0; + void OnActiveModeEntered() + { + for (auto & iter : mReadHandlerList) + { + if (iter.IsReportableNow()) + { + OnBecameReportable(iter.GetReadHandler()); + break; + } + } + } + /// @brief Check whether a ReadHandler is reportable right now, taking into account its minimum and maximum intervals. /// @param aReadHandler read handler to check - bool IsReportableNow(ReadHandler * aReadHandler) { return FindReadHandlerNode(aReadHandler)->IsReportableNow(); } + bool IsReportableNow(ReadHandler * aReadHandler) + { + return FindReadHandlerNode(aReadHandler)->IsReportableNow(); + } /// @brief Check if a ReadHandler is reportable without considering the timing - bool IsReadHandlerReportable(ReadHandler * aReadHandler) const { return aReadHandler->IsReportable(); } + bool IsReadHandlerReportable(ReadHandler * aReadHandler) const + { + return aReadHandler->IsReportable(); + } /// @brief Get the number of ReadHandlers registered in the scheduler's node pool - size_t GetNumReadHandlers() const { return mNodesPool.Allocated(); } + size_t GetNumReadHandlers() const + { + return mNodesPool.Allocated(); + } #ifdef CONFIG_BUILD_FOR_HOST_UNIT_TEST void RunNodeCallbackForHandler(const ReadHandler * aReadHandler) From 270705f43477b6e1ffb0757f43b7769466bba5bf Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Tue, 25 Jul 2023 13:53:25 +0000 Subject: [PATCH 02/10] Restyled by clang-format --- src/app/reporting/ReportScheduler.h | 50 ++++++----------------------- 1 file changed, 10 insertions(+), 40 deletions(-) diff --git a/src/app/reporting/ReportScheduler.h b/src/app/reporting/ReportScheduler.h index 971cf86a11a4a8..87a9ef545b4c71 100644 --- a/src/app/reporting/ReportScheduler.h +++ b/src/app/reporting/ReportScheduler.h @@ -69,14 +69,8 @@ class ReportScheduler : public ReadHandler::Observer MinIntervalElapsed = (1 << 0), MaxIntervalElapsed = (1 << 1), }; - void SetTestFlags(TestFlags aFlag, bool aValue) - { - mFlags.Set(aFlag, aValue); - } - bool GetTestFlags(TestFlags aFlag) const - { - return mFlags.Has(aFlag); - } + void SetTestFlags(TestFlags aFlag, bool aValue) { mFlags.Set(aFlag, aValue); } + bool GetTestFlags(TestFlags aFlag) const { return mFlags.Has(aFlag); } #endif // CONFIG_BUILD_FOR_HOST_UNIT_TEST ReadHandlerNode(ReadHandler * aReadHandler, TimerDelegate * aTimerDelegate, ReportScheduler * aScheduler) : @@ -89,10 +83,7 @@ class ReportScheduler : public ReadHandler::Observer mReadHandler = aReadHandler; SetIntervalTimeStamps(aReadHandler); } - ReadHandler * GetReadHandler() const - { - return mReadHandler; - } + ReadHandler * GetReadHandler() const { return mReadHandler; } /// @brief Check if the Node is reportable now, meaning its readhandler was made reportable by attribute dirtying and /// handler state, and minimal time interval since last report has elapsed, or the maximal time interval since last @@ -111,10 +102,7 @@ class ReportScheduler : public ReadHandler::Observer #endif // CONFIG_BUILD_FOR_HOST_UNIT_TEST } - bool IsEngineRunScheduled() const - { - return mEngineRunScheduled; - } + bool IsEngineRunScheduled() const { return mEngineRunScheduled; } void SetEngineRunScheduled(bool aEngineRunScheduled) { mEngineRunScheduled = aEngineRunScheduled; @@ -152,18 +140,9 @@ class ReportScheduler : public ReadHandler::Observer mSyncTimestamp = aSyncTimestamp; } - System::Clock::Timestamp GetMinTimestamp() const - { - return mMinTimestamp; - } - System::Clock::Timestamp GetMaxTimestamp() const - { - return mMaxTimestamp; - } - System::Clock::Timestamp GetSyncTimestamp() const - { - return mSyncTimestamp; - } + System::Clock::Timestamp GetMinTimestamp() const { return mMinTimestamp; } + System::Clock::Timestamp GetMaxTimestamp() const { return mMaxTimestamp; } + System::Clock::Timestamp GetSyncTimestamp() const { return mSyncTimestamp; } private: #ifdef CONFIG_BUILD_FOR_HOST_UNIT_TEST @@ -202,21 +181,12 @@ class ReportScheduler : public ReadHandler::Observer /// @brief Check whether a ReadHandler is reportable right now, taking into account its minimum and maximum intervals. /// @param aReadHandler read handler to check - bool IsReportableNow(ReadHandler * aReadHandler) - { - return FindReadHandlerNode(aReadHandler)->IsReportableNow(); - } + bool IsReportableNow(ReadHandler * aReadHandler) { return FindReadHandlerNode(aReadHandler)->IsReportableNow(); } /// @brief Check if a ReadHandler is reportable without considering the timing - bool IsReadHandlerReportable(ReadHandler * aReadHandler) const - { - return aReadHandler->IsReportable(); - } + bool IsReadHandlerReportable(ReadHandler * aReadHandler) const { return aReadHandler->IsReportable(); } /// @brief Get the number of ReadHandlers registered in the scheduler's node pool - size_t GetNumReadHandlers() const - { - return mNodesPool.Allocated(); - } + size_t GetNumReadHandlers() const { return mNodesPool.Allocated(); } #ifdef CONFIG_BUILD_FOR_HOST_UNIT_TEST void RunNodeCallbackForHandler(const ReadHandler * aReadHandler) From 6fdb8d56f48ce21aa6bef29c2bae75692c8135d2 Mon Sep 17 00:00:00 2001 From: lpbeliveau-silabs Date: Tue, 25 Jul 2023 12:17:47 -0400 Subject: [PATCH 03/10] Reworked the logic to force a report emission when min elapsed and inject the scheduler in the ICD manager from Server::Init() --- src/app/icd/BUILD.gn | 2 + src/app/icd/ICDManager.cpp | 13 ++++-- src/app/icd/ICDManager.h | 12 ++--- src/app/reporting/ReportScheduler.h | 68 +++++++++++++++++++++-------- src/app/server/Server.cpp | 2 +- 5 files changed, 70 insertions(+), 27 deletions(-) diff --git a/src/app/icd/BUILD.gn b/src/app/icd/BUILD.gn index f4d5b9a7375dac..fc8a2df96278ee 100644 --- a/src/app/icd/BUILD.gn +++ b/src/app/icd/BUILD.gn @@ -23,6 +23,7 @@ source_set("manager-srcs") { sources = [ "ICDManager.cpp", "ICDManager.h", + "${chip_root}/src/app/reporting/ReportScheduler.h", ] deps = [ ":cluster-srcs" ] @@ -54,6 +55,7 @@ source_set("server-srcs") { sources = [ "ICDEventManager.cpp", "ICDEventManager.h", + ] public_deps = [ ":manager-srcs" ] diff --git a/src/app/icd/ICDManager.cpp b/src/app/icd/ICDManager.cpp index 183a95ba498301..936f612d21f6b0 100644 --- a/src/app/icd/ICDManager.cpp +++ b/src/app/icd/ICDManager.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -39,13 +40,17 @@ namespace app { using namespace chip::app; using namespace chip::app::Clusters; using namespace chip::app::Clusters::IcdManagement; +using ReportScheduler = reporting::ReportScheduler; -void ICDManager::Init(PersistentStorageDelegate * storage, FabricTable * fabricTable) +void ICDManager::Init(PersistentStorageDelegate * storage, FabricTable * fabricTable, ReportScheduler * reportScheduler) { VerifyOrDie(storage != nullptr); VerifyOrDie(fabricTable != nullptr); - mStorage = storage; - mFabricTable = fabricTable; + VerifyOrDie(reportScheduler != nullptr); + + mStorage = storage; + mFabricTable = fabricTable; + mReportScheduler = reportScheduler; uint32_t activeModeInterval = IcdManagementServer::GetInstance().GetActiveModeInterval(); VerifyOrDie(kFastPollingInterval.count() < activeModeInterval); @@ -153,7 +158,7 @@ void ICDManager::UpdateOperationState(OperationalState state) ChipLogError(AppServer, "Failed to set Polling Interval: err %" CHIP_ERROR_FORMAT, err.Format()); } - InteractionModelEngine::GetInstance()->GetReportScheduler()->OnActiveModeEntered(); + mReportScheduler->TriggerReportEmission(); } else { diff --git a/src/app/icd/ICDManager.h b/src/app/icd/ICDManager.h index 94127d645e9c18..9bb0eb95b29c77 100644 --- a/src/app/icd/ICDManager.h +++ b/src/app/icd/ICDManager.h @@ -16,6 +16,7 @@ */ #pragma once +#include #include #include #include @@ -51,7 +52,7 @@ class ICDManager }; ICDManager() {} - void Init(PersistentStorageDelegate * storage, FabricTable * fabricTable); + void Init(PersistentStorageDelegate * storage, FabricTable * fabricTable, reporting::ReportScheduler * reportScheduler); void Shutdown(); void UpdateIcdMode(); void UpdateOperationState(OperationalState state); @@ -82,10 +83,11 @@ class ICDManager bool SupportsCheckInProtocol(); BitFlags mKeepActiveFlags{ 0 }; - OperationalState mOperationalState = OperationalState::IdleMode; - ICDMode mICDMode = ICDMode::SIT; - PersistentStorageDelegate * mStorage = nullptr; - FabricTable * mFabricTable = nullptr; + OperationalState mOperationalState = OperationalState::IdleMode; + ICDMode mICDMode = ICDMode::SIT; + PersistentStorageDelegate * mStorage = nullptr; + FabricTable * mFabricTable = nullptr; + reporting::ReportScheduler * mReportScheduler = nullptr; }; } // namespace app diff --git a/src/app/reporting/ReportScheduler.h b/src/app/reporting/ReportScheduler.h index 87a9ef545b4c71..e42e0ac2830082 100644 --- a/src/app/reporting/ReportScheduler.h +++ b/src/app/reporting/ReportScheduler.h @@ -69,8 +69,14 @@ class ReportScheduler : public ReadHandler::Observer MinIntervalElapsed = (1 << 0), MaxIntervalElapsed = (1 << 1), }; - void SetTestFlags(TestFlags aFlag, bool aValue) { mFlags.Set(aFlag, aValue); } - bool GetTestFlags(TestFlags aFlag) const { return mFlags.Has(aFlag); } + void SetTestFlags(TestFlags aFlag, bool aValue) + { + mFlags.Set(aFlag, aValue); + } + bool GetTestFlags(TestFlags aFlag) const + { + return mFlags.Has(aFlag); + } #endif // CONFIG_BUILD_FOR_HOST_UNIT_TEST ReadHandlerNode(ReadHandler * aReadHandler, TimerDelegate * aTimerDelegate, ReportScheduler * aScheduler) : @@ -83,7 +89,10 @@ class ReportScheduler : public ReadHandler::Observer mReadHandler = aReadHandler; SetIntervalTimeStamps(aReadHandler); } - ReadHandler * GetReadHandler() const { return mReadHandler; } + ReadHandler * GetReadHandler() const + { + return mReadHandler; + } /// @brief Check if the Node is reportable now, meaning its readhandler was made reportable by attribute dirtying and /// handler state, and minimal time interval since last report has elapsed, or the maximal time interval since last @@ -102,7 +111,10 @@ class ReportScheduler : public ReadHandler::Observer #endif // CONFIG_BUILD_FOR_HOST_UNIT_TEST } - bool IsEngineRunScheduled() const { return mEngineRunScheduled; } + bool IsEngineRunScheduled() const + { + return mEngineRunScheduled; + } void SetEngineRunScheduled(bool aEngineRunScheduled) { mEngineRunScheduled = aEngineRunScheduled; @@ -140,9 +152,18 @@ class ReportScheduler : public ReadHandler::Observer mSyncTimestamp = aSyncTimestamp; } - System::Clock::Timestamp GetMinTimestamp() const { return mMinTimestamp; } - System::Clock::Timestamp GetMaxTimestamp() const { return mMaxTimestamp; } - System::Clock::Timestamp GetSyncTimestamp() const { return mSyncTimestamp; } + System::Clock::Timestamp GetMinTimestamp() const + { + return mMinTimestamp; + } + System::Clock::Timestamp GetMaxTimestamp() const + { + return mMaxTimestamp; + } + System::Clock::Timestamp GetSyncTimestamp() const + { + return mSyncTimestamp; + } private: #ifdef CONFIG_BUILD_FOR_HOST_UNIT_TEST @@ -167,26 +188,39 @@ class ReportScheduler : public ReadHandler::Observer virtual void ReportTimerCallback() = 0; - void OnActiveModeEntered() + /// @brief Method that triggers a report emission on each ReadHandler that are above their min interval + /// It checks if all read handlers are above their min interval and if so forces them in a dirty state to trigger a + /// report emission + void TriggerReportEmission() { - for (auto & iter : mReadHandlerList) - { - if (iter.IsReportableNow()) + Timestamp now = mTimerDelegate->GetCurrentMonotonicTimestamp(); + mNodesPool.ForEachActiveObject([now](ReadHandlerNode * node) { + if (now >= node->GetMinTimestamp()) { - OnBecameReportable(iter.GetReadHandler()); - break; + node->GetReadHandler()->ForceDirtyState(); } - } + + return Loop::Continue; + }); } /// @brief Check whether a ReadHandler is reportable right now, taking into account its minimum and maximum intervals. /// @param aReadHandler read handler to check - bool IsReportableNow(ReadHandler * aReadHandler) { return FindReadHandlerNode(aReadHandler)->IsReportableNow(); } + bool IsReportableNow(ReadHandler * aReadHandler) + { + return FindReadHandlerNode(aReadHandler)->IsReportableNow(); + } /// @brief Check if a ReadHandler is reportable without considering the timing - bool IsReadHandlerReportable(ReadHandler * aReadHandler) const { return aReadHandler->IsReportable(); } + bool IsReadHandlerReportable(ReadHandler * aReadHandler) const + { + return aReadHandler->IsReportable(); + } /// @brief Get the number of ReadHandlers registered in the scheduler's node pool - size_t GetNumReadHandlers() const { return mNodesPool.Allocated(); } + size_t GetNumReadHandlers() const + { + return mNodesPool.Allocated(); + } #ifdef CONFIG_BUILD_FOR_HOST_UNIT_TEST void RunNodeCallbackForHandler(const ReadHandler * aReadHandler) diff --git a/src/app/server/Server.cpp b/src/app/server/Server.cpp index 96847ace574100..ce07c595d6db06 100644 --- a/src/app/server/Server.cpp +++ b/src/app/server/Server.cpp @@ -249,7 +249,7 @@ CHIP_ERROR Server::Init(const ServerInitParams & initParams) #endif // CHIP_CONFIG_ENABLE_SERVER_IM_EVENT #if CHIP_CONFIG_ENABLE_ICD_SERVER - mICDManager.Init(mDeviceStorage, &GetFabricTable()); + mICDManager.Init(mDeviceStorage, &GetFabricTable(), &mReportScheduler); mICDEventManager.Init(&mICDManager); #endif // CHIP_CONFIG_ENABLE_ICD_SERVER From d4b245d853d1482595c621207233e56b0935dc35 Mon Sep 17 00:00:00 2001 From: lpbeliveau-silabs <112982107+lpbeliveau-silabs@users.noreply.github.com> Date: Tue, 25 Jul 2023 16:29:34 -0400 Subject: [PATCH 04/10] Update src/app/reporting/ReportScheduler.h Co-authored-by: Boris Zbarsky --- src/app/reporting/ReportScheduler.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/app/reporting/ReportScheduler.h b/src/app/reporting/ReportScheduler.h index e42e0ac2830082..3eb74102c640cc 100644 --- a/src/app/reporting/ReportScheduler.h +++ b/src/app/reporting/ReportScheduler.h @@ -188,9 +188,8 @@ class ReportScheduler : public ReadHandler::Observer virtual void ReportTimerCallback() = 0; - /// @brief Method that triggers a report emission on each ReadHandler that are above their min interval - /// It checks if all read handlers are above their min interval and if so forces them in a dirty state to trigger a - /// report emission + /// @brief Method that triggers a report emission on each ReadHandler that is not blocked on its min interval. + /// Each read handler that is not blocked is immediately marked dirty so that it will report as soon as possible. void TriggerReportEmission() { Timestamp now = mTimerDelegate->GetCurrentMonotonicTimestamp(); From 36cf9162beffdf7816fcb3817c2fccb54db9228d Mon Sep 17 00:00:00 2001 From: lpbeliveau-silabs Date: Thu, 27 Jul 2023 14:59:41 -0400 Subject: [PATCH 05/10] Created StateObserver as an interface class to fix dependencies issues in app/BUILD.gn --- src/app/BUILD.gn | 2 +- src/app/ReadHandler.h | 4 +- src/app/icd/BUILD.gn | 11 +++- src/app/icd/ICDManager.cpp | 22 ++++--- src/app/icd/ICDManager.h | 14 ++--- src/app/icd/ICDStateObserver.h | 30 ++++++++++ src/app/reporting/ReportScheduler.h | 70 +++++------------------ src/app/reporting/ReportSchedulerImpl.cpp | 15 +++++ src/app/reporting/ReportSchedulerImpl.h | 3 + 9 files changed, 95 insertions(+), 76 deletions(-) create mode 100644 src/app/icd/ICDStateObserver.h diff --git a/src/app/BUILD.gn b/src/app/BUILD.gn index aade1882cb5f5a..9a697b6589a0ad 100644 --- a/src/app/BUILD.gn +++ b/src/app/BUILD.gn @@ -212,7 +212,7 @@ static_library("app") { public_deps = [ ":app_config", "${chip_root}/src/access", - "${chip_root}/src/app/icd:cluster-srcs", + "${chip_root}/src/app/icd:observer-srcs", "${chip_root}/src/lib/address_resolve", "${chip_root}/src/lib/support", "${chip_root}/src/messaging", diff --git a/src/app/ReadHandler.h b/src/app/ReadHandler.h index 5f1d3221886084..a87c121ffaf8b0 100644 --- a/src/app/ReadHandler.h +++ b/src/app/ReadHandler.h @@ -418,8 +418,8 @@ class ReadHandler : public Messaging::ExchangeDelegate friend class chip::app::reporting::Engine; friend class chip::app::InteractionModelEngine; - // The report scheduler needs to be able to access StateFlag private functions IsReportable(), IsGeneratingReports() and - // IsDirty() to know when to schedule a run so it is declared as a friend class. + // The report scheduler needs to be able to access StateFlag private functions IsReportable(), IsGeneratingReports(), + // ForceDirtyState() and IsDirty() to know when to schedule a run so it is declared as a friend class. friend class chip::app::reporting::ReportScheduler; enum class HandlerState : uint8_t diff --git a/src/app/icd/BUILD.gn b/src/app/icd/BUILD.gn index fc8a2df96278ee..18aea3f155d845 100644 --- a/src/app/icd/BUILD.gn +++ b/src/app/icd/BUILD.gn @@ -17,16 +17,22 @@ import("icd.gni") # ICD Server sources and configurations +source_set("observer-srcs") { + sources = [ "ICDStateObserver.h" ] +} + # ICD Manager source-set is broken out of the main source-set to enable unit tests # All sources and configurations used by the ICDManager need to go in this source-set source_set("manager-srcs") { sources = [ "ICDManager.cpp", "ICDManager.h", - "${chip_root}/src/app/reporting/ReportScheduler.h", ] - deps = [ ":cluster-srcs" ] + deps = [ + ":cluster-srcs", + ":observer-srcs", + ] public_deps = [ "${chip_root}/src/credentials:credentials" ] } @@ -55,7 +61,6 @@ source_set("server-srcs") { sources = [ "ICDEventManager.cpp", "ICDEventManager.h", - ] public_deps = [ ":manager-srcs" ] diff --git a/src/app/icd/ICDManager.cpp b/src/app/icd/ICDManager.cpp index 936f612d21f6b0..dae5fc0aa8a9fe 100644 --- a/src/app/icd/ICDManager.cpp +++ b/src/app/icd/ICDManager.cpp @@ -21,7 +21,6 @@ #include #include #include -#include #include #include #include @@ -34,23 +33,28 @@ #define ICD_ENFORCE_SIT_SLOW_POLL_LIMIT 0 #endif +#ifndef ICD_REPORT_ON_ENTER_ACTIVE_MODE +// Enabling this makes the devive emmit subscription reports when transitionning from idle to active mode. It gives the device a +// chance to sleep for the extent of its idle mode interval before getting awakened to emit reports again. +#define ICD_REPORT_ON_ENTER_ACTIVE_MODE 0 +#endif + namespace chip { namespace app { using namespace chip::app; using namespace chip::app::Clusters; using namespace chip::app::Clusters::IcdManagement; -using ReportScheduler = reporting::ReportScheduler; -void ICDManager::Init(PersistentStorageDelegate * storage, FabricTable * fabricTable, ReportScheduler * reportScheduler) +void ICDManager::Init(PersistentStorageDelegate * storage, FabricTable * fabricTable, ICDStateObserver * stateObserver) { VerifyOrDie(storage != nullptr); VerifyOrDie(fabricTable != nullptr); - VerifyOrDie(reportScheduler != nullptr); + VerifyOrDie(stateObserver != nullptr); - mStorage = storage; - mFabricTable = fabricTable; - mReportScheduler = reportScheduler; + mStorage = storage; + mFabricTable = fabricTable; + mStateObserver = stateObserver; uint32_t activeModeInterval = IcdManagementServer::GetInstance().GetActiveModeInterval(); VerifyOrDie(kFastPollingInterval.count() < activeModeInterval); @@ -158,7 +162,9 @@ void ICDManager::UpdateOperationState(OperationalState state) ChipLogError(AppServer, "Failed to set Polling Interval: err %" CHIP_ERROR_FORMAT, err.Format()); } - mReportScheduler->TriggerReportEmission(); +#if ICD_REPORT_ON_ENTER_ACTIVE_MODE + mStateObserver->OnEnterActiveMode(); +#endif } else { diff --git a/src/app/icd/ICDManager.h b/src/app/icd/ICDManager.h index 9bb0eb95b29c77..10a1704a670cfa 100644 --- a/src/app/icd/ICDManager.h +++ b/src/app/icd/ICDManager.h @@ -16,7 +16,7 @@ */ #pragma once -#include +#include #include #include #include @@ -52,7 +52,7 @@ class ICDManager }; ICDManager() {} - void Init(PersistentStorageDelegate * storage, FabricTable * fabricTable, reporting::ReportScheduler * reportScheduler); + void Init(PersistentStorageDelegate * storage, FabricTable * fabricTable, ICDStateObserver * stateObserver); void Shutdown(); void UpdateIcdMode(); void UpdateOperationState(OperationalState state); @@ -83,11 +83,11 @@ class ICDManager bool SupportsCheckInProtocol(); BitFlags mKeepActiveFlags{ 0 }; - OperationalState mOperationalState = OperationalState::IdleMode; - ICDMode mICDMode = ICDMode::SIT; - PersistentStorageDelegate * mStorage = nullptr; - FabricTable * mFabricTable = nullptr; - reporting::ReportScheduler * mReportScheduler = nullptr; + OperationalState mOperationalState = OperationalState::IdleMode; + ICDMode mICDMode = ICDMode::SIT; + PersistentStorageDelegate * mStorage = nullptr; + FabricTable * mFabricTable = nullptr; + ICDStateObserver * mStateObserver = nullptr; }; } // namespace app diff --git a/src/app/icd/ICDStateObserver.h b/src/app/icd/ICDStateObserver.h new file mode 100644 index 00000000000000..55f37c11088702 --- /dev/null +++ b/src/app/icd/ICDStateObserver.h @@ -0,0 +1,30 @@ +/* + * + * Copyright (c) 2023 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#pragma once + +namespace chip { +namespace app { + +class ICDStateObserver +{ +public: + virtual ~ICDStateObserver() {} + virtual void OnEnterActiveMode() = 0; +}; + +} // namespace app +} // namespace chip \ No newline at end of file diff --git a/src/app/reporting/ReportScheduler.h b/src/app/reporting/ReportScheduler.h index 3eb74102c640cc..adf75c300735b0 100644 --- a/src/app/reporting/ReportScheduler.h +++ b/src/app/reporting/ReportScheduler.h @@ -19,6 +19,7 @@ #pragma once #include +#include #include #include @@ -38,7 +39,7 @@ class TimerContext virtual void TimerFired() = 0; }; -class ReportScheduler : public ReadHandler::Observer +class ReportScheduler : public ReadHandler::Observer, public ICDStateObserver { public: /// @brief This class acts as an interface between the report scheduler and the system timer to reduce dependencies on the @@ -69,14 +70,8 @@ class ReportScheduler : public ReadHandler::Observer MinIntervalElapsed = (1 << 0), MaxIntervalElapsed = (1 << 1), }; - void SetTestFlags(TestFlags aFlag, bool aValue) - { - mFlags.Set(aFlag, aValue); - } - bool GetTestFlags(TestFlags aFlag) const - { - return mFlags.Has(aFlag); - } + void SetTestFlags(TestFlags aFlag, bool aValue) { mFlags.Set(aFlag, aValue); } + bool GetTestFlags(TestFlags aFlag) const { return mFlags.Has(aFlag); } #endif // CONFIG_BUILD_FOR_HOST_UNIT_TEST ReadHandlerNode(ReadHandler * aReadHandler, TimerDelegate * aTimerDelegate, ReportScheduler * aScheduler) : @@ -89,10 +84,7 @@ class ReportScheduler : public ReadHandler::Observer mReadHandler = aReadHandler; SetIntervalTimeStamps(aReadHandler); } - ReadHandler * GetReadHandler() const - { - return mReadHandler; - } + ReadHandler * GetReadHandler() const { return mReadHandler; } /// @brief Check if the Node is reportable now, meaning its readhandler was made reportable by attribute dirtying and /// handler state, and minimal time interval since last report has elapsed, or the maximal time interval since last @@ -111,10 +103,7 @@ class ReportScheduler : public ReadHandler::Observer #endif // CONFIG_BUILD_FOR_HOST_UNIT_TEST } - bool IsEngineRunScheduled() const - { - return mEngineRunScheduled; - } + bool IsEngineRunScheduled() const { return mEngineRunScheduled; } void SetEngineRunScheduled(bool aEngineRunScheduled) { mEngineRunScheduled = aEngineRunScheduled; @@ -152,18 +141,9 @@ class ReportScheduler : public ReadHandler::Observer mSyncTimestamp = aSyncTimestamp; } - System::Clock::Timestamp GetMinTimestamp() const - { - return mMinTimestamp; - } - System::Clock::Timestamp GetMaxTimestamp() const - { - return mMaxTimestamp; - } - System::Clock::Timestamp GetSyncTimestamp() const - { - return mSyncTimestamp; - } + System::Clock::Timestamp GetMinTimestamp() const { return mMinTimestamp; } + System::Clock::Timestamp GetMaxTimestamp() const { return mMaxTimestamp; } + System::Clock::Timestamp GetSyncTimestamp() const { return mSyncTimestamp; } private: #ifdef CONFIG_BUILD_FOR_HOST_UNIT_TEST @@ -188,38 +168,18 @@ class ReportScheduler : public ReadHandler::Observer virtual void ReportTimerCallback() = 0; - /// @brief Method that triggers a report emission on each ReadHandler that is not blocked on its min interval. - /// Each read handler that is not blocked is immediately marked dirty so that it will report as soon as possible. - void TriggerReportEmission() - { - Timestamp now = mTimerDelegate->GetCurrentMonotonicTimestamp(); - mNodesPool.ForEachActiveObject([now](ReadHandlerNode * node) { - if (now >= node->GetMinTimestamp()) - { - node->GetReadHandler()->ForceDirtyState(); - } - - return Loop::Continue; - }); - } + void TriggerReportEmission() {} /// @brief Check whether a ReadHandler is reportable right now, taking into account its minimum and maximum intervals. /// @param aReadHandler read handler to check - bool IsReportableNow(ReadHandler * aReadHandler) - { - return FindReadHandlerNode(aReadHandler)->IsReportableNow(); - } + bool IsReportableNow(ReadHandler * aReadHandler) { return FindReadHandlerNode(aReadHandler)->IsReportableNow(); } /// @brief Check if a ReadHandler is reportable without considering the timing - bool IsReadHandlerReportable(ReadHandler * aReadHandler) const - { - return aReadHandler->IsReportable(); - } + bool IsReadHandlerReportable(ReadHandler * aReadHandler) const { return aReadHandler->IsReportable(); } + /// @brief Sets the ForceDirty flag of a ReadHandler + void HandlerForceDirtyState(ReadHandler * aReadHandler) { aReadHandler->ForceDirtyState(); } /// @brief Get the number of ReadHandlers registered in the scheduler's node pool - size_t GetNumReadHandlers() const - { - return mNodesPool.Allocated(); - } + size_t GetNumReadHandlers() const { return mNodesPool.Allocated(); } #ifdef CONFIG_BUILD_FOR_HOST_UNIT_TEST void RunNodeCallbackForHandler(const ReadHandler * aReadHandler) diff --git a/src/app/reporting/ReportSchedulerImpl.cpp b/src/app/reporting/ReportSchedulerImpl.cpp index b6170fba9e0fdf..7ba909981a6bbb 100644 --- a/src/app/reporting/ReportSchedulerImpl.cpp +++ b/src/app/reporting/ReportSchedulerImpl.cpp @@ -37,6 +37,21 @@ ReportSchedulerImpl::ReportSchedulerImpl(TimerDelegate * aTimerDelegate) : Repor VerifyOrDie(nullptr != mTimerDelegate); } +/// @brief Method that triggers a report emission on each ReadHandler that is not blocked on its min interval. +/// Each read handler that is not blocked is immediately marked dirty so that it will report as soon as possible. +void ReportSchedulerImpl::OnEnterActiveMode() +{ + Timestamp now = mTimerDelegate->GetCurrentMonotonicTimestamp(); + mNodesPool.ForEachActiveObject([now, this](ReadHandlerNode * node) { + if (now >= node->GetMinTimestamp()) + { + this->HandlerForceDirtyState(node->GetReadHandler()); + } + + return Loop::Continue; + }); +} + /// @brief When a ReadHandler is added, register it, which will schedule an engine run void ReportSchedulerImpl::OnReadHandlerCreated(ReadHandler * aReadHandler) { diff --git a/src/app/reporting/ReportSchedulerImpl.h b/src/app/reporting/ReportSchedulerImpl.h index 3ac47449f834bc..573184ada02d5a 100644 --- a/src/app/reporting/ReportSchedulerImpl.h +++ b/src/app/reporting/ReportSchedulerImpl.h @@ -32,6 +32,9 @@ class ReportSchedulerImpl : public ReportScheduler ReportSchedulerImpl(TimerDelegate * aTimerDelegate); ~ReportSchedulerImpl() override { UnregisterAllHandlers(); } + // ICDStateObserver + void OnEnterActiveMode() override; + // ReadHandlerObserver void OnReadHandlerCreated(ReadHandler * aReadHandler) final; void OnBecameReportable(ReadHandler * aReadHandler) final; From d89eb8d859df9f8a4835e464c396c3650213b432 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Thu, 27 Jul 2023 19:20:14 +0000 Subject: [PATCH 06/10] Restyled by whitespace --- src/app/icd/ICDStateObserver.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/icd/ICDStateObserver.h b/src/app/icd/ICDStateObserver.h index 55f37c11088702..aa088a7b87f81a 100644 --- a/src/app/icd/ICDStateObserver.h +++ b/src/app/icd/ICDStateObserver.h @@ -27,4 +27,4 @@ class ICDStateObserver }; } // namespace app -} // namespace chip \ No newline at end of file +} // namespace chip From e89b21ad0b7b3902258900ee8f1a6b297fc85e5d Mon Sep 17 00:00:00 2001 From: lpbeliveau-silabs <112982107+lpbeliveau-silabs@users.noreply.github.com> Date: Mon, 31 Jul 2023 15:09:05 -0400 Subject: [PATCH 07/10] Update src/app/icd/ICDManager.cpp Co-authored-by: Boris Zbarsky --- src/app/icd/ICDManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/icd/ICDManager.cpp b/src/app/icd/ICDManager.cpp index dae5fc0aa8a9fe..4107f4f135259f 100644 --- a/src/app/icd/ICDManager.cpp +++ b/src/app/icd/ICDManager.cpp @@ -34,7 +34,7 @@ #endif #ifndef ICD_REPORT_ON_ENTER_ACTIVE_MODE -// Enabling this makes the devive emmit subscription reports when transitionning from idle to active mode. It gives the device a +// Enabling this makes the device emit subscription reports when transitioning from idle to active mode. It gives the device a // chance to sleep for the extent of its idle mode interval before getting awakened to emit reports again. #define ICD_REPORT_ON_ENTER_ACTIVE_MODE 0 #endif From c859ff6333a300e5fc7a5e6d7da97015e7688412 Mon Sep 17 00:00:00 2001 From: lpbeliveau-silabs Date: Mon, 31 Jul 2023 15:35:24 -0400 Subject: [PATCH 08/10] Moved the report on active mode ifdef to ReportSchedulerImpl and removed misleading comment --- src/app/icd/ICDManager.cpp | 5 +- src/app/reporting/ReportScheduler.h | 57 +++++++++++++++++------ src/app/reporting/ReportSchedulerImpl.cpp | 2 + 3 files changed, 47 insertions(+), 17 deletions(-) diff --git a/src/app/icd/ICDManager.cpp b/src/app/icd/ICDManager.cpp index 4107f4f135259f..e3787f2ddc747a 100644 --- a/src/app/icd/ICDManager.cpp +++ b/src/app/icd/ICDManager.cpp @@ -34,8 +34,7 @@ #endif #ifndef ICD_REPORT_ON_ENTER_ACTIVE_MODE -// Enabling this makes the device emit subscription reports when transitioning from idle to active mode. It gives the device a -// chance to sleep for the extent of its idle mode interval before getting awakened to emit reports again. +// Enabling this makes the device emit subscription reports when transitioning from idle to active mode. #define ICD_REPORT_ON_ENTER_ACTIVE_MODE 0 #endif @@ -162,9 +161,7 @@ void ICDManager::UpdateOperationState(OperationalState state) ChipLogError(AppServer, "Failed to set Polling Interval: err %" CHIP_ERROR_FORMAT, err.Format()); } -#if ICD_REPORT_ON_ENTER_ACTIVE_MODE mStateObserver->OnEnterActiveMode(); -#endif } else { diff --git a/src/app/reporting/ReportScheduler.h b/src/app/reporting/ReportScheduler.h index adf75c300735b0..40a596f5b9b628 100644 --- a/src/app/reporting/ReportScheduler.h +++ b/src/app/reporting/ReportScheduler.h @@ -70,8 +70,14 @@ class ReportScheduler : public ReadHandler::Observer, public ICDStateObserver MinIntervalElapsed = (1 << 0), MaxIntervalElapsed = (1 << 1), }; - void SetTestFlags(TestFlags aFlag, bool aValue) { mFlags.Set(aFlag, aValue); } - bool GetTestFlags(TestFlags aFlag) const { return mFlags.Has(aFlag); } + void SetTestFlags(TestFlags aFlag, bool aValue) + { + mFlags.Set(aFlag, aValue); + } + bool GetTestFlags(TestFlags aFlag) const + { + return mFlags.Has(aFlag); + } #endif // CONFIG_BUILD_FOR_HOST_UNIT_TEST ReadHandlerNode(ReadHandler * aReadHandler, TimerDelegate * aTimerDelegate, ReportScheduler * aScheduler) : @@ -84,7 +90,10 @@ class ReportScheduler : public ReadHandler::Observer, public ICDStateObserver mReadHandler = aReadHandler; SetIntervalTimeStamps(aReadHandler); } - ReadHandler * GetReadHandler() const { return mReadHandler; } + ReadHandler * GetReadHandler() const + { + return mReadHandler; + } /// @brief Check if the Node is reportable now, meaning its readhandler was made reportable by attribute dirtying and /// handler state, and minimal time interval since last report has elapsed, or the maximal time interval since last @@ -103,7 +112,10 @@ class ReportScheduler : public ReadHandler::Observer, public ICDStateObserver #endif // CONFIG_BUILD_FOR_HOST_UNIT_TEST } - bool IsEngineRunScheduled() const { return mEngineRunScheduled; } + bool IsEngineRunScheduled() const + { + return mEngineRunScheduled; + } void SetEngineRunScheduled(bool aEngineRunScheduled) { mEngineRunScheduled = aEngineRunScheduled; @@ -141,9 +153,18 @@ class ReportScheduler : public ReadHandler::Observer, public ICDStateObserver mSyncTimestamp = aSyncTimestamp; } - System::Clock::Timestamp GetMinTimestamp() const { return mMinTimestamp; } - System::Clock::Timestamp GetMaxTimestamp() const { return mMaxTimestamp; } - System::Clock::Timestamp GetSyncTimestamp() const { return mSyncTimestamp; } + System::Clock::Timestamp GetMinTimestamp() const + { + return mMinTimestamp; + } + System::Clock::Timestamp GetMaxTimestamp() const + { + return mMaxTimestamp; + } + System::Clock::Timestamp GetSyncTimestamp() const + { + return mSyncTimestamp; + } private: #ifdef CONFIG_BUILD_FOR_HOST_UNIT_TEST @@ -168,18 +189,28 @@ class ReportScheduler : public ReadHandler::Observer, public ICDStateObserver virtual void ReportTimerCallback() = 0; - void TriggerReportEmission() {} - /// @brief Check whether a ReadHandler is reportable right now, taking into account its minimum and maximum intervals. /// @param aReadHandler read handler to check - bool IsReportableNow(ReadHandler * aReadHandler) { return FindReadHandlerNode(aReadHandler)->IsReportableNow(); } + bool IsReportableNow(ReadHandler * aReadHandler) + { + return FindReadHandlerNode(aReadHandler)->IsReportableNow(); + } /// @brief Check if a ReadHandler is reportable without considering the timing - bool IsReadHandlerReportable(ReadHandler * aReadHandler) const { return aReadHandler->IsReportable(); } + bool IsReadHandlerReportable(ReadHandler * aReadHandler) const + { + return aReadHandler->IsReportable(); + } /// @brief Sets the ForceDirty flag of a ReadHandler - void HandlerForceDirtyState(ReadHandler * aReadHandler) { aReadHandler->ForceDirtyState(); } + void HandlerForceDirtyState(ReadHandler * aReadHandler) + { + aReadHandler->ForceDirtyState(); + } /// @brief Get the number of ReadHandlers registered in the scheduler's node pool - size_t GetNumReadHandlers() const { return mNodesPool.Allocated(); } + size_t GetNumReadHandlers() const + { + return mNodesPool.Allocated(); + } #ifdef CONFIG_BUILD_FOR_HOST_UNIT_TEST void RunNodeCallbackForHandler(const ReadHandler * aReadHandler) diff --git a/src/app/reporting/ReportSchedulerImpl.cpp b/src/app/reporting/ReportSchedulerImpl.cpp index 7ba909981a6bbb..8ce25dd581e28f 100644 --- a/src/app/reporting/ReportSchedulerImpl.cpp +++ b/src/app/reporting/ReportSchedulerImpl.cpp @@ -42,6 +42,7 @@ ReportSchedulerImpl::ReportSchedulerImpl(TimerDelegate * aTimerDelegate) : Repor void ReportSchedulerImpl::OnEnterActiveMode() { Timestamp now = mTimerDelegate->GetCurrentMonotonicTimestamp(); +#if ICD_REPORT_ON_ENTER_ACTIVE_MODE mNodesPool.ForEachActiveObject([now, this](ReadHandlerNode * node) { if (now >= node->GetMinTimestamp()) { @@ -50,6 +51,7 @@ void ReportSchedulerImpl::OnEnterActiveMode() return Loop::Continue; }); +#endif } /// @brief When a ReadHandler is added, register it, which will schedule an engine run From f7214bbb2b36149ca1ba57eca28aaa6cb850810d Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Mon, 31 Jul 2023 19:36:16 +0000 Subject: [PATCH 09/10] Restyled by clang-format --- src/app/reporting/ReportScheduler.h | 55 ++++++----------------------- 1 file changed, 11 insertions(+), 44 deletions(-) diff --git a/src/app/reporting/ReportScheduler.h b/src/app/reporting/ReportScheduler.h index 40a596f5b9b628..fc1858862bc4bd 100644 --- a/src/app/reporting/ReportScheduler.h +++ b/src/app/reporting/ReportScheduler.h @@ -70,14 +70,8 @@ class ReportScheduler : public ReadHandler::Observer, public ICDStateObserver MinIntervalElapsed = (1 << 0), MaxIntervalElapsed = (1 << 1), }; - void SetTestFlags(TestFlags aFlag, bool aValue) - { - mFlags.Set(aFlag, aValue); - } - bool GetTestFlags(TestFlags aFlag) const - { - return mFlags.Has(aFlag); - } + void SetTestFlags(TestFlags aFlag, bool aValue) { mFlags.Set(aFlag, aValue); } + bool GetTestFlags(TestFlags aFlag) const { return mFlags.Has(aFlag); } #endif // CONFIG_BUILD_FOR_HOST_UNIT_TEST ReadHandlerNode(ReadHandler * aReadHandler, TimerDelegate * aTimerDelegate, ReportScheduler * aScheduler) : @@ -90,10 +84,7 @@ class ReportScheduler : public ReadHandler::Observer, public ICDStateObserver mReadHandler = aReadHandler; SetIntervalTimeStamps(aReadHandler); } - ReadHandler * GetReadHandler() const - { - return mReadHandler; - } + ReadHandler * GetReadHandler() const { return mReadHandler; } /// @brief Check if the Node is reportable now, meaning its readhandler was made reportable by attribute dirtying and /// handler state, and minimal time interval since last report has elapsed, or the maximal time interval since last @@ -112,10 +103,7 @@ class ReportScheduler : public ReadHandler::Observer, public ICDStateObserver #endif // CONFIG_BUILD_FOR_HOST_UNIT_TEST } - bool IsEngineRunScheduled() const - { - return mEngineRunScheduled; - } + bool IsEngineRunScheduled() const { return mEngineRunScheduled; } void SetEngineRunScheduled(bool aEngineRunScheduled) { mEngineRunScheduled = aEngineRunScheduled; @@ -153,18 +141,9 @@ class ReportScheduler : public ReadHandler::Observer, public ICDStateObserver mSyncTimestamp = aSyncTimestamp; } - System::Clock::Timestamp GetMinTimestamp() const - { - return mMinTimestamp; - } - System::Clock::Timestamp GetMaxTimestamp() const - { - return mMaxTimestamp; - } - System::Clock::Timestamp GetSyncTimestamp() const - { - return mSyncTimestamp; - } + System::Clock::Timestamp GetMinTimestamp() const { return mMinTimestamp; } + System::Clock::Timestamp GetMaxTimestamp() const { return mMaxTimestamp; } + System::Clock::Timestamp GetSyncTimestamp() const { return mSyncTimestamp; } private: #ifdef CONFIG_BUILD_FOR_HOST_UNIT_TEST @@ -191,26 +170,14 @@ class ReportScheduler : public ReadHandler::Observer, public ICDStateObserver /// @brief Check whether a ReadHandler is reportable right now, taking into account its minimum and maximum intervals. /// @param aReadHandler read handler to check - bool IsReportableNow(ReadHandler * aReadHandler) - { - return FindReadHandlerNode(aReadHandler)->IsReportableNow(); - } + bool IsReportableNow(ReadHandler * aReadHandler) { return FindReadHandlerNode(aReadHandler)->IsReportableNow(); } /// @brief Check if a ReadHandler is reportable without considering the timing - bool IsReadHandlerReportable(ReadHandler * aReadHandler) const - { - return aReadHandler->IsReportable(); - } + bool IsReadHandlerReportable(ReadHandler * aReadHandler) const { return aReadHandler->IsReportable(); } /// @brief Sets the ForceDirty flag of a ReadHandler - void HandlerForceDirtyState(ReadHandler * aReadHandler) - { - aReadHandler->ForceDirtyState(); - } + void HandlerForceDirtyState(ReadHandler * aReadHandler) { aReadHandler->ForceDirtyState(); } /// @brief Get the number of ReadHandlers registered in the scheduler's node pool - size_t GetNumReadHandlers() const - { - return mNodesPool.Allocated(); - } + size_t GetNumReadHandlers() const { return mNodesPool.Allocated(); } #ifdef CONFIG_BUILD_FOR_HOST_UNIT_TEST void RunNodeCallbackForHandler(const ReadHandler * aReadHandler) From a51f7394c8c1876c042d5b26a071e35d18f079a3 Mon Sep 17 00:00:00 2001 From: lpbeliveau-silabs Date: Mon, 31 Jul 2023 16:16:55 -0400 Subject: [PATCH 10/10] Put the now timestamp in the #if check to avoid unused variable error --- src/app/reporting/ReportSchedulerImpl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/reporting/ReportSchedulerImpl.cpp b/src/app/reporting/ReportSchedulerImpl.cpp index 8ce25dd581e28f..74f75a663277aa 100644 --- a/src/app/reporting/ReportSchedulerImpl.cpp +++ b/src/app/reporting/ReportSchedulerImpl.cpp @@ -41,8 +41,8 @@ ReportSchedulerImpl::ReportSchedulerImpl(TimerDelegate * aTimerDelegate) : Repor /// Each read handler that is not blocked is immediately marked dirty so that it will report as soon as possible. void ReportSchedulerImpl::OnEnterActiveMode() { - Timestamp now = mTimerDelegate->GetCurrentMonotonicTimestamp(); #if ICD_REPORT_ON_ENTER_ACTIVE_MODE + Timestamp now = mTimerDelegate->GetCurrentMonotonicTimestamp(); mNodesPool.ForEachActiveObject([now, this](ReadHandlerNode * node) { if (now >= node->GetMinTimestamp()) {