Skip to content

Commit

Permalink
Use IsServerMask on clusterr class
Browse files Browse the repository at this point in the history
  • Loading branch information
andy31415 committed Jun 10, 2024
1 parent d94cde3 commit 8ff725d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 18 deletions.
13 changes: 3 additions & 10 deletions src/app/codegen-interaction-model/CodegenDataModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,6 @@ namespace chip {
namespace app {
namespace {

/// Checks if the specified ember cluster mask corresponds to a valid
/// server cluster.
bool IsServerMask(EmberAfClusterMask mask)
{
return (mask == 0) || ((mask & CLUSTER_MASK_SERVER) != 0);
}

/// Load the cluster information into the specified destination
std::variant<CHIP_ERROR, InteractionModel::ClusterInfo> LoadClusterInfo(const ConcreteClusterPath & path,
const EmberAfCluster & cluster)
Expand Down Expand Up @@ -86,7 +79,7 @@ InteractionModel::ClusterEntry FirstServerClusterEntry(EndpointId endpointId, co
for (unsigned cluster_idx = start_index; cluster_idx < endpoint->clusterCount; cluster_idx++)
{
const EmberAfCluster & cluster = endpoint->cluster[cluster_idx];
if (!IsServerMask(cluster.mask))
if (!cluster.IsServerMask())
{
continue;
}
Expand Down Expand Up @@ -338,7 +331,7 @@ std::optional<unsigned> CodegenDataModel::TryFindServerClusterIndex(const EmberA
if (mClusterIterationHint < clusterCount)
{
const EmberAfCluster & cluster = endpoint->cluster[mClusterIterationHint];
if (IsServerMask(cluster.mask) && (cluster.clusterId == id))
if (cluster.IsServerMask() && (cluster.clusterId == id))
{
return std::make_optional(mClusterIterationHint);
}
Expand All @@ -350,7 +343,7 @@ std::optional<unsigned> CodegenDataModel::TryFindServerClusterIndex(const EmberA
for (unsigned cluster_idx = 0; cluster_idx < clusterCount; cluster_idx++)
{
const EmberAfCluster & cluster = endpoint->cluster[cluster_idx];
if (IsServerMask(cluster.mask) && (cluster.clusterId == id))
if (cluster.IsServerMask() && (cluster.clusterId == id))
{
return std::make_optional(cluster_idx);
}
Expand Down
11 changes: 3 additions & 8 deletions src/app/interaction-model/MetadataTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,10 @@ namespace chip {
namespace app {
namespace InteractionModel {

const AttributeEntry AttributeEntry::kInvalid
{
.path = ConcreteAttributePath(kInvalidEndpointId, kInvalidClusterId, kInvalidAttributeId)
};
const AttributeEntry AttributeEntry::kInvalid{ .path = ConcreteAttributePath(kInvalidEndpointId, kInvalidClusterId,
kInvalidAttributeId) };

const CommandEntry CommandEntry::kInvalid
{
.path = ConcreteCommandPath(kInvalidEndpointId, kInvalidClusterId, kInvalidCommandId)
};
const CommandEntry CommandEntry::kInvalid{ .path = ConcreteCommandPath(kInvalidEndpointId, kInvalidClusterId, kInvalidCommandId) };

const ClusterEntry ClusterEntry::kInvalid{
.path = ConcreteClusterPath(kInvalidEndpointId, kInvalidClusterId),
Expand Down
3 changes: 3 additions & 0 deletions src/app/util/af-types.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
* @{
*/

#include "att-storage.h"
#include <stdbool.h> // For bool
#include <stdint.h> // For various uint*_t types

Expand Down Expand Up @@ -116,6 +117,8 @@ typedef struct
* Total number of events supported by the cluster instance (in eventList array).
*/
uint16_t eventCount;

bool IsServerMask() const { return (mask & CLUSTER_MASK_SERVER) != 0; }
} EmberAfCluster;

/**
Expand Down

0 comments on commit 8ff725d

Please sign in to comment.