Skip to content

Commit

Permalink
Modified naming convention related issues and others
Browse files Browse the repository at this point in the history
  • Loading branch information
lpbeliveau-silabs authored and pull[bot] committed Nov 23, 2023
1 parent 56ec2e8 commit 1525936
Show file tree
Hide file tree
Showing 9 changed files with 126 additions and 82 deletions.
1 change: 0 additions & 1 deletion scripts/examples/gn_efr32_example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ else
shift
while [ $# -gt 0 ]; do
case $1 in

--clean)
DIR_CLEAN=true
shift
Expand Down
13 changes: 6 additions & 7 deletions src/app/clusters/scenes/ExtensionFieldsSets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}
}

Expand All @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -82,7 +81,7 @@ CHIP_ERROR ExtensionFieldsSets::Deserialize(TLV::TLVReader & reader)
return CHIP_NO_ERROR;
}
}
void ExtensionFieldsSets::clear()
void ExtensionFieldsSets::Clear()
{
if (!this->empty)
{
Expand Down
17 changes: 9 additions & 8 deletions src/app/clusters/scenes/ExtensionFieldsSets.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@
namespace chip {
namespace scenes {

typedef struct fieldSets_s
typedef struct
{

#ifdef ZCL_USING_ON_OFF_CLUSTER_SERVER
bool onOff;
#endif
Expand Down Expand Up @@ -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
Expand Down
15 changes: 9 additions & 6 deletions src/app/clusters/scenes/SceneTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -77,7 +80,7 @@ class SceneTable
return reader.ExitContainer(container);
}

void clear()
void Clear()
{
sceneEndpointId = kInvalidEndpointId;
sceneGroupId = kGlobalGroupSceneId;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down
63 changes: 30 additions & 33 deletions src/app/clusters/scenes/SceneTableImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -50,7 +50,7 @@ struct FabricSceneData : public PersistentData<kPersistentBufferMax>
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;

Expand All @@ -66,7 +66,7 @@ struct FabricSceneData : public PersistentData<kPersistentBufferMax>

void Clear() override
{
first_scene.clear();
first_scene.Clear();
scene_count = 0;
next = kUndefinedFabricIndex;
}
Expand Down Expand Up @@ -100,10 +100,10 @@ struct FabricSceneData : public PersistentData<kPersistentBufferMax>
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)
{
Expand Down Expand Up @@ -140,7 +140,7 @@ struct FabricSceneData : public PersistentData<kPersistentBufferMax>
// 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);

Expand Down Expand Up @@ -183,7 +183,7 @@ struct FabricSceneData : public PersistentData<kPersistentBufferMax>
// 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
Expand Down Expand Up @@ -240,8 +240,8 @@ struct SceneTableData : public SceneTableEntry, PersistentData<kPersistentBuffer

void Clear() override
{
storageData.clear();
next.clear();
storageData.Clear();
next.Clear();
}

CHIP_ERROR Serialize(TLV::TLVWriter & writer) const override
Expand Down Expand Up @@ -271,7 +271,8 @@ struct SceneTableData : public SceneTableEntry, PersistentData<kPersistentBuffer
return reader.ExitContainer(container);
}

bool Find(PersistentStorageDelegate * storage, const FabricSceneData & fabric, SceneTableImpl::SceneStorageId target_scene)
bool Find(PersistentStorageDelegate * storage, const FabricSceneData & fabric,
DefaultSceneTableImpl::SceneStorageId target_scene)
{
fabric_index = fabric.fabric_index;
storageId = fabric.first_scene;
Expand All @@ -298,27 +299,23 @@ struct SceneTableData : public SceneTableEntry, PersistentData<kPersistentBuffer
}
};

void SceneTableImpl::SetStorageDelegate(PersistentStorageDelegate * storage)
CHIP_ERROR DefaultSceneTableImpl::Init(PersistentStorageDelegate * storage)
{
VerifyOrDie(storage != nullptr);
mStorage = storage;
}

CHIP_ERROR SceneTableImpl::Init()
{
if (mStorage == nullptr)
if (storage == nullptr)
{
return CHIP_ERROR_INCORRECT_STATE;
}

mStorage = storage;
return CHIP_NO_ERROR;
}

void SceneTableImpl::Finish()
void DefaultSceneTableImpl::Finish()
{
mSceneEntryIterators.ReleaseAll();
}

CHIP_ERROR SceneTableImpl::SetSceneTableEntry(FabricIndex fabric_index, const SceneTableEntry & entry)
CHIP_ERROR DefaultSceneTableImpl::SetSceneTableEntry(FabricIndex fabric_index, const SceneTableEntry & entry)
{
VerifyOrReturnError(IsInitialized(), CHIP_ERROR_INTERNAL);

Expand Down Expand Up @@ -359,7 +356,7 @@ CHIP_ERROR SceneTableImpl::SetSceneTableEntry(FabricIndex fabric_index, const Sc

return scene.Save(mStorage);
}
CHIP_ERROR SceneTableImpl::GetSceneTableEntry(FabricIndex fabric_index, SceneStorageId scene_id, SceneTableEntry & entry)
CHIP_ERROR DefaultSceneTableImpl::GetSceneTableEntry(FabricIndex fabric_index, SceneStorageId scene_id, SceneTableEntry & entry)
{
FabricSceneData fabric(fabric_index);
SceneTableData scene;
Expand All @@ -371,7 +368,7 @@ CHIP_ERROR SceneTableImpl::GetSceneTableEntry(FabricIndex fabric_index, SceneSto
entry.storageData = scene.storageData;
return CHIP_NO_ERROR;
}
CHIP_ERROR SceneTableImpl::RemoveSceneTableEntry(FabricIndex fabric_index, SceneStorageId scene_id)
CHIP_ERROR DefaultSceneTableImpl::RemoveSceneTableEntry(FabricIndex fabric_index, SceneStorageId scene_id)
{
FabricSceneData fabric(fabric_index);
SceneTableData scene;
Expand Down Expand Up @@ -404,13 +401,13 @@ CHIP_ERROR SceneTableImpl::RemoveSceneTableEntry(FabricIndex fabric_index, Scene
return CHIP_NO_ERROR;
}

SceneTableImpl::SceneEntryIterator * SceneTableImpl::IterateSceneEntry(FabricIndex fabric_index)
DefaultSceneTableImpl::SceneEntryIterator * DefaultSceneTableImpl::IterateSceneEntry(FabricIndex fabric_index)
{
VerifyOrReturnError(IsInitialized(), nullptr);
return mSceneEntryIterators.CreateObject(*this, fabric_index);
}

SceneTableImpl::SceneEntryIteratorImpl::SceneEntryIteratorImpl(SceneTableImpl & provider, FabricIndex fabric_index) :
DefaultSceneTableImpl::SceneEntryIteratorImpl::SceneEntryIteratorImpl(DefaultSceneTableImpl & provider, FabricIndex fabric_index) :
mProvider(provider), mFabric(fabric_index)
{
FabricSceneData fabric(fabric_index);
Expand All @@ -423,12 +420,12 @@ SceneTableImpl::SceneEntryIteratorImpl::SceneEntryIteratorImpl(SceneTableImpl &
}
}

size_t SceneTableImpl::SceneEntryIteratorImpl::Count()
size_t DefaultSceneTableImpl::SceneEntryIteratorImpl::Count()
{
return mTotalScene;
}

bool SceneTableImpl::SceneEntryIteratorImpl::Next(SceneTableEntry & output)
bool DefaultSceneTableImpl::SceneEntryIteratorImpl::Next(SceneTableEntry & output)
{
VerifyOrReturnError(mSceneCount < mTotalScene, false);

Expand All @@ -442,23 +439,23 @@ bool SceneTableImpl::SceneEntryIteratorImpl::Next(SceneTableEntry & output)
return true;
}

void SceneTableImpl::SceneEntryIteratorImpl::Release()
void DefaultSceneTableImpl::SceneEntryIteratorImpl::Release()
{
mProvider.mSceneEntryIterators.ReleaseObject(this);
}

namespace {

SceneTableImpl * gSceneTable = nullptr;
DefaultSceneTableImpl * gSceneTable = nullptr;

} // namespace

SceneTableImpl * GetSceneTable()
DefaultSceneTableImpl * GetSceneTable()
{
return gSceneTable;
}

void SetSceneTable(SceneTableImpl * provider)
void SetSceneTable(DefaultSceneTableImpl * provider)
{
gSceneTable = provider;
}
Expand Down
Loading

0 comments on commit 1525936

Please sign in to comment.