From 1525936d7b70c8d07f776d316b9673011a13be8f Mon Sep 17 00:00:00 2001 From: lpbeliveau-silabs Date: Mon, 23 Jan 2023 17:31:50 -0500 Subject: [PATCH] Modified naming convention related issues and others --- scripts/examples/gn_efr32_example.sh | 1 - .../clusters/scenes/ExtensionFieldsSets.cpp | 13 ++-- src/app/clusters/scenes/ExtensionFieldsSets.h | 17 ++--- src/app/clusters/scenes/SceneTable.h | 15 +++-- src/app/clusters/scenes/SceneTableImpl.cpp | 63 +++++++++---------- src/app/clusters/scenes/SceneTableImpl.h | 32 ++++------ src/lib/core/CHIPConfig.h | 56 +++++++++++++++-- src/lib/core/DataModelTypes.h | 8 ++- src/lib/support/DefaultStorageKeyAllocator.h | 3 - 9 files changed, 126 insertions(+), 82 deletions(-) diff --git a/scripts/examples/gn_efr32_example.sh b/scripts/examples/gn_efr32_example.sh index c519d0f9a837ea..c7a0681764083a 100755 --- a/scripts/examples/gn_efr32_example.sh +++ b/scripts/examples/gn_efr32_example.sh @@ -144,7 +144,6 @@ else shift while [ $# -gt 0 ]; do case $1 in - --clean) DIR_CLEAN=true shift diff --git a/src/app/clusters/scenes/ExtensionFieldsSets.cpp b/src/app/clusters/scenes/ExtensionFieldsSets.cpp index fd2c5433025d16..2b25d9a3253042 100644 --- a/src/app/clusters/scenes/ExtensionFieldsSets.cpp +++ b/src/app/clusters/scenes/ExtensionFieldsSets.cpp @@ -23,7 +23,7 @@ namespace scenes { ExtensionFieldsSets::ExtensionFieldsSets() { // check if any of the clusters with scene attributes are enabled - if (this->kExentesionFieldsSetsSize == 1) + if (this->kExtensionFieldsSetsSize == 1) { // a size of 1 byte indicates an empty struct, or a struct that only contains : // the on-off cluster @@ -40,9 +40,9 @@ ExtensionFieldsSets::ExtensionFieldsSets() this->empty = true; #endif } - else if (this->kExentesionFieldsSetsSize > 1) + else if (this->kExtensionFieldsSetsSize > 1) { - memset(&this->enabledFieldSets, 0, kExentesionFieldsSetsSize); + memset(&this->enabledFieldSets, 0, kExtensionFieldsSetsSize); } } @@ -53,8 +53,7 @@ CHIP_ERROR ExtensionFieldsSets::Serialize(TLV::TLVWriter & writer) const TLV::TLVType container; ReturnErrorOnFailure(writer.StartContainer(TLV::ContextTag(1), TLV::kTLVType_Structure, container)); - ReturnErrorOnFailure( - writer.PutBytes(TagEnabledFielsSets(), (uint8_t *) &this->enabledFieldSets, kExentesionFieldsSetsSize)); + ReturnErrorOnFailure(writer.PutBytes(TagEnabledFielsSets(), (uint8_t *) &this->enabledFieldSets, kExtensionFieldsSetsSize)); return writer.EndContainer(container); } @@ -73,7 +72,7 @@ CHIP_ERROR ExtensionFieldsSets::Deserialize(TLV::TLVReader & reader) ReturnErrorOnFailure(reader.EnterContainer(container)); ReturnErrorOnFailure(reader.Next(TagEnabledFielsSets())); - ReturnErrorOnFailure(reader.GetBytes((uint8_t *) &this->enabledFieldSets, kExentesionFieldsSetsSize)); + ReturnErrorOnFailure(reader.GetBytes((uint8_t *) &this->enabledFieldSets, kExtensionFieldsSetsSize)); return reader.ExitContainer(container); } @@ -82,7 +81,7 @@ CHIP_ERROR ExtensionFieldsSets::Deserialize(TLV::TLVReader & reader) return CHIP_NO_ERROR; } } -void ExtensionFieldsSets::clear() +void ExtensionFieldsSets::Clear() { if (!this->empty) { diff --git a/src/app/clusters/scenes/ExtensionFieldsSets.h b/src/app/clusters/scenes/ExtensionFieldsSets.h index cae1d41499ce5a..ca1e080aa9dbf4 100644 --- a/src/app/clusters/scenes/ExtensionFieldsSets.h +++ b/src/app/clusters/scenes/ExtensionFieldsSets.h @@ -25,8 +25,9 @@ namespace chip { namespace scenes { -typedef struct fieldSets_s +typedef struct { + #ifdef ZCL_USING_ON_OFF_CLUSTER_SERVER bool onOff; #endif @@ -68,32 +69,32 @@ typedef struct fieldSets_s uint8_t targetPositionLiftPercent100ths; uint8_t targetPositionTiltPercent100ths; #endif -} fieldSets_t; +} FieldSets; class ExtensionFieldsSets { public: - static constexpr size_t kExentesionFieldsSetsSize = sizeof(fieldSets_t); + static constexpr size_t kExtensionFieldsSetsSize = sizeof(FieldSets); static constexpr TLV::Tag TagEnabledFielsSets() { return TLV::ContextTag(1); } - fieldSets_t enabledFieldSets; + FieldSets enabledFieldSets; bool empty = false; ExtensionFieldsSets(); - virtual ~ExtensionFieldsSets() = default; + ~ExtensionFieldsSets(){}; CHIP_ERROR Serialize(TLV::TLVWriter & writer) const; CHIP_ERROR Deserialize(TLV::TLVReader & reader); - void clear(); + void Clear(); bool operator==(const ExtensionFieldsSets & other) { - return (!memcmp(&this->enabledFieldSets, &other.enabledFieldSets, kExentesionFieldsSetsSize)); + return (!memcmp(&this->enabledFieldSets, &other.enabledFieldSets, kExtensionFieldsSetsSize)); } void operator=(const ExtensionFieldsSets & other) { - memcpy(&this->enabledFieldSets, &other.enabledFieldSets, kExentesionFieldsSetsSize); + memcpy(&this->enabledFieldSets, &other.enabledFieldSets, kExtensionFieldsSetsSize); } }; } // namespace scenes diff --git a/src/app/clusters/scenes/SceneTable.h b/src/app/clusters/scenes/SceneTable.h index 9bbdd415d21d11..baaa41e9f1dae8 100644 --- a/src/app/clusters/scenes/SceneTable.h +++ b/src/app/clusters/scenes/SceneTable.h @@ -24,12 +24,15 @@ namespace chip { namespace scenes { +typedef uint16_t SceneTransitionTime; +typedef uint8_t TransitionTime100ms; + class SceneTable { public: static constexpr size_t kIteratorsMax = CHIP_CONFIG_MAX_GROUP_CONCURRENT_ITERATORS; - static constexpr size_t kSceneNameMax = ZCL_SCENES_CLUSTER_MAXIMUM_NAME_LENGTH; - static constexpr uint8_t kMaxScenePerFabric = SCENE_MAX_PER_FABRIC; + static constexpr size_t kSceneNameMax = CHIP_CONFIG_SCENES_CLUSTER_MAXIMUM_NAME_LENGTH; + static constexpr uint8_t kMaxScenePerFabric = CHIP_CONFIG_SCENES_MAX_PER_FABRIC; /// @brief struct used to identify a scene in storage by 3 ids, endpoint, group and scene struct SceneStorageId { @@ -77,7 +80,7 @@ class SceneTable return reader.ExitContainer(container); } - void clear() + void Clear() { sceneEndpointId = kInvalidEndpointId; sceneGroupId = kGlobalGroupSceneId; @@ -171,12 +174,12 @@ class SceneTable } } - void clear() + void Clear() { this->SetName(nullptr); sceneTransitionTime = 0; transitionTime100 = 0; - extentsionFieldsSets.clear(); + extentsionFieldsSets.Clear(); } bool operator==(const SceneData & other) @@ -223,7 +226,7 @@ class SceneTable virtual ~SceneTable() = default; // Not copyable - SceneTable(const SceneTable &) = delete; + SceneTable(const SceneTable &) = delete; SceneTable & operator=(const SceneTable &) = delete; virtual CHIP_ERROR Init() = 0; diff --git a/src/app/clusters/scenes/SceneTableImpl.cpp b/src/app/clusters/scenes/SceneTableImpl.cpp index 4178a713bcd5ba..552efb232fc1ba 100644 --- a/src/app/clusters/scenes/SceneTableImpl.cpp +++ b/src/app/clusters/scenes/SceneTableImpl.cpp @@ -23,11 +23,11 @@ namespace chip { namespace scenes { -using SceneTableEntry = SceneTableImpl::SceneTableEntry; -using SceneStorageId = SceneTableImpl::SceneStorageId; -using SceneData = SceneTableImpl::SceneData; +using SceneTableEntry = DefaultSceneTableImpl::SceneTableEntry; +using SceneStorageId = DefaultSceneTableImpl::SceneStorageId; +using SceneData = DefaultSceneTableImpl::SceneData; -struct FabricList : public CommonPersistentData::FabricList +struct FabricHavingSceneList : public CommonPersistentData::FabricList { CHIP_ERROR UpdateKey(StorageKeyName & key) override { @@ -50,7 +50,7 @@ struct FabricSceneData : public PersistentData static constexpr TLV::Tag TagNext() { return TLV::ContextTag(2); } chip::FabricIndex fabric_index = kUndefinedFabricIndex; - SceneTableImpl::SceneStorageId first_scene; + DefaultSceneTableImpl::SceneStorageId first_scene; uint16_t scene_count = 0; FabricIndex next = kUndefinedFabricIndex; @@ -66,7 +66,7 @@ struct FabricSceneData : public PersistentData void Clear() override { - first_scene.clear(); + first_scene.Clear(); scene_count = 0; next = kUndefinedFabricIndex; } @@ -100,10 +100,10 @@ struct FabricSceneData : public PersistentData return reader.ExitContainer(container); } - // Register the fabric in the fabrics' linked-list + // Register the fabric in the list of fabrics having scenes CHIP_ERROR Register(PersistentStorageDelegate * storage) { - FabricList fabric_list; + FabricHavingSceneList fabric_list; CHIP_ERROR err = fabric_list.Load(storage); if (CHIP_ERROR_NOT_FOUND == err) { @@ -140,7 +140,7 @@ struct FabricSceneData : public PersistentData // Remove the fabric from the fabrics' linked list CHIP_ERROR Unregister(PersistentStorageDelegate * storage) const { - FabricList fabric_list; + FabricHavingSceneList fabric_list; CHIP_ERROR err = fabric_list.Load(storage); VerifyOrReturnError(CHIP_NO_ERROR == err || CHIP_ERROR_NOT_FOUND == err, err); @@ -183,7 +183,7 @@ struct FabricSceneData : public PersistentData // Check the fabric is registered in the fabrics' linked list CHIP_ERROR Validate(PersistentStorageDelegate * storage) const { - FabricList fabric_list; + FabricHavingSceneList fabric_list; ReturnErrorOnFailure(fabric_list.Load(storage)); // Existing fabric list, search for existing entry @@ -240,8 +240,8 @@ struct SceneTableData : public SceneTableEntry, PersistentData mSceneEntryIterators; const uint8_t mMaxScenePerFabric = kMaxScenePerFabric; -}; // class SceneTableImpl +}; // class DefaultSceneTableImpl /** * Instance getter for the global SceneTable. @@ -93,7 +87,7 @@ class SceneTableImpl : public SceneTable * * @return The global Scene Table */ -SceneTableImpl * GetSceneTable(); +DefaultSceneTableImpl * GetSceneTable(); /** * Instance setter for the global Scene Table. @@ -104,6 +98,6 @@ SceneTableImpl * GetSceneTable(); * * @param[in] provider pointer to the Scene Table global isntance to use */ -void SetSceneTable(SceneTableImpl * provider); +void SetSceneTable(DefaultSceneTableImpl * provider); } // namespace scenes } // namespace chip diff --git a/src/lib/core/CHIPConfig.h b/src/lib/core/CHIPConfig.h index c66d7f2974d5a6..e951b485e753ef 100644 --- a/src/lib/core/CHIPConfig.h +++ b/src/lib/core/CHIPConfig.h @@ -1354,10 +1354,6 @@ extern const char CHIP_NON_PRODUCTION_MARKER[]; #define CHIP_CONFIG_MAX_CLIENT_REG_PER_FABRIC 1 #endif // CHIP_CONFIG_MAX_CLIENT_REG_PER_FABRIC -/** - * @} - */ - /** * @def CHIP_CONFIG_MAX_SUBSCRIPTION_RESUMPTION_STORAGE_CONCURRENT_ITERATORS * @@ -1368,3 +1364,55 @@ extern const char CHIP_NON_PRODUCTION_MARKER[]; #ifndef CHIP_CONFIG_MAX_SUBSCRIPTION_RESUMPTION_STORAGE_CONCURRENT_ITERATORS #define CHIP_CONFIG_MAX_SUBSCRIPTION_RESUMPTION_STORAGE_CONCURRENT_ITERATORS 2 #endif +/** + * @brief Indicates the absence of a Scene table entry. + */ +#ifndef CHIP_CONFIG_SCENES_TABLE_NULL_INDEX +#define CHIP_CONFIG_SCENES_TABLE_NULL_INDEX 0xFF +#endif + +/** + * @brief Value used when setting or getting the endpoint in a Scene table + * entry. It indicates that the entry is not in use. + */ +#ifndef CHIP_CONFIG_SCENES_TABLE_UNUSED_ENDPOINT_ID +#define CHIP_CONFIG_SCENES_TABLE_UNUSED_ENDPOINT_ID 0x00 +#endif +/** + * @brief The maximum number of scenes according to spec + */ +#ifndef CHIP_CONFIG_SCENES_MAX_NUMBER +#define CHIP_CONFIG_SCENES_MAX_NUMBER 16 +#endif + +/** + * @brief Maximum length of Scene names, not including the length byte. + */ +#ifndef CHIP_CONFIG_SCENES_CLUSTER_MAXIMUM_NAME_LENGTH +#define CHIP_CONFIG_SCENES_CLUSTER_MAXIMUM_NAME_LENGTH 16 +#endif + +/** + * @brief The group identifier for the global scene. + */ +#ifndef CHIP_CONFIG_SCENES_GLOBAL_SCENE_GROUP_ID +#define CHIP_CONFIG_SCENES_GLOBAL_SCENE_GROUP_ID 0x0000 +#endif + +/** + * @brief The scene identifier for the global scene. + */ +#ifndef CHIP_CONFIG_SCENES_GLOBAL_SCENE_SCENE_ID +#define CHIP_CONFIG_SCENES_GLOBAL_SCENE_SCENE_ID 0x00 +#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_SCENES_MAX_NUMBER / 2) +#endif + +/** + * @} + */ diff --git a/src/lib/core/DataModelTypes.h b/src/lib/core/DataModelTypes.h index 308b679057778e..5bfbec2f3b6131 100644 --- a/src/lib/core/DataModelTypes.h +++ b/src/lib/core/DataModelTypes.h @@ -19,11 +19,11 @@ #include +#include #include // For VendorId #include #include #include -#include namespace chip { @@ -47,6 +47,8 @@ typedef uint32_t TransactionId; typedef uint16_t KeysetId; typedef uint8_t InteractionModelRevision; typedef uint32_t SubscriptionId; +typedef GroupId SceneGroupID; +typedef uint8_t SceneId; constexpr CompressedFabricId kUndefinedCompressedFabricId = 0ULL; constexpr FabricId kUndefinedFabricId = 0ULL; @@ -60,6 +62,10 @@ constexpr EndpointId kRootEndpointId = 0; constexpr ListIndex kInvalidListIndex = 0xFFFF; // List index is a uint16 thus 0xFFFF is a invalid list index. constexpr KeysetId kInvalidKeysetId = 0xFFFF; +constexpr SceneGroupID kGlobalGroupSceneId = CHIP_CONFIG_SCENES_GLOBAL_SCENE_GROUP_ID; +constexpr SceneId kUndefinedSceneId = CHIP_CONFIG_SCENES_TABLE_NULL_INDEX; +constexpr SceneId kUnusedEndpointId = CHIP_CONFIG_SCENES_TABLE_UNUSED_ENDPOINT_ID; + // Invalid IC identifier is provisional. Value will most likely change when identifying token is defined // https://github.com/project-chip/connectedhomeip/issues/24251 constexpr uint64_t kInvalidIcId = 0; diff --git a/src/lib/support/DefaultStorageKeyAllocator.h b/src/lib/support/DefaultStorageKeyAllocator.h index a534632a5be064..aa78b876547683 100644 --- a/src/lib/support/DefaultStorageKeyAllocator.h +++ b/src/lib/support/DefaultStorageKeyAllocator.h @@ -191,14 +191,12 @@ class DefaultStorageKeyAllocator // Event number counter. static StorageKeyName IMEventNumber() { return StorageKeyName::FromConst("g/im/ec"); } -<<<<<<< HEAD // Subscription resumption static StorageKeyName SubscriptionResumption(size_t index) { return StorageKeyName::Formatted("g/su/%x", static_cast(index)); } static StorageKeyName SubscriptionResumptionMaxCount() { return StorageKeyName::Formatted("g/sum"); } -======= // Scene Storage static StorageKeyName SceneFabricList() { return StorageKeyName::FromConst("g/sfl"); } static StorageKeyName FabricScenesKey(chip::FabricIndex fabric) { return StorageKeyName::Formatted("f/%x/s", fabric); } @@ -207,7 +205,6 @@ class DefaultStorageKeyAllocator { return StorageKeyName::Formatted("f/%x/s/e%xg%xs%x", fabric, endpoint, group, scene); } ->>>>>>> 47da6c11b4 (Implementation of persistant storage of scene table along with test.) }; } // namespace chip