Skip to content

Commit

Permalink
Reduce type character size of SceneTableImpl types
Browse files Browse the repository at this point in the history
  • Loading branch information
mpbreton committed Aug 1, 2023
1 parent ed545c4 commit 43234a7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
17 changes: 8 additions & 9 deletions src/app/clusters/scenes-server/SceneTableImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ namespace chip {
namespace scenes {

CHIP_ERROR
DefaultSceneHandlerImpl::EncodeAttributeValueList(
const app::DataModel::List<app::Clusters::Scenes::Structs::AttributeValuePair::Type> & aVlist,
MutableByteSpan & serializedBytes)
DefaultSceneHandlerImpl::EncodeAttributeValueList(const app::DataModel::List<AttributeValuePair::Type> & aVlist,
MutableByteSpan & serializedBytes)
{
TLV::TLVWriter writer;
writer.Init(serializedBytes);
Expand All @@ -35,9 +34,9 @@ DefaultSceneHandlerImpl::EncodeAttributeValueList(
return CHIP_NO_ERROR;
}

CHIP_ERROR DefaultSceneHandlerImpl::DecodeAttributeValueList(
const ByteSpan & serializedBytes,
app::DataModel::DecodableList<app::Clusters::Scenes::Structs::AttributeValuePair::DecodableType> & aVlist)
CHIP_ERROR
DefaultSceneHandlerImpl::DecodeAttributeValueList(const ByteSpan & serializedBytes,
app::DataModel::DecodableList<AttributeValuePair::DecodableType> & aVlist)
{
TLV::TLVReader reader;

Expand All @@ -53,7 +52,7 @@ DefaultSceneHandlerImpl::SerializeAdd(EndpointId endpoint,
const app::Clusters::Scenes::Structs::ExtensionFieldSet::DecodableType & extensionFieldSet,
MutableByteSpan & serializedBytes)
{
app::Clusters::Scenes::Structs::AttributeValuePair::Type aVPairs[kMaxAvPair];
AttributeValuePair::Type aVPairs[kMaxAvPair];

size_t pairTotal = 0;
// Verify size of list
Expand All @@ -68,15 +67,15 @@ DefaultSceneHandlerImpl::SerializeAdd(EndpointId endpoint,
pairCount++;
}
ReturnErrorOnFailure(pair_iterator.GetStatus());
app::DataModel::List<app::Clusters::Scenes::Structs::AttributeValuePair::Type> attributeValueList(aVPairs, pairCount);
app::DataModel::List<AttributeValuePair::Type> attributeValueList(aVPairs, pairCount);

return EncodeAttributeValueList(attributeValueList, serializedBytes);
}

CHIP_ERROR DefaultSceneHandlerImpl::Deserialize(EndpointId endpoint, ClusterId cluster, const ByteSpan & serializedBytes,
app::Clusters::Scenes::Structs::ExtensionFieldSet::Type & extensionFieldSet)
{
app::DataModel::DecodableList<app::Clusters::Scenes::Structs::AttributeValuePair::DecodableType> attributeValueList;
app::DataModel::DecodableList<AttributeValuePair::DecodableType> attributeValueList;

ReturnErrorOnFailure(DecodeAttributeValueList(serializedBytes, attributeValueList));

Expand Down
13 changes: 6 additions & 7 deletions src/app/clusters/scenes-server/SceneTableImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ static constexpr uint16_t kMaxScenesPerFabric = CHIP_CONFIG_SCENES_MAX_PER_FAB
static constexpr uint16_t kMaxScenesPerEndpoint = CHIP_CONFIG_MAX_SCENES_PER_ENDPOINT;

using clusterId = chip::ClusterId;
using namespace app::Clusters::Scenes::Structs;

/// @brief Default implementation of handler, handle EFS from add scene and view scene commands for any cluster
/// The implementation of SerializeSave and ApplyScene were omitted and must be implemented in a way that
Expand All @@ -49,18 +50,16 @@ class DefaultSceneHandlerImpl : public scenes::SceneHandler
/// @param aVlist[in] Attribute value list to encode
/// @param serializedBytes[out] Buffer to fill from the Attribute value list in a TLV format
/// @return CHIP_ERROR
virtual CHIP_ERROR
EncodeAttributeValueList(const app::DataModel::List<app::Clusters::Scenes::Structs::AttributeValuePair::Type> & aVlist,
MutableByteSpan & serializedBytes);
virtual CHIP_ERROR EncodeAttributeValueList(const app::DataModel::List<AttributeValuePair::Type> & aVlist,
MutableByteSpan & serializedBytes);

/// @brief Decodes an attribute value list from a TLV structure and ensure it fits the member pair buffer
/// @param serializedBytes [in] Buffer to read from
/// @param aVlist [out] Attribute value list to fill from the TLV structure. Only valid while the buffer backing
/// serializedBytes exists and its contents are not modified.
/// @return CHIP_ERROR
virtual CHIP_ERROR DecodeAttributeValueList(
const ByteSpan & serializedBytes,
app::DataModel::DecodableList<app::Clusters::Scenes::Structs::AttributeValuePair::DecodableType> & aVlist);
virtual CHIP_ERROR DecodeAttributeValueList(const ByteSpan & serializedBytes,
app::DataModel::DecodableList<AttributeValuePair::DecodableType> & aVlist);

/// @brief From command AddScene, allows handler to filter through clusters in command to serialize only the supported ones.
/// @param endpoint[in] Endpoint ID
Expand All @@ -82,7 +81,7 @@ class DefaultSceneHandlerImpl : public scenes::SceneHandler
app::Clusters::Scenes::Structs::ExtensionFieldSet::Type & extensionFieldSet) override;

private:
app::Clusters::Scenes::Structs::AttributeValuePair::Type mAVPairs[kMaxAvPair];
AttributeValuePair::Type mAVPairs[kMaxAvPair];
};

/**
Expand Down

0 comments on commit 43234a7

Please sign in to comment.