diff --git a/src/app/clusters/scenes/ExtensionFieldSetsImpl.cpp b/src/app/clusters/scenes/ExtensionFieldSetsImpl.cpp index 7f8f7034ed19ea..05b49a0d615e03 100644 --- a/src/app/clusters/scenes/ExtensionFieldSetsImpl.cpp +++ b/src/app/clusters/scenes/ExtensionFieldSetsImpl.cpp @@ -121,15 +121,17 @@ CHIP_ERROR ExtensionFieldSetsImpl::GetFieldSetAtPosition(ExtensionFieldSet & fie CHIP_ERROR ExtensionFieldSetsImpl::RemoveFieldAtPosition(uint8_t position) { - VerifyOrReturnError(position < kMaxClusterPerScenes, CHIP_ERROR_INVALID_ARGUMENT); - VerifyOrReturnValue(!this->IsEmpty() && !mEFS[position].IsEmpty(), CHIP_NO_ERROR); + VerifyOrReturnValue(position < mFieldSetsCount, CHIP_NO_ERROR); uint8_t nextPos = static_cast(position + 1); uint8_t moveNum = static_cast(kMaxClusterPerScenes - nextPos); // TODO: Implement general array management methods - // Compress array after removal - memmove(&mEFS[position], &mEFS[nextPos], sizeof(ExtensionFieldSet) * moveNum); + // Compress array after removal, if the removed position is not the last + if (moveNum) + { + memmove(&mEFS[position], &mEFS[nextPos], sizeof(ExtensionFieldSet) * moveNum); + } mFieldSetsCount--; // Clear last occupied position diff --git a/src/app/clusters/scenes/SceneTable.h b/src/app/clusters/scenes/SceneTable.h index 50a89221d60969..d1ea719231c44e 100644 --- a/src/app/clusters/scenes/SceneTable.h +++ b/src/app/clusters/scenes/SceneTable.h @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include namespace chip { @@ -30,8 +30,7 @@ namespace scenes { typedef uint8_t SceneIndex; typedef uint32_t TransitionTimeMs; -typedef uint16_t SceneTransitionTime; -typedef uint8_t TransitionTime100ms; +typedef uint32_t SceneTransitionTime; constexpr GroupId kGlobalGroupSceneId = 0x0000; constexpr SceneIndex kUndefinedSceneIndex = 0xff; @@ -42,7 +41,7 @@ static constexpr size_t kSceneNameMax = CHIP_CONFIG_SCENES_CLUSTER_MAXIMUM // Handler's are meant to retrieve a single cluster's extension field set, therefore the maximum number allowed is the maximal // number of extension field set. -static constexpr uint8_t kMaxSceneHandlers = CHIP_CONFIG_SCENES_MAX_CLUSTERS_PER_SCENE; +static constexpr uint8_t kMaxSceneHandlers = CHIP_CONFIG_SCENES_MAX_SCENE_HANDLERS; /// @brief Abstract class allowing different Endpoints interactions with the ExtensionFieldSets added to and retrieved from the /// scene Table. The Scene Handler's are meant as interface between various clusters and the Scene table. The expected behaviour of @@ -156,27 +155,22 @@ class SceneTable /// mSceneTransitionTimeSeconds in enhanced scene commands struct SceneData { - char mName[kSceneNameMax] = { 0 }; - size_t mNameLength = 0; - SceneTransitionTime mSceneTransitionTimeSeconds = 0; + char mName[kSceneNameMax] = { 0 }; + size_t mNameLength = 0; + SceneTransitionTime mSceneTransitionTimeMs = 0; EFStype mExtensionFieldSets; - TransitionTime100ms mTransitionTime100ms = 0; - SceneData(const CharSpan & sceneName = CharSpan(), SceneTransitionTime time = 0, TransitionTime100ms time100ms = 0) : - mSceneTransitionTimeSeconds(time), mTransitionTime100ms(time100ms) + SceneData(const CharSpan & sceneName = CharSpan(), SceneTransitionTime time = 0) : mSceneTransitionTimeMs(time) { this->SetName(sceneName); } - SceneData(EFStype fields, const CharSpan & sceneName = CharSpan(), SceneTransitionTime time = 0, - TransitionTime100ms time100ms = 0) : - mSceneTransitionTimeSeconds(time), - mTransitionTime100ms(time100ms) + SceneData(EFStype fields, const CharSpan & sceneName = CharSpan(), SceneTransitionTime time = 0) : + mSceneTransitionTimeMs(time) { this->SetName(sceneName); mExtensionFieldSets = fields; } - SceneData(const SceneData & other) : - mSceneTransitionTimeSeconds(other.mSceneTransitionTimeSeconds), mTransitionTime100ms(other.mTransitionTime100ms) + SceneData(const SceneData & other) : mSceneTransitionTimeMs(other.mSceneTransitionTimeMs) { this->SetName(CharSpan(other.mName, other.mNameLength)); mExtensionFieldSets = other.mExtensionFieldSets; @@ -201,25 +195,22 @@ class SceneTable void Clear() { this->SetName(CharSpan()); - mSceneTransitionTimeSeconds = 0; - mTransitionTime100ms = 0; + mSceneTransitionTimeMs = 0; mExtensionFieldSets.Clear(); } bool operator==(const SceneData & other) { return (this->mNameLength == other.mNameLength && !memcmp(this->mName, other.mName, this->mNameLength) && - (this->mSceneTransitionTimeSeconds == other.mSceneTransitionTimeSeconds) && - (this->mTransitionTime100ms == other.mTransitionTime100ms) && + (this->mSceneTransitionTimeMs == other.mSceneTransitionTimeMs) && (this->mExtensionFieldSets == other.mExtensionFieldSets)); } void operator=(const SceneData & other) { this->SetName(CharSpan(other.mName, other.mNameLength)); - this->mExtensionFieldSets = other.mExtensionFieldSets; - this->mSceneTransitionTimeSeconds = other.mSceneTransitionTimeSeconds; - this->mTransitionTime100ms = other.mTransitionTime100ms; + this->mExtensionFieldSets = other.mExtensionFieldSets; + this->mSceneTransitionTimeMs = other.mSceneTransitionTimeMs; } }; diff --git a/src/app/clusters/scenes/SceneTableImpl.cpp b/src/app/clusters/scenes/SceneTableImpl.cpp index af67496def2686..e502f57a530290 100644 --- a/src/app/clusters/scenes/SceneTableImpl.cpp +++ b/src/app/clusters/scenes/SceneTableImpl.cpp @@ -28,24 +28,12 @@ namespace scenes { enum class TagSceneImpl : uint8_t { kSceneCount = 1, - kNextFabric, }; using SceneTableEntry = DefaultSceneTableImpl::SceneTableEntry; using SceneStorageId = DefaultSceneTableImpl::SceneStorageId; using SceneData = DefaultSceneTableImpl::SceneData; -struct FabricHavingSceneList : public CommonPersistentData::FabricList -{ - // This implementation uses the same key as the GroupFabricList from GroupDataProviderImpl to avoid duplicating the list in - // memory. If a different GroupDataProvider implementation is used, it will create the list in flash memory. - CHIP_ERROR UpdateKey(StorageKeyName & key) override - { - key = DefaultStorageKeyAllocator::GroupFabricList(); - return CHIP_NO_ERROR; - } -}; - // Worst case tested: Add Scene Command with EFS using the default SerializeAdd Method. This yielded a serialized scene of 212bytes // when using the OnOff, Level Control and Color Control as well as the maximal name length of 16 bytes. Putting 256 gives some // slack in case different clusters are used. Value obtained by using writer.GetLengthWritten at the end of the SceneTableData @@ -93,8 +81,7 @@ struct SceneTableData : public SceneTableEntry, PersistentData FabricIndex fabric_index = kUndefinedFabricIndex; uint8_t scene_count = 0; SceneStorageId scene_map[kMaxScenePerFabric]; - FabricIndex next = kUndefinedFabricIndex; FabricSceneData() = default; FabricSceneData(FabricIndex fabric) : fabric_index(fabric) {} @@ -175,7 +159,6 @@ struct FabricSceneData : public PersistentData { scene_map[i].Clear(); } - next = kUndefinedFabricIndex; } CHIP_ERROR Serialize(TLV::TLVWriter & writer) const override @@ -184,7 +167,6 @@ struct FabricSceneData : public PersistentData ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag(), TLV::kTLVType_Structure, container)); ReturnErrorOnFailure(writer.Put(TLV::ContextTag(TagSceneImpl::kSceneCount), (scene_count))); - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(TagSceneImpl::kNextFabric), (next))); // Storing the scene map for (uint8_t i = 0; i < kMaxScenePerFabric; i++) { @@ -205,8 +187,6 @@ struct FabricSceneData : public PersistentData ReturnErrorOnFailure(reader.Next(TLV::ContextTag(TagSceneImpl::kSceneCount))); ReturnErrorOnFailure(reader.Get(scene_count)); - ReturnErrorOnFailure(reader.Next(TLV::ContextTag(TagSceneImpl::kNextFabric))); - ReturnErrorOnFailure(reader.Get(next)); uint8_t i = 0; while (reader.Next(TLV::ContextTag(TagScene::kEndpointID)) != CHIP_END_OF_TLV) @@ -223,86 +203,6 @@ struct FabricSceneData : public PersistentData return reader.ExitContainer(container); } - // Register the fabric in the list of fabrics having scenes - CHIP_ERROR Register(PersistentStorageDelegate * storage) - { - FabricHavingSceneList fabric_list; - CHIP_ERROR err = fabric_list.Load(storage); - if (CHIP_ERROR_NOT_FOUND == err) - { - // New fabric list - fabric_list.first_entry = fabric_index; - fabric_list.entry_count = 1; - return fabric_list.Save(storage); - } - ReturnErrorOnFailure(err); - - // Existing fabric list, search for existing entry - FabricSceneData fabric(fabric_list.first_entry); - for (size_t i = 0; i < fabric_list.entry_count; i++) - { - err = fabric.Load(storage); - if (CHIP_NO_ERROR != err) - { - break; - } - if (fabric.fabric_index == this->fabric_index) - { - // Fabric already registered - return CHIP_NO_ERROR; - } - fabric.fabric_index = fabric.next; - } - // Add this fabric to the fabric list - this->next = fabric_list.first_entry; - fabric_list.first_entry = this->fabric_index; - fabric_list.entry_count++; - return fabric_list.Save(storage); - } - - // Remove the fabric from the fabrics' linked list - CHIP_ERROR Unregister(PersistentStorageDelegate * storage) const - { - FabricHavingSceneList fabric_list; - CHIP_ERROR err = fabric_list.Load(storage); - VerifyOrReturnValue(CHIP_ERROR_NOT_FOUND != err, CHIP_NO_ERROR); - ReturnErrorOnFailure(err); - - // Existing fabric list, search for existing entry - FabricSceneData fabric(fabric_list.first_entry); - FabricSceneData prev; - - for (size_t i = 0; i < fabric_list.entry_count; i++) - { - err = fabric.Load(storage); - if (CHIP_NO_ERROR != err) - { - break; - } - if (fabric.fabric_index == this->fabric_index) - { - // Fabric found - if (i == 0) - { - // Remove first fabric - fabric_list.first_entry = this->next; - } - else - { - // Remove intermediate fabric - prev.next = this->next; - ReturnErrorOnFailure(prev.Save(storage)); - } - VerifyOrReturnError(fabric_list.entry_count > 0, CHIP_ERROR_INTERNAL); - fabric_list.entry_count--; - return fabric_list.Save(storage); - } - prev = fabric; - fabric.fabric_index = fabric.next; - } - // Fabric not in the list - return CHIP_ERROR_NOT_FOUND; - } /// @brief Finds the index where to insert current scene by going through the whole table and looking if the scene is already in /// there. If the target is not in the table, sets idx to the first empty space /// @param target_scene Storage Id of scene to store @@ -336,17 +236,6 @@ struct FabricSceneData : public PersistentData return CHIP_ERROR_NO_MEMORY; } - CHIP_ERROR Save(PersistentStorageDelegate * storage) override - { - ReturnErrorOnFailure(Register(storage)); - return PersistentData::Save(storage); - } - - CHIP_ERROR Delete(PersistentStorageDelegate * storage) override - { - ReturnErrorOnFailure(Unregister(storage)); - return PersistentData::Delete(storage); - } CHIP_ERROR SaveScene(PersistentStorageDelegate * storage, const SceneTableEntry & entry) { @@ -538,7 +427,10 @@ CHIP_ERROR DefaultSceneTableImpl::UnregisterHandler(SceneHandler * handler) // TODO: Implement general array management methods // Compress array after removal - memmove(&this->mHandlers[position], &this->mHandlers[nextPos], sizeof(this->mHandlers[position]) * moveNum); + if (moveNum) + { + memmove(&this->mHandlers[position], &this->mHandlers[nextPos], sizeof(this->mHandlers[position]) * moveNum); + } this->mNumHandlers--; // Clear last occupied position @@ -602,9 +494,8 @@ CHIP_ERROR DefaultSceneTableImpl::SceneApplyEFS(FabricIndex fabric_index, const for (uint8_t i = 0; i < scene.mStorageData.mExtensionFieldSets.GetFieldSetCount(); i++) { scene.mStorageData.mExtensionFieldSets.GetFieldSetAtPosition(EFS, i); - cluster = EFS.mID; - time = scene.mStorageData.mSceneTransitionTimeSeconds * 1000 + - (scene.mStorageData.mTransitionTime100ms ? scene.mStorageData.mTransitionTime100ms * 10 : 0); + cluster = EFS.mID; + time = scene.mStorageData.mSceneTransitionTimeMs; ByteSpan EFSSpan = MutableByteSpan(EFS.mBytesBuffer, EFS.mUsedBytes); if (!EFS.IsEmpty()) diff --git a/src/app/clusters/scenes/SceneTableImpl.h b/src/app/clusters/scenes/SceneTableImpl.h index 56724b33cb9ccd..e80e68a9d3145a 100644 --- a/src/app/clusters/scenes/SceneTableImpl.h +++ b/src/app/clusters/scenes/SceneTableImpl.h @@ -31,16 +31,14 @@ namespace scenes { /// kGroupID: Tag for GroupID if the Scene is a Group Scene /// kID: Tag for the scene ID together with the two previous tag, forms the SceneStorageID /// kName: Tag for the name of the scene -/// kTransitionTime: Tag for the transition time of the scene in seconds -/// kTransitionTime100: Tag for the transition time of the scene in tenth of a second (enhanced scenes) +/// kTransitionTime: Tag for the transition time of the scene in miliseconds enum class TagScene : uint8_t { kEndpointID = 1, kGroupID, kID, kName, - kTransitionTime, - kTransitionTime100, + kTransitionTimeMs, }; using clusterId = chip::ClusterId; diff --git a/src/app/tests/TestSceneTable.cpp b/src/app/tests/TestSceneTable.cpp index 2dbba1b92468f1..dc4049b11e0cbe 100644 --- a/src/app/tests/TestSceneTable.cpp +++ b/src/app/tests/TestSceneTable.cpp @@ -17,7 +17,6 @@ */ #include -#include #include #include #include @@ -83,17 +82,17 @@ CharSpan empty; // Scene data static const SceneData sceneData1(CharSpan("Scene #1")); -static const SceneData sceneData2(CharSpan("Scene #2"), 2, 5); -static const SceneData sceneData3(CharSpan("Scene #3"), 25); -static const SceneData sceneData4(CharSpan("Scene num4"), 5); +static const SceneData sceneData2(CharSpan("Scene #2"), 2000); +static const SceneData sceneData3(CharSpan("Scene #3"), 250); +static const SceneData sceneData4(CharSpan("Scene num4"), 5000); static const SceneData sceneData5(empty); -static const SceneData sceneData6(CharSpan("Scene #6"), 3, 15); -static const SceneData sceneData7(CharSpan("Scene #7"), 20, 5); -static const SceneData sceneData8(CharSpan("NAME TOO LOOONNG!"), 1, 10); -static const SceneData sceneData9(CharSpan("Scene #9"), 30, 15); -static const SceneData sceneData10(CharSpan("Scene #10"), 10, 1); -static const SceneData sceneData11(CharSpan("Scene #11"), 20, 10); -static const SceneData sceneData12(CharSpan("Scene #12"), 30, 5); +static const SceneData sceneData6(CharSpan("Scene #6"), 3000); +static const SceneData sceneData7(CharSpan("Scene #7"), 20000); +static const SceneData sceneData8(CharSpan("NAME TOO LOOONNG!"), 15000); +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); // Scenes SceneTableEntry scene1(sceneId1, sceneData1); @@ -126,15 +125,6 @@ static uint32_t OO_buffer_serialized_length = 0; static uint32_t LC_buffer_serialized_length = 0; static uint32_t CC_buffer_serialized_length = 0; -// Group related data -constexpr chip::GroupId kGroup1 = kMinFabricGroupId; -constexpr chip::GroupId kGroup2 = 0x2222; -constexpr chip::GroupId kGroup3 = 0x1111; - -static const chip::Credentials::GroupDataProvider::GroupInfo kGroupInfo1_1(kGroup1, "Group-1.1"); -static const chip::Credentials::GroupDataProvider::GroupInfo kGroupInfo1_2(kGroup2, "Group-1.2"); -static const chip::Credentials::GroupDataProvider::GroupInfo kGroupInfo1_3(kGroup3, "Group-1.3"); - /// @brief Simulates a Handler where Endpoint 1 supports onoff and level control and Endpoint 2 supports onoff and color control class TestSceneHandler : public scenes::DefaultSceneHandlerImpl { @@ -380,10 +370,6 @@ class TestSceneHandler : public scenes::DefaultSceneHandlerImpl // Storage static chip::TestPersistentStorageDelegate testStorage; - -// Groups -static chip::Crypto::DefaultSessionKeystore sSessionKeystore; -static chip::Credentials::GroupDataProviderImpl sProvider(kMaxGroupsPerFabric, kMaxGroupKeysPerFabric); // Scene static SceneTableImpl sSceneTable; static TestSceneHandler sHandler; @@ -394,12 +380,6 @@ void ResetSceneTable(SceneTable * sceneTable) sceneTable->RemoveFabric(kFabric2); } -void ResetProvider(chip::Credentials::GroupDataProvider * provider) -{ - provider->RemoveFabric(kFabric1); - provider->RemoveFabric(kFabric2); -} - void TestHandlerRegistration(nlTestSuite * aSuite, void * aContext) { SceneTable * sceneTable = &sSceneTable; @@ -937,125 +917,6 @@ void TestFabricScenes(nlTestSuite * aSuite, void * aContext) NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric2, sceneId3, scene)); } -void TestGroupScenesInteraction(nlTestSuite * aSuite, void * aContext) -{ - chip::Credentials::GroupDataProvider * provider = chip::Credentials::GetGroupDataProvider(); - NL_TEST_ASSERT(aSuite, provider); - SceneTable * sceneTable = &sSceneTable; - NL_TEST_ASSERT(aSuite, sceneTable); - - // Scene Entry - SceneTableEntry scene; - - // Reset test - ResetSceneTable(sceneTable); - ResetProvider(provider); - - // Group Info - chip::Credentials::GroupDataProvider::GroupInfo group; - - // Setup Group Data in Fabric 1 - NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == provider->SetGroupInfoAt(kFabric1, 0, kGroupInfo1_1)); - NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == provider->SetGroupInfoAt(kFabric1, 1, kGroupInfo1_2)); - NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == provider->SetGroupInfoAt(kFabric1, 2, kGroupInfo1_3)); - - // Validate data written properly - NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == provider->GetGroupInfoAt(kFabric1, 0, group)); - NL_TEST_ASSERT(aSuite, group == kGroupInfo1_1); - NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == provider->GetGroupInfoAt(kFabric1, 1, group)); - NL_TEST_ASSERT(aSuite, group == kGroupInfo1_2); - NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == provider->GetGroupInfoAt(kFabric1, 2, group)); - NL_TEST_ASSERT(aSuite, group == kGroupInfo1_3); - - // Setup Scene Data in Fabric 1 - NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene1)); - NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene2)); - NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene3)); - - // Validate data written properly - NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric1, sceneId1, scene)); - NL_TEST_ASSERT(aSuite, scene == scene1); - NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric1, sceneId2, scene)); - NL_TEST_ASSERT(aSuite, scene == scene2); - NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric1, sceneId3, scene)); - NL_TEST_ASSERT(aSuite, scene == scene3); - - // Setup Group Data in Fabric 2 - NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == provider->SetGroupInfoAt(kFabric2, 0, kGroupInfo1_3)); - NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == provider->SetGroupInfoAt(kFabric2, 1, kGroupInfo1_1)); - NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == provider->SetGroupInfoAt(kFabric2, 2, kGroupInfo1_2)); - - // Validate data written properly - NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == provider->GetGroupInfoAt(kFabric2, 0, group)); - NL_TEST_ASSERT(aSuite, group == kGroupInfo1_3); - NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == provider->GetGroupInfoAt(kFabric2, 1, group)); - NL_TEST_ASSERT(aSuite, group == kGroupInfo1_1); - NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == provider->GetGroupInfoAt(kFabric2, 2, group)); - NL_TEST_ASSERT(aSuite, group == kGroupInfo1_2); - - // Setup Scene Data in Fabric 1 - 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)); - - // Validate data written properly - NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric2, sceneId1, scene)); - NL_TEST_ASSERT(aSuite, scene == scene1); - NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric2, sceneId2, scene)); - NL_TEST_ASSERT(aSuite, scene == scene2); - NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric2, sceneId3, scene)); - NL_TEST_ASSERT(aSuite, scene == scene3); - - // Verify removing a Fabric Scene Data doesn't impact Fabric Group Data - NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->RemoveFabric(kFabric1)); - - // Scene Entry - NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric1, sceneId1, scene)); - NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric1, sceneId2, scene)); - NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric1, sceneId3, scene)); - - // Group Info - NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == provider->GetGroupInfoAt(kFabric2, 0, group)); - NL_TEST_ASSERT(aSuite, group == kGroupInfo1_3); - NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == provider->GetGroupInfoAt(kFabric2, 1, group)); - NL_TEST_ASSERT(aSuite, group == kGroupInfo1_1); - NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == provider->GetGroupInfoAt(kFabric2, 2, group)); - NL_TEST_ASSERT(aSuite, group == kGroupInfo1_2); - NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == provider->GetGroupInfoAt(kFabric1, 0, group)); - NL_TEST_ASSERT(aSuite, group == kGroupInfo1_1); - NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == provider->GetGroupInfoAt(kFabric1, 1, group)); - NL_TEST_ASSERT(aSuite, group == kGroupInfo1_2); - NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == provider->GetGroupInfoAt(kFabric1, 2, group)); - NL_TEST_ASSERT(aSuite, group == kGroupInfo1_3); - - NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == provider->RemoveFabric(kFabric1)); - - // Group Info - NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == provider->GetGroupInfoAt(kFabric1, 0, group)); - NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == provider->GetGroupInfoAt(kFabric1, 1, group)); - NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == provider->GetGroupInfoAt(kFabric1, 2, group)); - - // Verify removing a Fabric Group Data doesn't impact Fabric Scene Data - NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == provider->RemoveFabric(kFabric2)); - - // Group Info - NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == provider->GetGroupInfoAt(kFabric2, 0, group)); - NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == provider->GetGroupInfoAt(kFabric2, 1, group)); - NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == provider->GetGroupInfoAt(kFabric2, 2, group)); - - // Scene Entry - NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric2, sceneId1, scene)); - NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric2, sceneId2, scene)); - NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->GetSceneTableEntry(kFabric2, sceneId3, scene)); - - NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->RemoveFabric(kFabric2)); - - // Scene Entry - NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric2, sceneId1, scene)); - NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric2, sceneId2, scene)); - NL_TEST_ASSERT(aSuite, CHIP_ERROR_NOT_FOUND == sceneTable->GetSceneTableEntry(kFabric2, sceneId3, scene)); -} - } // namespace /** @@ -1064,17 +925,9 @@ void TestGroupScenesInteraction(nlTestSuite * aSuite, void * aContext) int TestSetup(void * inContext) { VerifyOrReturnError(CHIP_NO_ERROR == chip::Platform::MemoryInit(), FAILURE); - printf("1\n"); - // Initialize Group Data Provider - sProvider.SetStorageDelegate(&testStorage); - sProvider.SetSessionKeystore(&sSessionKeystore); - VerifyOrReturnError(CHIP_NO_ERROR == sProvider.Init(), FAILURE); - SetGroupDataProvider(&sProvider); - printf("2\n"); // Initialize Scene Table VerifyOrReturnError(CHIP_NO_ERROR == sSceneTable.Init(&testStorage), FAILURE); - printf("3\n"); return SUCCESS; } @@ -1085,11 +938,6 @@ int TestSetup(void * inContext) int TestTeardown(void * inContext) { sSceneTable.Finish(); - chip::Credentials::GroupDataProvider * provider = chip::Credentials::GetGroupDataProvider(); - if (nullptr != provider) - { - provider->Finish(); - } chip::Platform::MemoryShutdown(); return SUCCESS; @@ -1104,7 +952,6 @@ int TestSceneTable() NL_TEST_DEF("TestIterateScenes", TestIterateScenes), NL_TEST_DEF("TestRemoveScenes", TestRemoveScenes), NL_TEST_DEF("TestFabricScenes", TestFabricScenes), - NL_TEST_DEF("TestGroupScenesInteraction", TestGroupScenesInteraction), NL_TEST_SENTINEL() }; diff --git a/src/lib/core/CHIPConfig.h b/src/lib/core/CHIPConfig.h index 96de94294d1df4..ef1d5bd64a16b3 100644 --- a/src/lib/core/CHIPConfig.h +++ b/src/lib/core/CHIPConfig.h @@ -1393,6 +1393,13 @@ extern const char CHIP_NON_PRODUCTION_MARKER[]; #define CHIP_CONFIG_SCENES_MAX_CLUSTERS_PER_SCENE 3 #endif +/** + * @brief The maximum number of handlers used for extension field sets per scene. + */ +#ifndef CHIP_CONFIG_SCENES_MAX_SCENE_HANDLERS +#define CHIP_CONFIG_SCENES_MAX_SCENE_HANDLERS 3 +#endif + /** * @brief The maximum size of a single extension field set for a single cluster */