From 594ffe2bbe03e529f8bbfb18e3836525d23a94c1 Mon Sep 17 00:00:00 2001 From: Wang Qixiang <43193572+wqx6@users.noreply.github.com> Date: Fri, 17 Jan 2025 20:00:24 +0800 Subject: [PATCH] icd management: make the feature map and operating mode managed by AAI (#37062) * icd management: make the feature map and operating mode managed by AAI * Restyled by clang-format * review changes * Restyled by clang-format * change the macro for operating mode * review change * run zap regen * Update TestICDManager.cpp --------- Co-authored-by: Restyled.io --- .../data_model/contact-sensor-app.matter | 4 +- .../nxp/zap-lit/contact-sensor-app.matter | 4 +- .../nxp/zap-sit/contact-sensor-app.matter | 2 +- .../icd-lit-light-switch-app.matter | 4 +- .../light-switch-app.matter | 2 +- .../light-switch-app/qpg/zap/switch.matter | 4 +- .../lit-icd-common/lit-icd-server-app.matter | 4 +- examples/lock-app/lock-common/lock-app.matter | 2 +- examples/lock-app/nxp/zap/lock-app.matter | 2 +- examples/lock-app/qpg/zap/lock.matter | 2 +- .../silabs/data_model/lock-app.matter | 2 +- .../smoke-co-alarm-app.matter | 2 +- examples/window-app/common/window-app.matter | 2 +- .../icd-management-server.cpp | 20 ++++ src/app/icd/server/BUILD.gn | 4 + src/app/icd/server/ICDConfigurationData.h | 25 ++++- src/app/icd/server/ICDManager.cpp | 15 +-- src/app/icd/server/ICDManager.h | 6 -- .../tests/ICDConfigurationDataTestAccess.h | 4 + src/app/icd/server/tests/TestICDManager.cpp | 47 ++++++--- .../zcl/zcl-with-test-extensions.json | 4 +- src/app/zap-templates/zcl/zcl.json | 4 +- .../zap-generated/attributes/Accessors.cpp | 95 ------------------- .../zap-generated/attributes/Accessors.h | 14 --- 24 files changed, 110 insertions(+), 164 deletions(-) diff --git a/examples/contact-sensor-app/bouffalolab/data_model/contact-sensor-app.matter b/examples/contact-sensor-app/bouffalolab/data_model/contact-sensor-app.matter index f12c88c86598a1..26c05f5250e086 100644 --- a/examples/contact-sensor-app/bouffalolab/data_model/contact-sensor-app.matter +++ b/examples/contact-sensor-app/bouffalolab/data_model/contact-sensor-app.matter @@ -2235,12 +2235,12 @@ endpoint 0 { callback attribute clientsSupportedPerFabric; ram attribute userActiveModeTriggerHint default = 0x100; ram attribute userActiveModeTriggerInstruction default = "Push setup button for Active Mode"; - ram attribute operatingMode default = 0; + callback attribute operatingMode; callback attribute maximumCheckInBackOff; callback attribute generatedCommandList; callback attribute acceptedCommandList; callback attribute attributeList; - ram attribute featureMap default = 0x000f; + callback attribute featureMap; ram attribute clusterRevision default = 3; handle command RegisterClient; diff --git a/examples/contact-sensor-app/nxp/zap-lit/contact-sensor-app.matter b/examples/contact-sensor-app/nxp/zap-lit/contact-sensor-app.matter index dbd6e529a78be4..f82918c1d131a6 100644 --- a/examples/contact-sensor-app/nxp/zap-lit/contact-sensor-app.matter +++ b/examples/contact-sensor-app/nxp/zap-lit/contact-sensor-app.matter @@ -2023,12 +2023,12 @@ endpoint 0 { callback attribute clientsSupportedPerFabric; ram attribute userActiveModeTriggerHint default = 4096; ram attribute userActiveModeTriggerInstruction default = "Push setup button for Active Mode"; - ram attribute operatingMode default = 0; + callback attribute operatingMode; callback attribute maximumCheckInBackOff; callback attribute generatedCommandList; callback attribute acceptedCommandList; callback attribute attributeList; - ram attribute featureMap default = 0x000F; + callback attribute featureMap; ram attribute clusterRevision default = 3; handle command RegisterClient; diff --git a/examples/contact-sensor-app/nxp/zap-sit/contact-sensor-app.matter b/examples/contact-sensor-app/nxp/zap-sit/contact-sensor-app.matter index c4c44479c10823..1a9664ca9abe86 100644 --- a/examples/contact-sensor-app/nxp/zap-sit/contact-sensor-app.matter +++ b/examples/contact-sensor-app/nxp/zap-sit/contact-sensor-app.matter @@ -2021,7 +2021,7 @@ endpoint 0 { callback attribute generatedCommandList; callback attribute acceptedCommandList; callback attribute attributeList; - ram attribute featureMap default = 0x0000; + callback attribute featureMap; ram attribute clusterRevision default = 3; } } diff --git a/examples/light-switch-app/light-switch-common/icd-lit-light-switch-app.matter b/examples/light-switch-app/light-switch-common/icd-lit-light-switch-app.matter index 7ca5371335eb92..727775bfddc048 100644 --- a/examples/light-switch-app/light-switch-common/icd-lit-light-switch-app.matter +++ b/examples/light-switch-app/light-switch-common/icd-lit-light-switch-app.matter @@ -3136,9 +3136,9 @@ endpoint 0 { callback attribute clientsSupportedPerFabric; ram attribute userActiveModeTriggerHint default = 0x1115; ram attribute userActiveModeTriggerInstruction default = "Power Cycle"; - ram attribute operatingMode default = 0; + callback attribute operatingMode; callback attribute maximumCheckInBackOff; - ram attribute featureMap default = 15; + callback attribute featureMap; ram attribute clusterRevision default = 3; handle command RegisterClient; diff --git a/examples/light-switch-app/light-switch-common/light-switch-app.matter b/examples/light-switch-app/light-switch-common/light-switch-app.matter index 4e37b0e4a7a76e..1bed030b5cc4a8 100644 --- a/examples/light-switch-app/light-switch-common/light-switch-app.matter +++ b/examples/light-switch-app/light-switch-common/light-switch-app.matter @@ -3131,7 +3131,7 @@ endpoint 0 { callback attribute idleModeDuration; callback attribute activeModeDuration; callback attribute activeModeThreshold; - ram attribute featureMap default = 0x0000; + callback attribute featureMap; ram attribute clusterRevision default = 3; } } diff --git a/examples/light-switch-app/qpg/zap/switch.matter b/examples/light-switch-app/qpg/zap/switch.matter index 2a6b5fb17101d6..8cefeeb19bb5c2 100644 --- a/examples/light-switch-app/qpg/zap/switch.matter +++ b/examples/light-switch-app/qpg/zap/switch.matter @@ -3242,11 +3242,11 @@ endpoint 0 { callback attribute clientsSupportedPerFabric; ram attribute userActiveModeTriggerHint default = 0x100; ram attribute userActiveModeTriggerInstruction default = "Reset the application"; - ram attribute operatingMode default = 1; + callback attribute operatingMode; callback attribute generatedCommandList; callback attribute acceptedCommandList; callback attribute attributeList; - ram attribute featureMap default = 0x0007; + callback attribute featureMap; ram attribute clusterRevision default = 3; handle command RegisterClient; diff --git a/examples/lit-icd-app/lit-icd-common/lit-icd-server-app.matter b/examples/lit-icd-app/lit-icd-common/lit-icd-server-app.matter index 6967b910f43fb7..2fce74e7b337b2 100644 --- a/examples/lit-icd-app/lit-icd-common/lit-icd-server-app.matter +++ b/examples/lit-icd-app/lit-icd-common/lit-icd-server-app.matter @@ -2089,12 +2089,12 @@ endpoint 0 { callback attribute clientsSupportedPerFabric; ram attribute userActiveModeTriggerHint default = 0x111D; ram attribute userActiveModeTriggerInstruction default = "Restart the application"; - ram attribute operatingMode default = 0; + callback attribute operatingMode; callback attribute maximumCheckInBackOff; callback attribute generatedCommandList; callback attribute acceptedCommandList; callback attribute attributeList; - ram attribute featureMap default = 0x000F; + callback attribute featureMap; ram attribute clusterRevision default = 3; handle command RegisterClient; diff --git a/examples/lock-app/lock-common/lock-app.matter b/examples/lock-app/lock-common/lock-app.matter index 24ff7e9505b68f..7d26abef20e46f 100644 --- a/examples/lock-app/lock-common/lock-app.matter +++ b/examples/lock-app/lock-common/lock-app.matter @@ -3173,7 +3173,7 @@ endpoint 0 { callback attribute idleModeDuration; callback attribute activeModeDuration; callback attribute activeModeThreshold; - ram attribute featureMap default = 0x0000; + callback attribute featureMap; ram attribute clusterRevision default = 3; } } diff --git a/examples/lock-app/nxp/zap/lock-app.matter b/examples/lock-app/nxp/zap/lock-app.matter index 86254e2b05bd2b..7c58efd5cd5a52 100644 --- a/examples/lock-app/nxp/zap/lock-app.matter +++ b/examples/lock-app/nxp/zap/lock-app.matter @@ -2683,7 +2683,7 @@ endpoint 0 { callback attribute generatedCommandList; callback attribute acceptedCommandList; callback attribute attributeList; - ram attribute featureMap default = 0x0000; + callback attribute featureMap; ram attribute clusterRevision default = 1; } } diff --git a/examples/lock-app/qpg/zap/lock.matter b/examples/lock-app/qpg/zap/lock.matter index aab98397a40f55..b3f683515c3e8b 100644 --- a/examples/lock-app/qpg/zap/lock.matter +++ b/examples/lock-app/qpg/zap/lock.matter @@ -2805,7 +2805,7 @@ endpoint 0 { callback attribute generatedCommandList; callback attribute acceptedCommandList; callback attribute attributeList; - ram attribute featureMap default = 0x0000; + callback attribute featureMap; ram attribute clusterRevision default = 3; } } diff --git a/examples/lock-app/silabs/data_model/lock-app.matter b/examples/lock-app/silabs/data_model/lock-app.matter index 9a57b261e229d7..ea89439a23a745 100644 --- a/examples/lock-app/silabs/data_model/lock-app.matter +++ b/examples/lock-app/silabs/data_model/lock-app.matter @@ -3175,7 +3175,7 @@ endpoint 0 { callback attribute idleModeDuration; callback attribute activeModeDuration; callback attribute activeModeThreshold; - ram attribute featureMap default = 0x0000; + callback attribute featureMap; ram attribute clusterRevision default = 3; } } diff --git a/examples/smoke-co-alarm-app/smoke-co-alarm-common/smoke-co-alarm-app.matter b/examples/smoke-co-alarm-app/smoke-co-alarm-common/smoke-co-alarm-app.matter index 14ed47c8bf1f44..1399ecb7c184c9 100644 --- a/examples/smoke-co-alarm-app/smoke-co-alarm-common/smoke-co-alarm-app.matter +++ b/examples/smoke-co-alarm-app/smoke-co-alarm-common/smoke-co-alarm-app.matter @@ -2471,7 +2471,7 @@ endpoint 0 { callback attribute generatedCommandList; callback attribute acceptedCommandList; callback attribute attributeList; - ram attribute featureMap default = 1; + callback attribute featureMap; ram attribute clusterRevision default = 3; handle command RegisterClient; diff --git a/examples/window-app/common/window-app.matter b/examples/window-app/common/window-app.matter index cab4ff96cb9107..0cec2be0cf7582 100644 --- a/examples/window-app/common/window-app.matter +++ b/examples/window-app/common/window-app.matter @@ -2699,7 +2699,7 @@ endpoint 0 { callback attribute generatedCommandList; callback attribute acceptedCommandList; callback attribute attributeList; - ram attribute featureMap default = 0x0000; + callback attribute featureMap; ram attribute clusterRevision default = 3; } } diff --git a/src/app/clusters/icd-management-server/icd-management-server.cpp b/src/app/clusters/icd-management-server/icd-management-server.cpp index c2625b050d4661..288f7dcceabf40 100644 --- a/src/app/clusters/icd-management-server/icd-management-server.cpp +++ b/src/app/clusters/icd-management-server/icd-management-server.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -64,6 +65,19 @@ class IcdManagementAttributeAccess : public AttributeAccessInterface CHIP_ERROR ReadIdleModeDuration(EndpointId endpoint, AttributeValueEncoder & encoder); CHIP_ERROR ReadActiveModeDuration(EndpointId endpoint, AttributeValueEncoder & encoder); CHIP_ERROR ReadActiveModeThreshold(EndpointId endpoint, AttributeValueEncoder & encoder); + CHIP_ERROR ReadFeatureMap(EndpointId endpoint, AttributeValueEncoder & encoder) + { + return encoder.Encode(mICDConfigurationData->GetFeatureMap()); + } + +#if CHIP_CONFIG_ENABLE_ICD_LIT + CHIP_ERROR ReadOperatingMode(EndpointId endpoint, AttributeValueEncoder & encoder) + { + return mICDConfigurationData->GetICDMode() == ICDConfigurationData::ICDMode::SIT + ? encoder.Encode(IcdManagement::OperatingModeEnum::kSit) + : encoder.Encode(IcdManagement::OperatingModeEnum::kLit); + } +#endif // CHIP_CONFIG_ENABLE_ICD_LIT #if CHIP_CONFIG_ENABLE_ICD_CIP CHIP_ERROR ReadRegisteredClients(EndpointId endpoint, AttributeValueEncoder & encoder); @@ -94,6 +108,12 @@ CHIP_ERROR IcdManagementAttributeAccess::Read(const ConcreteReadAttributePath & case IcdManagement::Attributes::ActiveModeThreshold::Id: return ReadActiveModeThreshold(aPath.mEndpointId, aEncoder); + case IcdManagement::Attributes::FeatureMap::Id: + return ReadFeatureMap(aPath.mEndpointId, aEncoder); +#if CHIP_CONFIG_ENABLE_ICD_LIT + case IcdManagement::Attributes::OperatingMode::Id: + return ReadOperatingMode(aPath.mEndpointId, aEncoder); +#endif // CHIP_CONFIG_ENABLE_ICD_LIT #if CHIP_CONFIG_ENABLE_ICD_CIP case IcdManagement::Attributes::RegisteredClients::Id: return ReadRegisteredClients(aPath.mEndpointId, aEncoder); diff --git a/src/app/icd/server/BUILD.gn b/src/app/icd/server/BUILD.gn index bef9a0730abdc7..1d77158e473237 100644 --- a/src/app/icd/server/BUILD.gn +++ b/src/app/icd/server/BUILD.gn @@ -31,6 +31,10 @@ buildconfig_header("icd-server-buildconfig") { assert(chip_enable_icd_checkin && chip_enable_icd_user_active_mode_trigger) } + if (chip_enable_icd_dsls) { + assert(chip_enable_icd_lit) + } + defines = [ "CHIP_CONFIG_ENABLE_ICD_SERVER=${chip_enable_icd_server}", "CHIP_CONFIG_ENABLE_ICD_LIT=${chip_enable_icd_lit}", diff --git a/src/app/icd/server/ICDConfigurationData.h b/src/app/icd/server/ICDConfigurationData.h index 4d2597ef260355..42b32e453d8f8d 100644 --- a/src/app/icd/server/ICDConfigurationData.h +++ b/src/app/icd/server/ICDConfigurationData.h @@ -17,8 +17,10 @@ #pragma once +#include #include #include +#include #include #include #include @@ -77,6 +79,8 @@ class ICDConfigurationData System::Clock::Seconds32 GetMaximumCheckInBackoff() { return mMaximumCheckInBackOff; } + BitFlags GetFeatureMap() { return mFeatureMap; } + /** * The returned value will depend on the devices operating mode. * If ICDMode == SIT && the configured slow poll interval is superior to the maximum threshold (15s), the function will return @@ -92,7 +96,22 @@ class ICDConfigurationData private: // Singleton Object - ICDConfigurationData() = default; + ICDConfigurationData() + { + // Initialize feature map +#if CHIP_CONFIG_ENABLE_ICD_CIP + mFeatureMap.Set(app::Clusters::IcdManagement::Feature::kCheckInProtocolSupport); +#endif // CHIP_CONFIG_ENABLE_ICD_CIP +#if CHIP_CONFIG_ENABLE_ICD_UAT + mFeatureMap.Set(app::Clusters::IcdManagement::Feature::kUserActiveModeTrigger); +#endif // CHIP_CONFIG_ENABLE_ICD_UAT +#if CHIP_CONFIG_ENABLE_ICD_LIT + mFeatureMap.Set(app::Clusters::IcdManagement::Feature::kLongIdleTimeSupport); +#if CHIP_CONFIG_ENABLE_ICD_DSLS + mFeatureMap.Set(app::Clusters::IcdManagement::Feature::kDynamicSitLitSupport); +#endif // CHIP_CONFIG_ENABLE_ICD_DSLS +#endif // CHIP_CONFIG_ENABLE_ICD_LIT + } static ICDConfigurationData instance; // ICD related information is managed by the ICDManager but stored in the ICDConfigurationData to enable consummers to access it @@ -125,6 +144,8 @@ class ICDConfigurationData CHIP_ERROR SetModeDurations(Optional activeModeDuration, Optional idleModeDuration); + void SetFeatureMap(BitFlags featureMap) { mFeatureMap = featureMap; } + static constexpr System::Clock::Seconds32 kMaxIdleModeDuration = System::Clock::Seconds32(18 * kSecondsPerHour); static constexpr System::Clock::Seconds32 kMinIdleModeDuration = System::Clock::Seconds32(1); // As defined in the spec, the maximum guaranteed duration for the StayActiveDuration is 30s "Matter Application @@ -169,6 +190,8 @@ class ICDConfigurationData System::Clock::Milliseconds32 mSlowPollingInterval = CHIP_DEVICE_CONFIG_ICD_SLOW_POLL_INTERVAL; System::Clock::Milliseconds32 mFastPollingInterval = CHIP_DEVICE_CONFIG_ICD_FAST_POLL_INTERVAL; + BitFlags mFeatureMap; + ICDMode mICDMode = ICDMode::SIT; }; diff --git a/src/app/icd/server/ICDManager.cpp b/src/app/icd/server/ICDManager.cpp index 6efa43875fdf46..e23427dacb14da 100644 --- a/src/app/icd/server/ICDManager.cpp +++ b/src/app/icd/server/ICDManager.cpp @@ -116,14 +116,7 @@ void ICDManager::Shutdown() bool ICDManager::SupportsFeature(Feature feature) { - // Can't use attribute accessors/Attributes::FeatureMap::Get in unit tests -#if !(CONFIG_BUILD_FOR_HOST_UNIT_TEST) - uint32_t featureMap = 0; - bool success = (Attributes::FeatureMap::Get(kRootEndpointId, &featureMap) == Status::Success); - return success ? ((featureMap & to_underlying(feature)) != 0) : false; -#else - return ((mFeatureMap & to_underlying(feature)) != 0); -#endif // !(CONFIG_BUILD_FOR_HOST_UNIT_TEST) + return ICDConfigurationData::GetInstance().GetFeatureMap().Has(feature); } uint32_t ICDManager::StayActiveRequest(uint32_t stayActiveDuration) @@ -394,12 +387,6 @@ void ICDManager::UpdateICDMode() if (ICDConfigurationData::GetInstance().GetICDMode() != tempMode) { ICDConfigurationData::GetInstance().SetICDMode(tempMode); - - // Can't use attribute accessors/Attributes::OperatingMode::Set in unit tests -#if !(CONFIG_BUILD_FOR_HOST_UNIT_TEST) - Attributes::OperatingMode::Set(kRootEndpointId, static_cast(tempMode)); -#endif - postObserverEvent(ObserverEventType::ICDModeChange); } diff --git a/src/app/icd/server/ICDManager.h b/src/app/icd/server/ICDManager.h index eae0adbc1a28de..5e8288a655a5ac 100644 --- a/src/app/icd/server/ICDManager.h +++ b/src/app/icd/server/ICDManager.h @@ -229,7 +229,6 @@ class ICDManager : public ICDListener, public TestEventTriggerHandler #endif // CHIP_CONFIG_ENABLE_ICD_CIP #if CONFIG_BUILD_FOR_HOST_UNIT_TEST - void SetTestFeatureMapValue(uint32_t featureMap) { mFeatureMap = featureMap; }; #if CHIP_CONFIG_PERSIST_SUBSCRIPTIONS && !CHIP_CONFIG_SUBSCRIPTION_TIMEOUT_RESUMPTION bool GetIsBootUpResumeSubscriptionExecuted() { return mIsBootUpResumeSubscriptionExecuted; }; #endif // !CHIP_CONFIG_SUBSCRIPTION_TIMEOUT_RESUMPTION && CHIP_CONFIG_PERSIST_SUBSCRIPTIONS @@ -381,11 +380,6 @@ class ICDManager : public ICDListener, public TestEventTriggerHandler ICDCheckInBackOffStrategy * mICDCheckInBackOffStrategy = nullptr; ObjectPool mICDSenderPool; #endif // CHIP_CONFIG_ENABLE_ICD_CIP - -#if CONFIG_BUILD_FOR_HOST_UNIT_TEST - // feature map that can be changed at runtime for testing purposes - uint32_t mFeatureMap = 0; -#endif // CONFIG_BUILD_FOR_HOST_UNIT_TEST }; } // namespace app diff --git a/src/app/icd/server/tests/ICDConfigurationDataTestAccess.h b/src/app/icd/server/tests/ICDConfigurationDataTestAccess.h index 8771ce15b2c9a9..cfb4abca351b8e 100644 --- a/src/app/icd/server/tests/ICDConfigurationDataTestAccess.h +++ b/src/app/icd/server/tests/ICDConfigurationDataTestAccess.h @@ -17,7 +17,9 @@ #pragma once +#include #include +#include namespace chip { namespace Test { @@ -39,6 +41,8 @@ class ICDConfigurationDataTestAccess return mData->SetModeDurations(activeModeDuration, idleModeDuration); } + void SetFeatureMap(BitFlags featureMap) { mData->SetFeatureMap(featureMap); } + private: ICDConfigurationData * mData = nullptr; }; diff --git a/src/app/icd/server/tests/TestICDManager.cpp b/src/app/icd/server/tests/TestICDManager.cpp index 4d0791c7149c54..b05ba9b132e1e3 100644 --- a/src/app/icd/server/tests/TestICDManager.cpp +++ b/src/app/icd/server/tests/TestICDManager.cpp @@ -16,6 +16,7 @@ * limitations under the License. */ +#include #include #include @@ -261,8 +262,10 @@ TEST_F(TestICDManager, TestICDModeDurationsWith0ActiveModeDurationWithoutActiveS ICDConfigurationData & icdConfigData = ICDConfigurationData::GetInstance(); ICDConfigurationDataTestAccess privateIcdConfigData(&icdConfigData); - // Set FeatureMap - Configures CIP, UAT and LITS to 1 - mICDManager.SetTestFeatureMapValue(0x07); + using Feature = Clusters::IcdManagement::Feature; + BitFlags featureMap; + featureMap.Set(Feature::kLongIdleTimeSupport).Set(Feature::kUserActiveModeTrigger).Set(Feature::kCheckInProtocolSupport); + privateIcdConfigData.SetFeatureMap(featureMap); // Set that there are no matching subscriptions mSubInfoProvider.SetHasActiveSubscription(false); @@ -341,8 +344,10 @@ TEST_F(TestICDManager, TestICDModeDurationsWith0ActiveModeDurationWithActiveSub) ICDConfigurationData & icdConfigData = ICDConfigurationData::GetInstance(); ICDConfigurationDataTestAccess privateIcdConfigData(&icdConfigData); - // Set FeatureMap - Configures CIP, UAT and LITS to 1 - mICDManager.SetTestFeatureMapValue(0x07); + using Feature = Clusters::IcdManagement::Feature; + BitFlags featureMap; + featureMap.Set(Feature::kLongIdleTimeSupport).Set(Feature::kUserActiveModeTrigger).Set(Feature::kCheckInProtocolSupport); + privateIcdConfigData.SetFeatureMap(featureMap); // Set that there are not matching subscriptions mSubInfoProvider.SetHasActiveSubscription(true); @@ -480,10 +485,12 @@ TEST_F(TestICDManager, TestICDMRegisterUnregisterEvents) { typedef ICDListener::ICDManagementEvents ICDMEvent; ICDNotifier notifier = ICDNotifier::GetInstance(); + ICDConfigurationDataTestAccess privateIcdConfigData(&ICDConfigurationData::GetInstance()); - // Set FeatureMap - // Configures CIP, UAT and LITS to 1 - mICDManager.SetTestFeatureMapValue(0x07); + using Feature = Clusters::IcdManagement::Feature; + BitFlags featureMap; + featureMap.Set(Feature::kLongIdleTimeSupport).Set(Feature::kUserActiveModeTrigger).Set(Feature::kCheckInProtocolSupport); + privateIcdConfigData.SetFeatureMap(featureMap); // Check ICDManager starts in SIT mode if no entries are present EXPECT_EQ(ICDConfigurationData::GetInstance().GetICDMode(), ICDConfigurationData::ICDMode::SIT); @@ -704,10 +711,15 @@ TEST_F(TestICDManager, TestICDMDSLS) { typedef ICDListener::ICDManagementEvents ICDMEvent; ICDNotifier notifier = ICDNotifier::GetInstance(); + ICDConfigurationDataTestAccess privateIcdConfigData(&ICDConfigurationData::GetInstance()); - // Set FeatureMap - // Configures CIP, UAT, LITS and DSLS to 1 - mICDManager.SetTestFeatureMapValue(0x0F); + using Feature = Clusters::IcdManagement::Feature; + BitFlags featureMap; + featureMap.Set(Feature::kLongIdleTimeSupport) + .Set(Feature::kUserActiveModeTrigger) + .Set(Feature::kCheckInProtocolSupport) + .Set(Feature::kDynamicSitLitSupport); + privateIcdConfigData.SetFeatureMap(featureMap); // Check ICDManager starts in SIT mode if no entries are present EXPECT_EQ(ICDConfigurationData::GetInstance().GetICDMode(), ICDConfigurationData::ICDMode::SIT); @@ -988,9 +1000,12 @@ TEST_F(TestICDManager, TestICDStateObserverOnEnterActiveMode) TEST_F(TestICDManager, TestICDStateObserverOnICDModeChange) { typedef ICDListener::ICDManagementEvents ICDMEvent; + ICDConfigurationDataTestAccess privateIcdConfigData(&ICDConfigurationData::GetInstance()); - // Set FeatureMap - Configures CIP, UAT and LITS to 1 - mICDManager.SetTestFeatureMapValue(0x07); + using Feature = Clusters::IcdManagement::Feature; + BitFlags featureMap; + featureMap.Set(Feature::kLongIdleTimeSupport).Set(Feature::kUserActiveModeTrigger).Set(Feature::kCheckInProtocolSupport); + privateIcdConfigData.SetFeatureMap(featureMap); // Since we don't have a registration, we stay in SIT mode. No changes EXPECT_FALSE(mICDStateObserver.mOnICDModeChangeCalled); @@ -1034,8 +1049,12 @@ TEST_F(TestICDManager, TestICDStateObserverOnICDModeChange) TEST_F(TestICDManager, TestICDStateObserverOnICDModeChangeOnInit) { - // Set FeatureMap - Configures CIP, UAT and LITS to 1 - mICDManager.SetTestFeatureMapValue(0x07); + ICDConfigurationDataTestAccess privateIcdConfigData(&ICDConfigurationData::GetInstance()); + + using Feature = Clusters::IcdManagement::Feature; + BitFlags featureMap; + featureMap.Set(Feature::kLongIdleTimeSupport).Set(Feature::kUserActiveModeTrigger).Set(Feature::kCheckInProtocolSupport); + privateIcdConfigData.SetFeatureMap(featureMap); ICDMonitoringTable table(testStorage, kTestFabricIndex1, kMaxTestClients, &(mKeystore)); diff --git a/src/app/zap-templates/zcl/zcl-with-test-extensions.json b/src/app/zap-templates/zcl/zcl-with-test-extensions.json index 054ffc603420a3..5a9636d4b3ff1c 100644 --- a/src/app/zap-templates/zcl/zcl-with-test-extensions.json +++ b/src/app/zap-templates/zcl/zcl-with-test-extensions.json @@ -295,7 +295,9 @@ "RegisteredClients", "ICDCounter", "ClientsSupportedPerFabric", - "MaximumCheckInBackOff" + "MaximumCheckInBackOff", + "OperatingMode", + "FeatureMap" ], "Occupancy Sensing": [ "HoldTimeLimits", diff --git a/src/app/zap-templates/zcl/zcl.json b/src/app/zap-templates/zcl/zcl.json index 77239f9adb0296..64ec88e471fd21 100644 --- a/src/app/zap-templates/zcl/zcl.json +++ b/src/app/zap-templates/zcl/zcl.json @@ -289,7 +289,9 @@ "RegisteredClients", "ICDCounter", "ClientsSupportedPerFabric", - "MaximumCheckInBackOff" + "MaximumCheckInBackOff", + "OperatingMode", + "FeatureMap" ], "Occupancy Sensing": [ "HoldTimeLimits", diff --git a/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp b/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp index dcb96fdcb6346d..479c68f4eae256 100644 --- a/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp +++ b/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp @@ -9043,101 +9043,6 @@ Protocols::InteractionModel::Status Set(EndpointId endpoint, chip::CharSpan valu } // namespace UserActiveModeTriggerInstruction -namespace OperatingMode { - -Protocols::InteractionModel::Status Get(EndpointId endpoint, chip::app::Clusters::IcdManagement::OperatingModeEnum * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - Protocols::InteractionModel::Status status = - emberAfReadAttribute(endpoint, Clusters::IcdManagement::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(Protocols::InteractionModel::Status::Success == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return Protocols::InteractionModel::Status::ConstraintError; - } - *value = Traits::StorageToWorking(temp); - return status; -} - -Protocols::InteractionModel::Status Set(EndpointId endpoint, chip::app::Clusters::IcdManagement::OperatingModeEnum value, - MarkAttributeDirty markDirty) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return Protocols::InteractionModel::Status::ConstraintError; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(ConcreteAttributePath(endpoint, Clusters::IcdManagement::Id, Id), - EmberAfWriteDataInput(writable, ZCL_ENUM8_ATTRIBUTE_TYPE).SetMarkDirty(markDirty)); -} - -Protocols::InteractionModel::Status Set(EndpointId endpoint, chip::app::Clusters::IcdManagement::OperatingModeEnum value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return Protocols::InteractionModel::Status::ConstraintError; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::IcdManagement::Id, Id, writable, ZCL_ENUM8_ATTRIBUTE_TYPE); -} - -} // namespace OperatingMode - -namespace FeatureMap { - -Protocols::InteractionModel::Status Get(EndpointId endpoint, uint32_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - Protocols::InteractionModel::Status status = - emberAfReadAttribute(endpoint, Clusters::IcdManagement::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(Protocols::InteractionModel::Status::Success == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return Protocols::InteractionModel::Status::ConstraintError; - } - *value = Traits::StorageToWorking(temp); - return status; -} - -Protocols::InteractionModel::Status Set(EndpointId endpoint, uint32_t value, MarkAttributeDirty markDirty) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return Protocols::InteractionModel::Status::ConstraintError; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(ConcreteAttributePath(endpoint, Clusters::IcdManagement::Id, Id), - EmberAfWriteDataInput(writable, ZCL_BITMAP32_ATTRIBUTE_TYPE).SetMarkDirty(markDirty)); -} - -Protocols::InteractionModel::Status Set(EndpointId endpoint, uint32_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return Protocols::InteractionModel::Status::ConstraintError; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::IcdManagement::Id, Id, writable, ZCL_BITMAP32_ATTRIBUTE_TYPE); -} - -} // namespace FeatureMap - namespace ClusterRevision { Protocols::InteractionModel::Status Get(EndpointId endpoint, uint16_t * value) diff --git a/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.h b/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.h index 60e9c4512bc4d4..e213f56658af7e 100644 --- a/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.h +++ b/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.h @@ -1423,20 +1423,6 @@ Protocols::InteractionModel::Status Set(EndpointId endpoint, chip::CharSpan valu Protocols::InteractionModel::Status Set(EndpointId endpoint, chip::CharSpan value, MarkAttributeDirty markDirty); } // namespace UserActiveModeTriggerInstruction -namespace OperatingMode { -Protocols::InteractionModel::Status Get(EndpointId endpoint, - chip::app::Clusters::IcdManagement::OperatingModeEnum * value); // OperatingModeEnum -Protocols::InteractionModel::Status Set(EndpointId endpoint, chip::app::Clusters::IcdManagement::OperatingModeEnum value); -Protocols::InteractionModel::Status Set(EndpointId endpoint, chip::app::Clusters::IcdManagement::OperatingModeEnum value, - MarkAttributeDirty markDirty); -} // namespace OperatingMode - -namespace FeatureMap { -Protocols::InteractionModel::Status Get(EndpointId endpoint, uint32_t * value); // bitmap32 -Protocols::InteractionModel::Status Set(EndpointId endpoint, uint32_t value); -Protocols::InteractionModel::Status Set(EndpointId endpoint, uint32_t value, MarkAttributeDirty markDirty); -} // namespace FeatureMap - namespace ClusterRevision { Protocols::InteractionModel::Status Get(EndpointId endpoint, uint16_t * value); // int16u Protocols::InteractionModel::Status Set(EndpointId endpoint, uint16_t value);