diff --git a/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter b/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter index f4d14a49f75c8b..64d1544996c517 100644 --- a/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter +++ b/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter @@ -6717,7 +6717,7 @@ endpoint 1 { callback attribute acceptedCommandList; callback attribute eventList; callback attribute attributeList; - ram attribute featureMap default = 3; + ram attribute featureMap default = 7; ram attribute clusterRevision default = 5; handle command AddScene; @@ -7947,7 +7947,7 @@ endpoint 2 { callback attribute acceptedCommandList; callback attribute eventList; callback attribute attributeList; - ram attribute featureMap default = 3; + ram attribute featureMap default = 7; ram attribute clusterRevision default = 5; handle command AddScene; diff --git a/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap b/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap index 983304e753c7a7..ed9e065c1ae25e 100644 --- a/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap +++ b/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap @@ -1,6 +1,6 @@ { "fileFormat": 2, - "featureLevel": 98, + "featureLevel": 99, "creator": "zap", "keyValuePairs": [ { @@ -3059,7 +3059,7 @@ "side": "server", "type": "bitmap32", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "1", @@ -5676,7 +5676,7 @@ "side": "server", "type": "bitmap32", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "0", @@ -5692,7 +5692,7 @@ "side": "server", "type": "int16u", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "1", @@ -6998,7 +6998,7 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "3", + "defaultValue": "7", "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -9013,7 +9013,7 @@ "side": "server", "type": "bitmap32", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "0", @@ -9185,7 +9185,7 @@ "side": "server", "type": "bitmap32", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "0", @@ -9527,7 +9527,7 @@ "side": "server", "type": "bitmap32", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "0", @@ -9699,7 +9699,7 @@ "side": "server", "type": "bitmap32", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "0", @@ -10150,7 +10150,7 @@ "side": "server", "type": "bitmap32", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "0", @@ -10256,7 +10256,7 @@ "side": "server", "type": "bitmap32", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "0", @@ -11444,7 +11444,7 @@ "side": "server", "type": "bitmap32", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "7", @@ -11640,7 +11640,7 @@ "side": "server", "type": "bitmap32", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "7", @@ -12580,7 +12580,7 @@ "code": 8, "mfgCode": null, "side": "server", - "type": "Percent", + "type": "percent", "included": 1, "storageOption": "NVM", "singleton": 0, @@ -12596,7 +12596,7 @@ "code": 9, "mfgCode": null, "side": "server", - "type": "Percent", + "type": "percent", "included": 1, "storageOption": "NVM", "singleton": 0, @@ -12628,7 +12628,7 @@ "code": 11, "mfgCode": null, "side": "server", - "type": "Percent100ths", + "type": "percent100ths", "included": 1, "storageOption": "RAM", "singleton": 0, @@ -12644,7 +12644,7 @@ "code": 12, "mfgCode": null, "side": "server", - "type": "Percent100ths", + "type": "percent100ths", "included": 1, "storageOption": "RAM", "singleton": 0, @@ -12676,7 +12676,7 @@ "code": 14, "mfgCode": null, "side": "server", - "type": "Percent100ths", + "type": "percent100ths", "included": 1, "storageOption": "NVM", "singleton": 0, @@ -12692,7 +12692,7 @@ "code": 15, "mfgCode": null, "side": "server", - "type": "Percent100ths", + "type": "percent100ths", "included": 1, "storageOption": "NVM", "singleton": 0, @@ -13794,7 +13794,7 @@ "code": 2, "mfgCode": null, "side": "server", - "type": "Percent", + "type": "percent", "included": 1, "storageOption": "RAM", "singleton": 0, @@ -13810,7 +13810,7 @@ "code": 3, "mfgCode": null, "side": "server", - "type": "Percent", + "type": "percent", "included": 1, "storageOption": "RAM", "singleton": 0, @@ -16274,7 +16274,7 @@ "side": "server", "type": "bitmap32", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "0", @@ -16540,7 +16540,7 @@ "side": "server", "type": "bitmap32", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "0", @@ -16806,7 +16806,7 @@ "side": "server", "type": "bitmap32", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "0", @@ -17072,7 +17072,7 @@ "side": "server", "type": "bitmap32", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "0", @@ -17338,7 +17338,7 @@ "side": "server", "type": "bitmap32", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "0", @@ -17604,7 +17604,7 @@ "side": "server", "type": "bitmap32", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "0", @@ -17870,7 +17870,7 @@ "side": "server", "type": "bitmap32", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "0", @@ -18136,7 +18136,7 @@ "side": "server", "type": "bitmap32", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "0", @@ -18402,7 +18402,7 @@ "side": "server", "type": "bitmap32", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "0", @@ -18668,7 +18668,7 @@ "side": "server", "type": "bitmap32", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "0", @@ -22206,7 +22206,7 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "3", + "defaultValue": "7", "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -23371,5 +23371,6 @@ "endpointId": 65534, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter b/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter index 7a30362e47c08e..bd375fc8294d9f 100644 --- a/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter +++ b/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter @@ -4377,7 +4377,7 @@ endpoint 1 { callback attribute acceptedCommandList; callback attribute eventList; callback attribute attributeList; - ram attribute featureMap default = 3; + ram attribute featureMap default = 7; ram attribute clusterRevision default = 5; handle command AddScene; @@ -4940,7 +4940,7 @@ endpoint 2 { callback attribute acceptedCommandList; callback attribute eventList; callback attribute attributeList; - ram attribute featureMap default = 3; + ram attribute featureMap default = 7; ram attribute clusterRevision default = 5; handle command AddScene; diff --git a/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.zap b/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.zap index 2908aed7212954..003e42cd5e1dd2 100644 --- a/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.zap +++ b/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.zap @@ -1,6 +1,6 @@ { "fileFormat": 2, - "featureLevel": 98, + "featureLevel": 99, "creator": "zap", "keyValuePairs": [ { @@ -17,6 +17,12 @@ } ], "package": [ + { + "pathRelativity": "relativeToZap", + "path": "../../../src/app/zap-templates/app-templates.json", + "type": "gen-templates-json", + "version": "chip-v1" + }, { "pathRelativity": "relativeToZap", "path": "../../../src/app/zap-templates/zcl/zcl.json", @@ -24,12 +30,6 @@ "category": "matter", "version": 1, "description": "Matter SDK ZCL data" - }, - { - "pathRelativity": "relativeToZap", - "path": "../../../src/app/zap-templates/app-templates.json", - "type": "gen-templates-json", - "version": "chip-v1" } ], "endpointTypes": [ @@ -2532,7 +2532,7 @@ "side": "server", "type": "bitmap32", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "0", @@ -3856,7 +3856,7 @@ "side": "server", "type": "bitmap32", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "0", @@ -3872,7 +3872,7 @@ "side": "server", "type": "int16u", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "1", @@ -4802,7 +4802,7 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "3", + "defaultValue": "7", "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -6988,7 +6988,7 @@ "code": 2, "mfgCode": null, "side": "server", - "type": "Percent", + "type": "percent", "included": 1, "storageOption": "RAM", "singleton": 0, @@ -7004,7 +7004,7 @@ "code": 3, "mfgCode": null, "side": "server", - "type": "Percent", + "type": "percent", "included": 1, "storageOption": "RAM", "singleton": 0, @@ -11082,7 +11082,7 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "3", + "defaultValue": "7", "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -12183,5 +12183,6 @@ "endpointId": 65534, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/lighting-app/lighting-common/lighting-app.matter b/examples/lighting-app/lighting-common/lighting-app.matter index f1f35df97c2425..f8596085c263ac 100644 --- a/examples/lighting-app/lighting-common/lighting-app.matter +++ b/examples/lighting-app/lighting-common/lighting-app.matter @@ -2483,7 +2483,7 @@ endpoint 1 { callback attribute generatedCommandList; callback attribute acceptedCommandList; callback attribute attributeList; - ram attribute featureMap default = 3; + ram attribute featureMap default = 7; ram attribute clusterRevision default = 5; handle command AddScene; diff --git a/examples/lighting-app/lighting-common/lighting-app.zap b/examples/lighting-app/lighting-common/lighting-app.zap index 5704e26200591d..d63f7354fdf4f3 100644 --- a/examples/lighting-app/lighting-common/lighting-app.zap +++ b/examples/lighting-app/lighting-common/lighting-app.zap @@ -4701,7 +4701,7 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "3", + "defaultValue": "7", "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -5976,4 +5976,4 @@ "networkId": 0 } ] -} \ No newline at end of file +} diff --git a/examples/lighting-app/silabs/data_model/lighting-thread-app.matter b/examples/lighting-app/silabs/data_model/lighting-thread-app.matter index c4c00d6180f52e..5be36635652f69 100644 --- a/examples/lighting-app/silabs/data_model/lighting-thread-app.matter +++ b/examples/lighting-app/silabs/data_model/lighting-thread-app.matter @@ -2500,7 +2500,7 @@ endpoint 1 { callback attribute acceptedCommandList; callback attribute eventList; callback attribute attributeList; - ram attribute featureMap default = 3; + ram attribute featureMap default = 7; ram attribute clusterRevision default = 5; handle command AddScene; diff --git a/examples/lighting-app/silabs/data_model/lighting-thread-app.zap b/examples/lighting-app/silabs/data_model/lighting-thread-app.zap index 7b3e1af338bdec..f429557b9aca0d 100644 --- a/examples/lighting-app/silabs/data_model/lighting-thread-app.zap +++ b/examples/lighting-app/silabs/data_model/lighting-thread-app.zap @@ -4257,7 +4257,7 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "3", + "defaultValue": "7", "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -5916,4 +5916,4 @@ "networkId": 0 } ] -} \ No newline at end of file +} diff --git a/examples/lighting-app/silabs/data_model/lighting-wifi-app.matter b/examples/lighting-app/silabs/data_model/lighting-wifi-app.matter index 9b84a36da6d93b..b9e7973ce34420 100644 --- a/examples/lighting-app/silabs/data_model/lighting-wifi-app.matter +++ b/examples/lighting-app/silabs/data_model/lighting-wifi-app.matter @@ -2340,7 +2340,7 @@ endpoint 1 { callback attribute acceptedCommandList; callback attribute eventList; callback attribute attributeList; - ram attribute featureMap default = 3; + ram attribute featureMap default = 7; ram attribute clusterRevision default = 5; handle command AddScene; diff --git a/examples/lighting-app/silabs/data_model/lighting-wifi-app.zap b/examples/lighting-app/silabs/data_model/lighting-wifi-app.zap index 89a46128f2a4ae..3f13b8e89e6d13 100644 --- a/examples/lighting-app/silabs/data_model/lighting-wifi-app.zap +++ b/examples/lighting-app/silabs/data_model/lighting-wifi-app.zap @@ -3433,7 +3433,7 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "3", + "defaultValue": "7", "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -5092,4 +5092,4 @@ "networkId": 0 } ] -} \ No newline at end of file +} diff --git a/examples/placeholder/linux/apps/app1/config.zap b/examples/placeholder/linux/apps/app1/config.zap index fdac4afb9f5152..0280eba02537b7 100644 --- a/examples/placeholder/linux/apps/app1/config.zap +++ b/examples/placeholder/linux/apps/app1/config.zap @@ -15157,4 +15157,4 @@ "networkId": 0 } ] -} \ No newline at end of file +} diff --git a/examples/pump-app/silabs/src/AppTask.cpp b/examples/pump-app/silabs/src/AppTask.cpp index 2dab9268a9035c..f1608b40f3325c 100644 --- a/examples/pump-app/silabs/src/AppTask.cpp +++ b/examples/pump-app/silabs/src/AppTask.cpp @@ -26,7 +26,6 @@ #include "LEDWidget.h" #include -#include #include #include #include diff --git a/scripts/tools/zap/tests/outputs/all-clusters-app/app-templates/gen_config.h b/scripts/tools/zap/tests/outputs/all-clusters-app/app-templates/gen_config.h index bf4dbc94ede3f7..1a7ff62dabb169 100644 --- a/scripts/tools/zap/tests/outputs/all-clusters-app/app-templates/gen_config.h +++ b/scripts/tools/zap/tests/outputs/all-clusters-app/app-templates/gen_config.h @@ -102,17 +102,16 @@ #define EMBER_AF_PLUGIN_SCENES_SERVER #define EMBER_AF_PLUGIN_SCENES // User options for server plugin Scenes -// Cluster spec 1.4.8.2 -#ifdef CHIP_CONFIG_MAX_SCENES_PER_FABRIC -#define MATTER_SCENES_TABLE_SIZE CHIP_CONFIG_MAX_SCENES_PER_FABRIC -#else -#define MATTER_SCENES_TABLE_SIZE 16 -#endif - +// Cluster spec 1.4.8.7 +#define MATTER_SCENES_TABLE_SIZE // Scenes FeatureMap Attribute Toggle Scenes Name feature // App cluster specs 1.4.4 #define MATTER_CLUSTER_SCENE_NAME_SUPPORT_MASK 0x0001 #define MATTER_CLUSTER_SCENE_NAME_SUPPORT (0x0000 & MATTER_CLUSTER_SCENE_NAME_SUPPORT_MASK) +// Scenes FeatureMap Table Size feature used for the MATTER_SCENES_TABLE_SIZE define +// App cluster specs 1.4.4.2 +#define MATTER_CLUSTER_TABLE_SIZE_SUPPORT_MASK 0x0001 +#define MATTER_CLUSTER_TABLE_SIZE_SUPPORT (0x0000 & MATTER_CLUSTER_TABLE_SIZE_SUPPORT_MASK) // Use this macro to check if the server side of the On/Off cluster is included #define ZCL_USING_ON_OFF_CLUSTER_SERVER diff --git a/src/app/clusters/scenes-server/SceneTableImpl.cpp b/src/app/clusters/scenes-server/SceneTableImpl.cpp index ea894c9d1d108c..b37ab57b5005b8 100644 --- a/src/app/clusters/scenes-server/SceneTableImpl.cpp +++ b/src/app/clusters/scenes-server/SceneTableImpl.cpp @@ -929,7 +929,7 @@ void DefaultSceneTableImpl::SetTableSize(uint16_t endpointSceneTableSize) { // Verify the endpoint passed size respects the limits of the device configuration mMaxScenesPerEndpoint = (kMaxScenesPerEndpoint < endpointSceneTableSize) ? kMaxScenesPerEndpoint : endpointSceneTableSize; - mMaxScenesPerFabric = static_cast(endpointSceneTableSize / 2); + mMaxScenesPerFabric = static_cast(mMaxScenesPerEndpoint / 2); } DefaultSceneTableImpl::SceneEntryIterator * DefaultSceneTableImpl::IterateSceneEntries(FabricIndex fabric) diff --git a/src/app/clusters/scenes-server/SceneTableImpl.h b/src/app/clusters/scenes-server/SceneTableImpl.h index 3be1dc43e48c26..1d0432f3a0c2f3 100644 --- a/src/app/clusters/scenes-server/SceneTableImpl.h +++ b/src/app/clusters/scenes-server/SceneTableImpl.h @@ -23,12 +23,14 @@ #include #include #include +#include + namespace chip { namespace scenes { -static constexpr uint16_t kMaxScenesPerFabric = CHIP_CONFIG_SCENES_MAX_PER_FABRIC; -static constexpr uint16_t kMaxScenesPerEndpoint = CHIP_CONFIG_MAX_SCENES_PER_ENDPOINT; +static constexpr uint16_t kMaxScenesPerFabric = MATTER_SCENES_TABLE_SIZE / 2; +static constexpr uint16_t kMaxScenesPerEndpoint = MATTER_SCENES_TABLE_SIZE; using clusterId = chip::ClusterId; diff --git a/src/app/clusters/scenes-server/scenes-server.cpp b/src/app/clusters/scenes-server/scenes-server.cpp index 39bdba86bd90d3..2386e2155d6722 100644 --- a/src/app/clusters/scenes-server/scenes-server.cpp +++ b/src/app/clusters/scenes-server/scenes-server.cpp @@ -136,8 +136,8 @@ CHIP_ERROR ScenesServer::Init() ChipLogDetail(Zcl, "ERR: getting the scenes FeatureMap on Endpoint %hu Status: %x", endpoint, status); } - // Explicit AttributeValuePairs is mandatory for matter so we force it here - featureMap |= to_underlying(Feature::kExplicit); + // Explicit AttributeValuePairs and TableSize features are mandatory for matter so we force-set them here + featureMap |= (to_underlying(Feature::kExplicit) | to_underlying(Feature::kTableSize)); status = Attributes::FeatureMap::Set(endpoint, featureMap); if (EMBER_ZCL_STATUS_SUCCESS != status) { diff --git a/src/app/tests/TestSceneTable.cpp b/src/app/tests/TestSceneTable.cpp index cba0ebe4e8d5f5..b7b5e47a6761ce 100644 --- a/src/app/tests/TestSceneTable.cpp +++ b/src/app/tests/TestSceneTable.cpp @@ -37,6 +37,10 @@ using TransitionTimeMs = scenes::TransitionTimeMs; namespace TestScenes { +// TestTableSize +constexpr uint8_t defaultTestTableSize = 16; +constexpr uint8_t defaultTestFabricCapacity = 8; + // Test Cluster ID constexpr chip::ClusterId kOnOffClusterId = 0x0006; constexpr chip::ClusterId kLevelControlClusterId = 0x0008; @@ -91,6 +95,9 @@ static const SceneStorageId sceneId6(kScene6, kGroup2); static const SceneStorageId sceneId7(kScene7, kGroup3); static const SceneStorageId sceneId8(kScene8, kGroup4); static const SceneStorageId sceneId9(kScene1, kGroup4); +static const SceneStorageId sceneId10(kScene4, kGroup4); +static const SceneStorageId sceneId11(kScene5, kGroup4); +static const SceneStorageId sceneId12(kScene6, kGroup4); CharSpan empty; @@ -107,6 +114,9 @@ static const SceneData sceneData9(CharSpan("Scene #9"), 3000); static const SceneData sceneData10(CharSpan("Scene #10"), 1000); static const SceneData sceneData11(CharSpan("Scene #11"), 50); static const SceneData sceneData12(CharSpan("Scene #12"), 100); +static const SceneData sceneData13(CharSpan("Scene #13"), 100); +static const SceneData sceneData14(CharSpan("Scene #14"), 100); +static const SceneData sceneData15(CharSpan("Scene #15"), 100); // Scenes SceneTableEntry scene1(sceneId1, sceneData1); @@ -121,6 +131,9 @@ SceneTableEntry scene9(sceneId9, sceneData9); SceneTableEntry scene10(sceneId1, sceneData10); SceneTableEntry scene11(sceneId5, sceneData11); SceneTableEntry scene12(sceneId8, sceneData12); +SceneTableEntry scene13(sceneId10, sceneData13); +SceneTableEntry scene14(sceneId11, sceneData14); +SceneTableEntry scene15(sceneId12, sceneData15); // Clusters EFS data static app::Clusters::Scenes::Structs::ExtensionFieldSet::Type OOextensionFieldSet; @@ -390,8 +403,7 @@ class TestSceneHandler : public scenes::DefaultSceneHandlerImpl class TestSceneTableImpl : public SceneTableImpl { public: - TestSceneTableImpl(uint16_t maxScenesPerFabric = scenes::kMaxScenesPerFabric, - uint16_t maxScenesGlobal = scenes::kMaxScenesPerEndpoint) : + TestSceneTableImpl(uint16_t maxScenesPerFabric = defaultTestFabricCapacity, uint16_t maxScenesGlobal = defaultTestTableSize) : SceneTableImpl(maxScenesPerFabric, maxScenesGlobal) {} ~TestSceneTableImpl() override {} @@ -427,7 +439,7 @@ void ResetSceneTable(SceneTable * sceneTable) void TestHandlerRegistration(nlTestSuite * aSuite, void * aContext) { - SceneTable * sceneTable = scenes::GetSceneTableImpl(); + SceneTable * sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1, defaultTestTableSize); NL_TEST_ASSERT(aSuite, nullptr != sceneTable); VerifyOrReturn(nullptr != sceneTable); TestSceneHandler tmpHandler[scenes::kMaxClustersPerScene]; @@ -480,7 +492,7 @@ void TestHandlerRegistration(nlTestSuite * aSuite, void * aContext) void TestHandlerFunctions(nlTestSuite * aSuite, void * aContext) { - SceneTable * sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1, scenes::kMaxScenesPerEndpoint); + SceneTable * sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1, defaultTestTableSize); NL_TEST_ASSERT(aSuite, nullptr != sceneTable); VerifyOrReturn(nullptr != sceneTable); @@ -673,16 +685,13 @@ void TestHandlerFunctions(nlTestSuite * aSuite, void * aContext) void TestStoreScenes(nlTestSuite * aSuite, void * aContext) { - SceneTable * sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1); + SceneTable * sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1, defaultTestTableSize); NL_TEST_ASSERT(aSuite, nullptr != sceneTable); VerifyOrReturn(nullptr != sceneTable); - SceneId sceneList[scenes::kMaxScenesPerFabric]; + SceneId sceneList[defaultTestFabricCapacity]; // Reset test ResetSceneTable(sceneTable); - sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1); - NL_TEST_ASSERT(aSuite, nullptr != sceneTable); - VerifyOrReturn(nullptr != sceneTable); // Populate scene1's EFS (Endpoint1) NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SceneSaveEFS(scene1)); @@ -796,7 +805,7 @@ void TestStoreScenes(nlTestSuite * aSuite, void * aContext) void TestOverwriteScenes(nlTestSuite * aSuite, void * aContext) { - SceneTable * sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1, scenes::kMaxScenesPerEndpoint); + SceneTable * sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1, defaultTestTableSize); NL_TEST_ASSERT(aSuite, nullptr != sceneTable); VerifyOrReturn(nullptr != sceneTable); @@ -824,7 +833,7 @@ void TestOverwriteScenes(nlTestSuite * aSuite, void * aContext) void TestIterateScenes(nlTestSuite * aSuite, void * aContext) { - SceneTable * sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1, scenes::kMaxScenesPerEndpoint); + SceneTable * sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1, defaultTestTableSize); NL_TEST_ASSERT(aSuite, nullptr != sceneTable); VerifyOrReturn(nullptr != sceneTable); @@ -861,7 +870,7 @@ void TestIterateScenes(nlTestSuite * aSuite, void * aContext) void TestRemoveScenes(nlTestSuite * aSuite, void * aContext) { - SceneTable * sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1, scenes::kMaxScenesPerEndpoint); + SceneTableImpl * sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1, defaultTestTableSize); NL_TEST_ASSERT(aSuite, nullptr != sceneTable); VerifyOrReturn(nullptr != sceneTable); @@ -948,10 +957,9 @@ void TestRemoveScenes(nlTestSuite * aSuite, void * aContext) iterator->Release(); // Remove at empty position, shouldn't trigger error - NL_TEST_ASSERT( - aSuite, - CHIP_NO_ERROR == - sceneTable->RemoveSceneTableEntryAtPosition(kTestEndpoint1, kFabric1, chip::scenes::kMaxScenesPerFabric - 1)); + NL_TEST_ASSERT(aSuite, + CHIP_NO_ERROR == + sceneTable->RemoveSceneTableEntryAtPosition(kTestEndpoint1, kFabric1, defaultTestFabricCapacity - 1)); iterator = sceneTable->IterateSceneEntries(kFabric1); NL_TEST_ASSERT(aSuite, iterator->Count() == 0); @@ -985,26 +993,23 @@ void TestRemoveScenes(nlTestSuite * aSuite, void * aContext) void TestFabricScenes(nlTestSuite * aSuite, void * aContext) { - SceneTable * sceneTable = scenes::GetSceneTableImpl(); + SceneTable * sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1, defaultTestTableSize); NL_TEST_ASSERT(aSuite, nullptr != sceneTable); VerifyOrReturn(nullptr != sceneTable); // Reset test ResetSceneTable(sceneTable); - sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1); - NL_TEST_ASSERT(aSuite, nullptr != sceneTable); - VerifyOrReturn(nullptr != sceneTable); SceneTableEntry scene; uint8_t fabric_capacity = 0; // Verify capacities are at max NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity)); - NL_TEST_ASSERT(aSuite, scenes::kMaxScenesPerFabric == fabric_capacity); + NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity == fabric_capacity); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric2, fabric_capacity)); - NL_TEST_ASSERT(aSuite, scenes::kMaxScenesPerFabric == fabric_capacity); + NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity == fabric_capacity); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric3, fabric_capacity)); - NL_TEST_ASSERT(aSuite, scenes::kMaxScenesPerFabric == fabric_capacity); + NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity == fabric_capacity); // Fabric 1 inserts NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene1)); @@ -1020,25 +1025,25 @@ void TestFabricScenes(nlTestSuite * aSuite, void * aContext) uint8_t scene_count = 0; NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetFabricSceneCount(kFabric1, scene_count)); - NL_TEST_ASSERT(aSuite, scenes::kMaxScenesPerFabric == scene_count); + NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity == scene_count); // Fabric 2 inserts NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric2, fabric_capacity)); - NL_TEST_ASSERT(aSuite, scenes::kMaxScenesPerFabric == fabric_capacity); + NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity == fabric_capacity); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric2, scene1)); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric2, scene2)); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric2, scene3)); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric2, scene4)); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric2, fabric_capacity)); - NL_TEST_ASSERT(aSuite, (scenes::kMaxScenesPerFabric - 4) == fabric_capacity); + NL_TEST_ASSERT(aSuite, (defaultTestFabricCapacity - 4) == fabric_capacity); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetFabricSceneCount(kFabric2, scene_count)); NL_TEST_ASSERT(aSuite, 4 == scene_count); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetEndpointSceneCount(scene_count)); - NL_TEST_ASSERT(aSuite, scenes::kMaxScenesPerEndpoint - 4 == scene_count); + NL_TEST_ASSERT(aSuite, defaultTestTableSize - 4 == scene_count); // Fabric 3 inserts, should only be 4 spaces left at this point since 12 got taken NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric3, fabric_capacity)); - NL_TEST_ASSERT(aSuite, scenes::kMaxScenesPerFabric - 4 == fabric_capacity); + NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity - 4 == fabric_capacity); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric3, scene1)); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric3, scene2)); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric3, scene3)); @@ -1046,7 +1051,7 @@ void TestFabricScenes(nlTestSuite * aSuite, void * aContext) NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetFabricSceneCount(kFabric2, scene_count)); NL_TEST_ASSERT(aSuite, 4 == scene_count); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetEndpointSceneCount(scene_count)); - NL_TEST_ASSERT(aSuite, scenes::kMaxScenesPerEndpoint == scene_count); + NL_TEST_ASSERT(aSuite, defaultTestTableSize == scene_count); // Checks capacity is now 0 accross all fabrics NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity)); @@ -1126,11 +1131,11 @@ void TestFabricScenes(nlTestSuite * aSuite, void * aContext) // Verify capacity updated for all fabrics NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity)); - NL_TEST_ASSERT(aSuite, scenes::kMaxScenesPerFabric == fabric_capacity); + NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity == fabric_capacity); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric2, fabric_capacity)); - NL_TEST_ASSERT(aSuite, scenes::kMaxScenesPerFabric - 4 == fabric_capacity); + NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity - 4 == fabric_capacity); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric3, fabric_capacity)); - NL_TEST_ASSERT(aSuite, scenes::kMaxScenesPerFabric - 4 == fabric_capacity); + NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity - 4 == fabric_capacity); // Verify we can now write more scenes in scene fabric 2 NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric2, scene5)); @@ -1150,9 +1155,9 @@ void TestFabricScenes(nlTestSuite * aSuite, void * aContext) // Verify capacity updated properly NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity)); - NL_TEST_ASSERT(aSuite, scenes::kMaxScenesPerFabric - 4 == fabric_capacity); + NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity - 4 == fabric_capacity); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric3, fabric_capacity)); - NL_TEST_ASSERT(aSuite, scenes::kMaxScenesPerFabric - 4 == fabric_capacity); + NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity - 4 == fabric_capacity); // Verify Fabric 3 still there NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric3, sceneId1, scene)); @@ -1214,52 +1219,48 @@ void TestFabricScenes(nlTestSuite * aSuite, void * aContext) // Verify capacity updated for all fabrics NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity)); - NL_TEST_ASSERT(aSuite, scenes::kMaxScenesPerFabric == fabric_capacity); + NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity == fabric_capacity); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric2, fabric_capacity)); - NL_TEST_ASSERT(aSuite, scenes::kMaxScenesPerFabric == fabric_capacity); + NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity == fabric_capacity); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric3, fabric_capacity)); - NL_TEST_ASSERT(aSuite, scenes::kMaxScenesPerFabric == fabric_capacity); + NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity == fabric_capacity); } void TestEndpointScenes(nlTestSuite * aSuite, void * aContext) { // Get Count for Endpoint 1 - SceneTable * sceneTable = scenes::GetSceneTableImpl(); + SceneTable * sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1, defaultTestTableSize); NL_TEST_ASSERT(aSuite, nullptr != sceneTable); VerifyOrReturn(nullptr != sceneTable); // Reset test ResetSceneTable(sceneTable); - sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1); - NL_TEST_ASSERT(aSuite, nullptr != sceneTable); - VerifyOrReturn(nullptr != sceneTable); - SceneTableEntry scene; // Verify all endpoints are empty uint8_t endpoint_scene_count = 0; // Get Count for Endpoint 1 - sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1); + sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1, defaultTestTableSize); NL_TEST_ASSERT(aSuite, nullptr != sceneTable); VerifyOrReturn(nullptr != sceneTable); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetEndpointSceneCount(endpoint_scene_count)); NL_TEST_ASSERT(aSuite, 0 == endpoint_scene_count); // Get Count for Endpoint 2 - sceneTable = scenes::GetSceneTableImpl(kTestEndpoint2); + sceneTable = scenes::GetSceneTableImpl(kTestEndpoint2, defaultTestTableSize); NL_TEST_ASSERT(aSuite, nullptr != sceneTable); VerifyOrReturn(nullptr != sceneTable); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetEndpointSceneCount(endpoint_scene_count)); NL_TEST_ASSERT(aSuite, 0 == endpoint_scene_count); // Get Count for Endpoint 3 - sceneTable = scenes::GetSceneTableImpl(kTestEndpoint3); + sceneTable = scenes::GetSceneTableImpl(kTestEndpoint3, defaultTestTableSize); NL_TEST_ASSERT(aSuite, nullptr != sceneTable); VerifyOrReturn(nullptr != sceneTable); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetEndpointSceneCount(endpoint_scene_count)); NL_TEST_ASSERT(aSuite, 0 == endpoint_scene_count); // Test Scenes insertion not accessible accross all endpoints - sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1); + sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1, defaultTestTableSize); NL_TEST_ASSERT(aSuite, nullptr != sceneTable); VerifyOrReturn(nullptr != sceneTable); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene1)); @@ -1269,25 +1270,25 @@ void TestEndpointScenes(nlTestSuite * aSuite, void * aContext) uint8_t fabric_capacity = 0; NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity)); - NL_TEST_ASSERT(aSuite, scenes::kMaxScenesPerFabric - 1 == fabric_capacity); + NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity - 1 == fabric_capacity); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric2, fabric_capacity)); - NL_TEST_ASSERT(aSuite, scenes::kMaxScenesPerFabric - 1 == fabric_capacity); + NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity - 1 == fabric_capacity); // Endpoint2 - sceneTable = scenes::GetSceneTableImpl(kTestEndpoint2); + sceneTable = scenes::GetSceneTableImpl(kTestEndpoint2, defaultTestTableSize); NL_TEST_ASSERT(aSuite, nullptr != sceneTable); VerifyOrReturn(nullptr != sceneTable); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetEndpointSceneCount(endpoint_scene_count)); NL_TEST_ASSERT(aSuite, 0 == endpoint_scene_count); // Endpoint3 - sceneTable = scenes::GetSceneTableImpl(kTestEndpoint3); + sceneTable = scenes::GetSceneTableImpl(kTestEndpoint3, defaultTestTableSize); NL_TEST_ASSERT(aSuite, nullptr != sceneTable); VerifyOrReturn(nullptr != sceneTable); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetEndpointSceneCount(endpoint_scene_count)); NL_TEST_ASSERT(aSuite, 0 == endpoint_scene_count); // Check if scene present in Endpoint 1 - sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1); + sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1, defaultTestTableSize); NL_TEST_ASSERT(aSuite, nullptr != sceneTable); VerifyOrReturn(nullptr != sceneTable); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric1, sceneId1, scene)); @@ -1296,13 +1297,13 @@ void TestEndpointScenes(nlTestSuite * aSuite, void * aContext) NL_TEST_ASSERT(aSuite, scene == scene1); // Check if scene present in Endpoint 2 - sceneTable = scenes::GetSceneTableImpl(kTestEndpoint2); + sceneTable = scenes::GetSceneTableImpl(kTestEndpoint2, defaultTestTableSize); NL_TEST_ASSERT(aSuite, nullptr != sceneTable); VerifyOrReturn(nullptr != sceneTable); NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric1, sceneId1, scene)); NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric2, sceneId1, scene)); // Check if scene present in Endpoint 3 - sceneTable = scenes::GetSceneTableImpl(kTestEndpoint3); + sceneTable = scenes::GetSceneTableImpl(kTestEndpoint3, defaultTestTableSize); NL_TEST_ASSERT(aSuite, nullptr != sceneTable); VerifyOrReturn(nullptr != sceneTable); NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric1, sceneId1, scene)); @@ -1310,7 +1311,7 @@ void TestEndpointScenes(nlTestSuite * aSuite, void * aContext) // Test removal on different endpoints do not affect each endpoints // Insertion on Endpoint2 - sceneTable = scenes::GetSceneTableImpl(kTestEndpoint2); + sceneTable = scenes::GetSceneTableImpl(kTestEndpoint2, defaultTestTableSize); NL_TEST_ASSERT(aSuite, nullptr != sceneTable); VerifyOrReturn(nullptr != sceneTable); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene1)); @@ -1318,14 +1319,14 @@ void TestEndpointScenes(nlTestSuite * aSuite, void * aContext) NL_TEST_ASSERT(aSuite, scene == scene1); // Removal on Endpoint1 - sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1); + sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1, defaultTestTableSize); NL_TEST_ASSERT(aSuite, nullptr != sceneTable); VerifyOrReturn(nullptr != sceneTable); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->RemoveSceneTableEntry(kFabric1, sceneId1)); NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric1, sceneId1, scene)); // Scene present on Endpoint2 - sceneTable = scenes::GetSceneTableImpl(kTestEndpoint2); + sceneTable = scenes::GetSceneTableImpl(kTestEndpoint2, defaultTestTableSize); NL_TEST_ASSERT(aSuite, nullptr != sceneTable); VerifyOrReturn(nullptr != sceneTable); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric1, sceneId1, scene)); @@ -1335,7 +1336,7 @@ void TestEndpointScenes(nlTestSuite * aSuite, void * aContext) NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->RemoveSceneTableEntry(kFabric1, sceneId1)); // Removal on Endpoint 1 - sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1); + sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1, defaultTestTableSize); NL_TEST_ASSERT(aSuite, nullptr != sceneTable); VerifyOrReturn(nullptr != sceneTable); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->RemoveSceneTableEntry(kFabric2, sceneId1)); @@ -1343,13 +1344,13 @@ void TestEndpointScenes(nlTestSuite * aSuite, void * aContext) NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetEndpointSceneCount(endpoint_scene_count)); NL_TEST_ASSERT(aSuite, 0 == endpoint_scene_count); // Endpoint 2 - sceneTable = scenes::GetSceneTableImpl(kTestEndpoint2); + sceneTable = scenes::GetSceneTableImpl(kTestEndpoint2, defaultTestTableSize); NL_TEST_ASSERT(aSuite, nullptr != sceneTable); VerifyOrReturn(nullptr != sceneTable); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetEndpointSceneCount(endpoint_scene_count)); NL_TEST_ASSERT(aSuite, 0 == endpoint_scene_count); // Endpoint 3 - sceneTable = scenes::GetSceneTableImpl(kTestEndpoint3); + sceneTable = scenes::GetSceneTableImpl(kTestEndpoint3, defaultTestTableSize); NL_TEST_ASSERT(aSuite, nullptr != sceneTable); VerifyOrReturn(nullptr != sceneTable); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetEndpointSceneCount(endpoint_scene_count)); @@ -1357,7 +1358,7 @@ void TestEndpointScenes(nlTestSuite * aSuite, void * aContext) // Test the fabric capacity accross endpoint // Fill fabric 1 endpoint 1 - sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1); + sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1, defaultTestTableSize); NL_TEST_ASSERT(aSuite, nullptr != sceneTable); VerifyOrReturn(nullptr != sceneTable); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene1)); @@ -1385,26 +1386,26 @@ void TestEndpointScenes(nlTestSuite * aSuite, void * aContext) NL_TEST_ASSERT(aSuite, 0 == fabric_capacity); // Endpoints 2 and 3 should be unaffected - sceneTable = scenes::GetSceneTableImpl(kTestEndpoint2); + sceneTable = scenes::GetSceneTableImpl(kTestEndpoint2, defaultTestTableSize); NL_TEST_ASSERT(aSuite, nullptr != sceneTable); VerifyOrReturn(nullptr != sceneTable); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity)); - NL_TEST_ASSERT(aSuite, scenes::kMaxScenesPerFabric == fabric_capacity); + NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity == fabric_capacity); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric2, fabric_capacity)); - NL_TEST_ASSERT(aSuite, scenes::kMaxScenesPerFabric == fabric_capacity); + NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity == fabric_capacity); - sceneTable = scenes::GetSceneTableImpl(kTestEndpoint3); + sceneTable = scenes::GetSceneTableImpl(kTestEndpoint3, defaultTestTableSize); NL_TEST_ASSERT(aSuite, nullptr != sceneTable); VerifyOrReturn(nullptr != sceneTable); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity)); - NL_TEST_ASSERT(aSuite, scenes::kMaxScenesPerFabric == fabric_capacity); + NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity == fabric_capacity); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric2, fabric_capacity)); - NL_TEST_ASSERT(aSuite, scenes::kMaxScenesPerFabric == fabric_capacity); + NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity == fabric_capacity); // Verify filling Fabric on endpoint 2 does not affect on endpoint 3 despite Max per fabric being reached by adding Endpoint1 // and Endpoint2 // Fill fabric 1 endpoint 2 - sceneTable = scenes::GetSceneTableImpl(kTestEndpoint2); + sceneTable = scenes::GetSceneTableImpl(kTestEndpoint2, defaultTestTableSize); NL_TEST_ASSERT(aSuite, nullptr != sceneTable); VerifyOrReturn(nullptr != sceneTable); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene1)); @@ -1417,7 +1418,7 @@ void TestEndpointScenes(nlTestSuite * aSuite, void * aContext) NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene8)); // Fill fabric 2 endpoint 2 - sceneTable = scenes::GetSceneTableImpl(kTestEndpoint2); + sceneTable = scenes::GetSceneTableImpl(kTestEndpoint2, defaultTestTableSize); NL_TEST_ASSERT(aSuite, nullptr != sceneTable); VerifyOrReturn(nullptr != sceneTable); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric2, scene1)); @@ -1430,16 +1431,16 @@ void TestEndpointScenes(nlTestSuite * aSuite, void * aContext) NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric2, scene8)); // scene count to Endpoint - sceneTable = scenes::GetSceneTableImpl(kTestEndpoint3); + sceneTable = scenes::GetSceneTableImpl(kTestEndpoint3, defaultTestTableSize); NL_TEST_ASSERT(aSuite, nullptr != sceneTable); VerifyOrReturn(nullptr != sceneTable); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity)); - NL_TEST_ASSERT(aSuite, scenes::kMaxScenesPerFabric == fabric_capacity); + NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity == fabric_capacity); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric2, fabric_capacity)); - NL_TEST_ASSERT(aSuite, scenes::kMaxScenesPerFabric == fabric_capacity); + NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity == fabric_capacity); // Test removal of fabric clears scene fabric on all endpoints - sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1); + sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1, defaultTestTableSize); NL_TEST_ASSERT(aSuite, nullptr != sceneTable); VerifyOrReturn(nullptr != sceneTable); sceneTable->RemoveFabric(kFabric1); @@ -1452,7 +1453,7 @@ void TestEndpointScenes(nlTestSuite * aSuite, void * aContext) NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric1, sceneId7, scene)); NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric1, sceneId8, scene)); - sceneTable = scenes::GetSceneTableImpl(kTestEndpoint2); + sceneTable = scenes::GetSceneTableImpl(kTestEndpoint2, defaultTestTableSize); NL_TEST_ASSERT(aSuite, nullptr != sceneTable); VerifyOrReturn(nullptr != sceneTable); NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric1, sceneId1, scene)); @@ -1467,17 +1468,17 @@ void TestEndpointScenes(nlTestSuite * aSuite, void * aContext) sceneTable->RemoveFabric(kFabric2); // Validate endpoints are empty - sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1); + sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1, defaultTestTableSize); NL_TEST_ASSERT(aSuite, nullptr != sceneTable); VerifyOrReturn(nullptr != sceneTable); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetEndpointSceneCount(endpoint_scene_count)); NL_TEST_ASSERT(aSuite, 0 == endpoint_scene_count); - sceneTable = scenes::GetSceneTableImpl(kTestEndpoint2); + sceneTable = scenes::GetSceneTableImpl(kTestEndpoint2, defaultTestTableSize); NL_TEST_ASSERT(aSuite, nullptr != sceneTable); VerifyOrReturn(nullptr != sceneTable); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetEndpointSceneCount(endpoint_scene_count)); NL_TEST_ASSERT(aSuite, 0 == endpoint_scene_count); - sceneTable = scenes::GetSceneTableImpl(kTestEndpoint3); + sceneTable = scenes::GetSceneTableImpl(kTestEndpoint3, defaultTestTableSize); NL_TEST_ASSERT(aSuite, nullptr != sceneTable); VerifyOrReturn(nullptr != sceneTable); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetEndpointSceneCount(endpoint_scene_count)); @@ -1486,53 +1487,53 @@ void TestEndpointScenes(nlTestSuite * aSuite, void * aContext) // Validate Fabric capacities at maximum accross all endpoints // Endpoint 1 - sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1); + sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1, defaultTestTableSize); NL_TEST_ASSERT(aSuite, nullptr != sceneTable); VerifyOrReturn(nullptr != sceneTable); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity)); - NL_TEST_ASSERT(aSuite, scenes::kMaxScenesPerFabric == fabric_capacity); + NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity == fabric_capacity); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric2, fabric_capacity)); - NL_TEST_ASSERT(aSuite, scenes::kMaxScenesPerFabric == fabric_capacity); + NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity == fabric_capacity); // Endpoint 2 - sceneTable = scenes::GetSceneTableImpl(kTestEndpoint2); + sceneTable = scenes::GetSceneTableImpl(kTestEndpoint2, defaultTestTableSize); NL_TEST_ASSERT(aSuite, nullptr != sceneTable); VerifyOrReturn(nullptr != sceneTable); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity)); - NL_TEST_ASSERT(aSuite, scenes::kMaxScenesPerFabric == fabric_capacity); + NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity == fabric_capacity); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric2, fabric_capacity)); - NL_TEST_ASSERT(aSuite, scenes::kMaxScenesPerFabric == fabric_capacity); + NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity == fabric_capacity); // Endpoint 3 - sceneTable = scenes::GetSceneTableImpl(kTestEndpoint3); + sceneTable = scenes::GetSceneTableImpl(kTestEndpoint3, defaultTestTableSize); NL_TEST_ASSERT(aSuite, nullptr != sceneTable); VerifyOrReturn(nullptr != sceneTable); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity)); - NL_TEST_ASSERT(aSuite, scenes::kMaxScenesPerFabric == fabric_capacity); + NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity == fabric_capacity); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric2, fabric_capacity)); - NL_TEST_ASSERT(aSuite, scenes::kMaxScenesPerFabric == fabric_capacity); + NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity == fabric_capacity); // Test of Get with changes to Endpoint capacity // Endpoint 1 - sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1, scenes::kMaxScenesPerEndpoint - 2); + sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1, defaultTestTableSize - 2); NL_TEST_ASSERT(aSuite, nullptr != sceneTable); VerifyOrReturn(nullptr != sceneTable); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity)); - NL_TEST_ASSERT(aSuite, scenes::kMaxScenesPerFabric - 1 == fabric_capacity); + NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity - 1 == fabric_capacity); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric2, fabric_capacity)); - NL_TEST_ASSERT(aSuite, scenes::kMaxScenesPerFabric - 1 == fabric_capacity); + NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity - 1 == fabric_capacity); // Test Endpoint 2's capacity remains unaffected - sceneTable = scenes::GetSceneTableImpl(kTestEndpoint2); + sceneTable = scenes::GetSceneTableImpl(kTestEndpoint2, defaultTestTableSize); NL_TEST_ASSERT(aSuite, nullptr != sceneTable); VerifyOrReturn(nullptr != sceneTable); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity)); - NL_TEST_ASSERT(aSuite, scenes::kMaxScenesPerFabric == fabric_capacity); + NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity == fabric_capacity); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric2, fabric_capacity)); - NL_TEST_ASSERT(aSuite, scenes::kMaxScenesPerFabric == fabric_capacity); + NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity == fabric_capacity); NL_TEST_ASSERT(aSuite, nullptr != sceneTable); VerifyOrReturn(nullptr != sceneTable); // Test Insertion then change of capacity - sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1); + sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1, defaultTestTableSize); NL_TEST_ASSERT(aSuite, nullptr != sceneTable); VerifyOrReturn(nullptr != sceneTable); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene1)); @@ -1540,22 +1541,22 @@ void TestEndpointScenes(nlTestSuite * aSuite, void * aContext) NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene3)); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene4)); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity)); - NL_TEST_ASSERT(aSuite, scenes::kMaxScenesPerFabric - 4 == fabric_capacity); + NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity - 4 == fabric_capacity); - sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1, scenes::kMaxScenesPerFabric - 2); + sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1, defaultTestFabricCapacity - 2); NL_TEST_ASSERT(aSuite, nullptr != sceneTable); VerifyOrReturn(nullptr != sceneTable); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity)); - NL_TEST_ASSERT(aSuite, scenes::kMaxScenesPerFabric - 6 == fabric_capacity); + NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity - 6 == fabric_capacity); - sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1, scenes::kMaxScenesPerFabric - 4); + sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1, defaultTestFabricCapacity - 4); NL_TEST_ASSERT(aSuite, nullptr != sceneTable); VerifyOrReturn(nullptr != sceneTable); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity)); NL_TEST_ASSERT(aSuite, 0 == fabric_capacity); // Test making the endpoint scene table smaller than the actual number of scenes on it - sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1, scenes::kMaxScenesPerFabric - 5); + sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1, defaultTestFabricCapacity - 5); NL_TEST_ASSERT(aSuite, nullptr != sceneTable); VerifyOrReturn(nullptr != sceneTable); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity)); @@ -1564,15 +1565,12 @@ void TestEndpointScenes(nlTestSuite * aSuite, void * aContext) void TestOTAChanges(nlTestSuite * aSuite, void * aContext) { - SceneTable * sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1); + SceneTable * sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1, defaultTestTableSize); NL_TEST_ASSERT(aSuite, nullptr != sceneTable); VerifyOrReturn(nullptr != sceneTable); // Reset test ResetSceneTable(sceneTable); - sceneTable = scenes::GetSceneTableImpl(kTestEndpoint1); - NL_TEST_ASSERT(aSuite, nullptr != sceneTable); - VerifyOrReturn(nullptr != sceneTable); SceneTableEntry scene; uint8_t fabric_capacity = 0; @@ -1589,8 +1587,9 @@ void TestOTAChanges(nlTestSuite * aSuite, void * aContext) NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene8)); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity)); NL_TEST_ASSERT(aSuite, 0 == fabric_capacity); - auto * iterator = sceneTable->IterateSceneEntries(kFabric1); - NL_TEST_ASSERT(aSuite, scenes::kMaxScenesPerFabric == iterator->Count()); + uint8_t scene_table_fabric1_capacity = fabric_capacity; + auto * iterator = sceneTable->IterateSceneEntries(kFabric1); + NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity == iterator->Count()); iterator->Release(); // Fill fabric 2 to capacity @@ -1604,14 +1603,56 @@ void TestOTAChanges(nlTestSuite * aSuite, void * aContext) NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric2, scene8)); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity)); NL_TEST_ASSERT(aSuite, 0 == fabric_capacity); - iterator = sceneTable->IterateSceneEntries(kFabric2); - NL_TEST_ASSERT(aSuite, scenes::kMaxScenesPerFabric == iterator->Count()); + uint8_t scene_table_fabric2_capacity = fabric_capacity; + iterator = sceneTable->IterateSceneEntries(kFabric2); + NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity == iterator->Count()); iterator->Release(); // SceneTable should be full at this point uint8_t scene_count; NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetEndpointSceneCount(scene_count)); // Global count should not have been modified - NL_TEST_ASSERT(aSuite, scenes::kMaxScenesPerEndpoint == scene_count); + NL_TEST_ASSERT(aSuite, defaultTestTableSize == scene_count); + + // Create a scene table with a greater capacity than the original one (Max allowed capacity from gen_config.h) + TestSceneTableImpl ExpandedSceneTable(scenes::kMaxScenesPerFabric, scenes::kMaxScenesPerEndpoint); + NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ExpandedSceneTable.Init(&testStorage)); + ExpandedSceneTable.SetEndpoint(kTestEndpoint1); + + NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ExpandedSceneTable.GetRemainingCapacity(kFabric1, fabric_capacity)); + NL_TEST_ASSERT(aSuite, + scene_table_fabric1_capacity + (scenes::kMaxScenesPerFabric - defaultTestFabricCapacity) == fabric_capacity); + NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ExpandedSceneTable.GetRemainingCapacity(kFabric2, fabric_capacity)); + NL_TEST_ASSERT(aSuite, + scene_table_fabric2_capacity + (scenes::kMaxScenesPerFabric - defaultTestFabricCapacity) == fabric_capacity); + + // We should be able to insert 4 scenes into fabric 2 + NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ExpandedSceneTable.SetSceneTableEntry(kFabric2, scene9)); + NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ExpandedSceneTable.SetSceneTableEntry(kFabric2, scene13)); + NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ExpandedSceneTable.SetSceneTableEntry(kFabric2, scene14)); + NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ExpandedSceneTable.SetSceneTableEntry(kFabric2, scene15)); + NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ExpandedSceneTable.GetRemainingCapacity(kFabric2, fabric_capacity)); + NL_TEST_ASSERT(aSuite, 0 == fabric_capacity); + + // Fabric 1's capacity should have remain unchanged + NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ExpandedSceneTable.GetRemainingCapacity(kFabric1, fabric_capacity)); + NL_TEST_ASSERT(aSuite, + scene_table_fabric1_capacity + (scenes::kMaxScenesPerFabric - defaultTestFabricCapacity) == fabric_capacity); + + // Global count should have increased by (scenes::kMaxScenesPerFarbic - defaultTestFabricCapacity) + NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ExpandedSceneTable.GetEndpointSceneCount(scene_count)); + NL_TEST_ASSERT(aSuite, defaultTestTableSize + (scenes::kMaxScenesPerFabric - defaultTestFabricCapacity) == scene_count); + + // Same test for 4 insertion in fabric 1 + NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ExpandedSceneTable.SetSceneTableEntry(kFabric1, scene9)); + NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ExpandedSceneTable.SetSceneTableEntry(kFabric1, scene13)); + NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ExpandedSceneTable.SetSceneTableEntry(kFabric1, scene14)); + NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ExpandedSceneTable.SetSceneTableEntry(kFabric1, scene15)); + NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ExpandedSceneTable.GetRemainingCapacity(kFabric1, fabric_capacity)); + NL_TEST_ASSERT(aSuite, 0 == fabric_capacity); + + // Global count should be at defaultTestTableSize + (scenes::kMaxScenesPerEndpoint - defaultTestTableSize) + NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ExpandedSceneTable.GetEndpointSceneCount(scene_count)); + NL_TEST_ASSERT(aSuite, defaultTestTableSize + (scenes::kMaxScenesPerEndpoint - defaultTestTableSize) == scene_count); // Test failure to init a SceneTable with sizes above the defined max scenes per fabric or globaly TestSceneTableImpl SceneTableTooManyPerFabric(scenes::kMaxScenesPerFabric + 1, scenes::kMaxScenesPerEndpoint); @@ -1622,8 +1663,12 @@ void TestOTAChanges(nlTestSuite * aSuite, void * aContext) NL_TEST_ASSERT(aSuite, CHIP_ERROR_INVALID_INTEGER_VALUE == SceneTableTooManyGlobal.Init(&testStorage)); SceneTableTooManyGlobal.Finish(); - // Create a new table with a different limit of scenes per fabric - TestSceneTableImpl ReducedSceneTable(scenes::kMaxScenesPerFabric - 1, scenes::kMaxScenesPerEndpoint - 2); + // Create a new table with a lower limit of scenes per fabric + uint8_t newCapacity = defaultTestFabricCapacity - 1; + uint8_t newTableSize = defaultTestTableSize - 2; + uint8_t capacityDifference = static_cast(scenes::kMaxScenesPerFabric - newCapacity); + uint8_t tableSizeDifference = static_cast(scenes::kMaxScenesPerEndpoint - newTableSize); + TestSceneTableImpl ReducedSceneTable(newCapacity, newTableSize); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ReducedSceneTable.Init(&testStorage)); ReducedSceneTable.SetEndpoint(kTestEndpoint1); @@ -1632,6 +1677,8 @@ void TestOTAChanges(nlTestSuite * aSuite, void * aContext) NL_TEST_ASSERT(aSuite, scenes::kMaxScenesPerEndpoint == scene_count); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ReducedSceneTable.GetRemainingCapacity(kFabric1, fabric_capacity)); NL_TEST_ASSERT(aSuite, 0 == fabric_capacity); + NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ReducedSceneTable.GetRemainingCapacity(kFabric2, fabric_capacity)); + NL_TEST_ASSERT(aSuite, 0 == fabric_capacity); // Load a scene from fabric 1, this should adjust fabric 1 scene count in flash NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ReducedSceneTable.GetSceneTableEntry(kFabric1, sceneId1, scene)); @@ -1639,66 +1686,74 @@ void TestOTAChanges(nlTestSuite * aSuite, void * aContext) // The number count of scenes in Fabric 1 should have been adjusted here iterator = ReducedSceneTable.IterateSceneEntries(kFabric1); - NL_TEST_ASSERT(aSuite, scenes::kMaxScenesPerFabric - 1 == iterator->Count()); + NL_TEST_ASSERT(aSuite, newCapacity == iterator->Count()); iterator->Release(); - // Capacity should still be 0 + // Capacity should still be 0 in fabric 1 + NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ReducedSceneTable.GetRemainingCapacity(kFabric1, fabric_capacity)); NL_TEST_ASSERT(aSuite, 0 == fabric_capacity); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ReducedSceneTable.GetEndpointSceneCount(scene_count)); - // Global count should have been reduced by 1 - NL_TEST_ASSERT(aSuite, scenes::kMaxScenesPerEndpoint - 1 == scene_count); + // Global count should have been reduced by the difference between the max fabric capacity of a fabric and the + // new fabric capacity since we haven't loaded from fabric 2 yet + NL_TEST_ASSERT(aSuite, scenes::kMaxScenesPerEndpoint - capacityDifference == scene_count); // Remove a Scene from the Fabric 1 - NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ReducedSceneTable.RemoveSceneTableEntry(kFabric1, scene.mStorageId)); + NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ReducedSceneTable.RemoveSceneTableEntry(kFabric1, scene1.mStorageId)); // Check count updated for fabric iterator = ReducedSceneTable.IterateSceneEntries(kFabric1); - NL_TEST_ASSERT(aSuite, scenes::kMaxScenesPerFabric - 2 == iterator->Count()); + NL_TEST_ASSERT(aSuite, static_cast(newCapacity - 1) == iterator->Count()); iterator->Release(); // Check fabric still doesn't have capacity because fabric 2 still have a higher number of scene than allowed NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ReducedSceneTable.GetRemainingCapacity(kFabric1, fabric_capacity)); NL_TEST_ASSERT(aSuite, 0 == fabric_capacity); // Remove another scene from fabric 1 NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ReducedSceneTable.RemoveSceneTableEntry(kFabric1, scene2.mStorageId)); + NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ReducedSceneTable.RemoveSceneTableEntry(kFabric1, scene3.mStorageId)); + NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ReducedSceneTable.RemoveSceneTableEntry(kFabric1, scene4.mStorageId)); + NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ReducedSceneTable.RemoveSceneTableEntry(kFabric1, scene5.mStorageId)); + NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ReducedSceneTable.RemoveSceneTableEntry(kFabric1, scene6.mStorageId)); // Check count updated for fabric iterator = ReducedSceneTable.IterateSceneEntries(kFabric1); - NL_TEST_ASSERT(aSuite, scenes::kMaxScenesPerFabric - 3 == iterator->Count()); + NL_TEST_ASSERT(aSuite, static_cast(newCapacity - 6) == iterator->Count()); iterator->Release(); - // Global count should now have been adjusted + // Confirm global count has been updated NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ReducedSceneTable.GetEndpointSceneCount(scene_count)); - NL_TEST_ASSERT(aSuite, scenes::kMaxScenesPerEndpoint - 3 == scene_count); - // Confirm we now have capacity + NL_TEST_ASSERT(aSuite, scenes::kMaxScenesPerEndpoint - capacityDifference - 6 == scene_count); + // Confirm we now have capacity in fabric one NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ReducedSceneTable.GetRemainingCapacity(kFabric1, fabric_capacity)); NL_TEST_ASSERT(aSuite, 1 == fabric_capacity); - // Load a scene from fabric 2, this should adjust fabric 1 scene count in flash + // Load a scene from fabric 2, this should adjust fabric 2 scene count in flash NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ReducedSceneTable.GetSceneTableEntry(kFabric2, sceneId1, scene)); NL_TEST_ASSERT(aSuite, scene == scene1); - // The number count of scenes in Fabric 1 should have been adjusted here + // The number count of scenes in Fabric 2 should have been adjusted here iterator = ReducedSceneTable.IterateSceneEntries(kFabric2); - NL_TEST_ASSERT(aSuite, scenes::kMaxScenesPerFabric - 1 == iterator->Count()); + NL_TEST_ASSERT(aSuite, defaultTestFabricCapacity - 1 == iterator->Count()); iterator->Release(); - // Global count should now have been adjusted + // Global count should also have been adjusted NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ReducedSceneTable.GetEndpointSceneCount(scene_count)); - NL_TEST_ASSERT(aSuite, scenes::kMaxScenesPerEndpoint - 4 == scene_count); - // Confirm we now have capacity in the first fabric since we previously removed 2 scenes form there + // had 24 scenes, truncated 5 from both (10) and deleted 6 from fabric 1: 8 scenes left + NL_TEST_ASSERT(aSuite, scenes::kMaxScenesPerEndpoint - tableSizeDifference - 6 == scene_count); + // Confirm we now have capacity of 6 in the first fabric since we previously removed 6 scenes form there NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ReducedSceneTable.GetRemainingCapacity(kFabric1, fabric_capacity)); - NL_TEST_ASSERT(aSuite, 2 == fabric_capacity); + NL_TEST_ASSERT(aSuite, 6 == fabric_capacity); // Fabric 2 should still be at capacity NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == ReducedSceneTable.GetRemainingCapacity(kFabric2, fabric_capacity)); NL_TEST_ASSERT(aSuite, 0 == fabric_capacity); ReducedSceneTable.Finish(); - // The Scene 8 should now have been deleted from the memory and thus not be accessible from both fabrics in the original scene - // table + // The Scene 8 should now have been truncated from the memory and thus not be accessible from both fabrics in the + // original scene table NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric1, sceneId8, scene)); NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric2, sceneId8, scene)); // The Remaining capacity in the original scene table therefore have been modified as well - // Fabric 2 should still be at capacity + // Fabric 2 should still be almost at capacity NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric1, fabric_capacity)); - NL_TEST_ASSERT(aSuite, 3 == fabric_capacity); + NL_TEST_ASSERT(aSuite, 7 == fabric_capacity); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetRemainingCapacity(kFabric2, fabric_capacity)); + NL_TEST_ASSERT(aSuite, 1 == fabric_capacity); } diff --git a/src/app/tests/suites/certification/Test_TC_S_1_1.yaml b/src/app/tests/suites/certification/Test_TC_S_1_1.yaml index 0fdc16b325b0d7..ed3fe73f726710 100644 --- a/src/app/tests/suites/certification/Test_TC_S_1_1.yaml +++ b/src/app/tests/suites/certification/Test_TC_S_1_1.yaml @@ -48,10 +48,7 @@ tests: response: constraints: type: bitmap32 - hasMasksSet: [0x1] - # This needs to be changed in the Name Support PR: https://github.com/project-chip/connectedhomeip/pull/29639 - # Issue in Test plan repo: https://github.com/CHIP-Specifications/chip-test-plans/issues/3515 - #hasMasksClear: [0x1] + hasMasksClear: [0x1] - label: "Step 3a: Read FeatureMap (global attribute 65532)" PICS: S.S.F00 @@ -62,6 +59,22 @@ tests: type: bitmap32 hasMasksSet: [0x1] + - label: "Step 3b: Read FeatureMap (global attribute 65532)" + command: "readAttribute" + attribute: "FeatureMap" + response: + constraints: + type: bitmap32 + hasMasksSet: [0x2] + + - label: "Step 3c: Read FeatureMap (global attribute 65532)" + command: "readAttribute" + attribute: "FeatureMap" + response: + constraints: + type: bitmap32 + hasMasksSet: [0x4] + - label: "Step 4: Read Mandatory attributes in AttributeList (global attribute 65531)" diff --git a/src/app/tests/suites/certification/ci-pics-values b/src/app/tests/suites/certification/ci-pics-values index 4869039cf87fef..e2f080c858c92c 100644 --- a/src/app/tests/suites/certification/ci-pics-values +++ b/src/app/tests/suites/certification/ci-pics-values @@ -679,7 +679,7 @@ S.S.AM=0 S.S.AO=0 S.S.F00=1 S.S.F01=1 -S.S.F02=0 +S.S.F02=1 S.S.F03=0 PICS_SC_RECALL_SCENE_TRANSITION_TIME=1 diff --git a/src/app/util/mock/include/zap-generated/gen_config.h b/src/app/util/mock/include/zap-generated/gen_config.h index 08d2d851b6b93d..c5dff6931128fe 100644 --- a/src/app/util/mock/include/zap-generated/gen_config.h +++ b/src/app/util/mock/include/zap-generated/gen_config.h @@ -18,3 +18,4 @@ #pragma once #define EMBER_BINDING_TABLE_SIZE 20 +#define MATTER_SCENES_TABLE_SIZE 24 \ No newline at end of file diff --git a/src/app/zap-templates/templates/app/gen_config.zapt b/src/app/zap-templates/templates/app/gen_config.zapt index 01048170425067..4accc4a61be151 100644 --- a/src/app/zap-templates/templates/app/gen_config.zapt +++ b/src/app/zap-templates/templates/app/gen_config.zapt @@ -5,57 +5,58 @@ /**** Cluster endpoint counts ****/ {{#all_user_clusters}} -#define EMBER_AF_{{asDelimitedMacro define}}_{{asDelimitedMacro side}}_ENDPOINT_COUNT ({{user_endpoint_count_by_cluster id side}}) +#define EMBER_AF_{{as_delimited_macro define}}_{{as_delimited_macro side}}_ENDPOINT_COUNT ({{user_endpoint_count_by_cluster id side}}) {{/all_user_clusters}} /**** Cluster Plugins ****/ {{#all_user_clusters}} // Use this macro to check if the {{side}} side of the {{name}} cluster is included -#define ZCL_USING_{{asDelimitedMacro define}}_{{asDelimitedMacro side}} -#define EMBER_AF_PLUGIN_{{asDelimitedMacro name}}_{{asDelimitedMacro side}} -{{#if (isServer side)}} -#define EMBER_AF_PLUGIN_{{asDelimitedMacro name}} +#define ZCL_USING_{{as_delimited_macro define}}_{{as_delimited_macro side}} +#define EMBER_AF_PLUGIN_{{as_delimited_macro name}}_{{as_delimited_macro side}} +{{#if (is_server side)}} +#define EMBER_AF_PLUGIN_{{as_delimited_macro name}} {{/if}} -{{#if (isStrEqual name "Color Control")}} -{{#if (isServer side)}} +{{#if (is_str_equal name "Color Control")}} +{{#if (is_server side)}} // User options for {{side}} plugin {{name}} #define EMBER_AF_PLUGIN_COLOR_CONTROL_SERVER_XY #define EMBER_AF_PLUGIN_COLOR_CONTROL_SERVER_TEMP #define EMBER_AF_PLUGIN_COLOR_CONTROL_SERVER_HSV {{/if}} -{{else if (isStrEqual name "IAS Zone")}} +{{else if (is_str_equal name "IAS Zone")}} // User options for {{side}} plugin {{name}} -{{#if (isServer side)}} +{{#if (is_server side)}} #define EMBER_AF_PLUGIN_IAS_ZONE_SERVER_ZONE_TYPE 541 {{else}} #define EMBER_AF_PLUGIN_IAS_ZONE_CLIENT_MAX_DEVICES 10 {{/if}} -{{else if (isStrEqual name "Level Control")}} -{{#if (isServer side)}} +{{else if (is_str_equal name "Level Control")}} +{{#if (is_server side)}} // User options for {{side}} plugin {{name}} #define EMBER_AF_PLUGIN_LEVEL_CONTROL_MAXIMUM_LEVEL 254 #define EMBER_AF_PLUGIN_LEVEL_CONTROL_MINIMUM_LEVEL 0 #define EMBER_AF_PLUGIN_LEVEL_CONTROL_RATE 0 {{/if}} -{{else if (isStrEqual name "Scenes")}} -{{#if (isServer side)}} +{{else if (is_str_equal name "Scenes")}} +{{#if (is_server side)}} // User options for {{side}} plugin {{name}} -// Cluster spec 1.4.8.2 -#ifdef CHIP_CONFIG_MAX_SCENES_PER_FABRIC -#define MATTER_SCENES_TABLE_SIZE CHIP_CONFIG_MAX_SCENES_PER_FABRIC -#else -#define MATTER_SCENES_TABLE_SIZE 16 -#endif {{/if}} {{#all_user_cluster_generated_attributes}} -{{#if (isStrEqual ../name clusterName)}} -{{#if (isStrEqual name "FeatureMap")}} - +{{#if (is_str_equal ../name clusterName)}} +{{#if (is_str_equal name "FeatureMap")}} // Scenes FeatureMap Attribute Toggle Scenes Name feature // App cluster specs 1.4.4 #define MATTER_CLUSTER_SCENE_NAME_SUPPORT_MASK 0x0001 #define MATTER_CLUSTER_SCENE_NAME_SUPPORT ({{asHex defaultValue 4}} & MATTER_CLUSTER_SCENE_NAME_SUPPORT_MASK) +// Scenes FeatureMap Table Size feature used for the MATTER_SCENES_TABLE_SIZE define +// App cluster specs 1.4.4.2 +#define MATTER_CLUSTER_TABLE_SIZE_SUPPORT_MASK 0x0001 +#define MATTER_CLUSTER_TABLE_SIZE_SUPPORT ({{asHex defaultValue 4}} & MATTER_CLUSTER_TABLE_SIZE_SUPPORT_MASK) +{{/if}} +{{#if (is_str_equal name "SceneTableSize")}} +// Cluster spec 1.4.8.7 +#define MATTER_SCENES_TABLE_SIZE {{defaultValue}} {{/if}} {{/if}} {{/all_user_cluster_generated_attributes}} diff --git a/src/lib/core/CHIPConfig.h b/src/lib/core/CHIPConfig.h index 30d6d6b8a65b36..5ef55d3ff2239a 100644 --- a/src/lib/core/CHIPConfig.h +++ b/src/lib/core/CHIPConfig.h @@ -1403,13 +1403,6 @@ extern const char CHIP_NON_PRODUCTION_MARKER[]; #define CHIP_CONFIG_MAX_SUBSCRIPTION_RESUMPTION_STORAGE_CONCURRENT_ITERATORS 2 #endif -/** - * @brief The minimum number of scenes to support according to spec - */ -#ifndef CHIP_CONFIG_MAX_SCENES_PER_ENDPOINT -#define CHIP_CONFIG_MAX_SCENES_PER_ENDPOINT 16 -#endif - /** * @brief Maximum length of Scene names */ @@ -1417,13 +1410,6 @@ extern const char CHIP_NON_PRODUCTION_MARKER[]; #define CHIP_CONFIG_SCENES_CLUSTER_MAXIMUM_NAME_LENGTH 16 #endif -/** - * @brief The maximum number of scenes allowed on a single fabric - */ -#ifndef CHIP_CONFIG_SCENES_MAX_PER_FABRIC -#define CHIP_CONFIG_SCENES_MAX_PER_FABRIC (CHIP_CONFIG_MAX_SCENES_PER_ENDPOINT / 2) -#endif - /** * @brief The maximum number of attribute value pairs in an extension field set. */