Skip to content

Commit 8ff725d

Browse files
committed
Use IsServerMask on clusterr class
1 parent d94cde3 commit 8ff725d

File tree

3 files changed

+9
-18
lines changed

3 files changed

+9
-18
lines changed

src/app/codegen-interaction-model/CodegenDataModel.cpp

+3-10
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,6 @@ namespace chip {
2929
namespace app {
3030
namespace {
3131

32-
/// Checks if the specified ember cluster mask corresponds to a valid
33-
/// server cluster.
34-
bool IsServerMask(EmberAfClusterMask mask)
35-
{
36-
return (mask == 0) || ((mask & CLUSTER_MASK_SERVER) != 0);
37-
}
38-
3932
/// Load the cluster information into the specified destination
4033
std::variant<CHIP_ERROR, InteractionModel::ClusterInfo> LoadClusterInfo(const ConcreteClusterPath & path,
4134
const EmberAfCluster & cluster)
@@ -86,7 +79,7 @@ InteractionModel::ClusterEntry FirstServerClusterEntry(EndpointId endpointId, co
8679
for (unsigned cluster_idx = start_index; cluster_idx < endpoint->clusterCount; cluster_idx++)
8780
{
8881
const EmberAfCluster & cluster = endpoint->cluster[cluster_idx];
89-
if (!IsServerMask(cluster.mask))
82+
if (!cluster.IsServerMask())
9083
{
9184
continue;
9285
}
@@ -338,7 +331,7 @@ std::optional<unsigned> CodegenDataModel::TryFindServerClusterIndex(const EmberA
338331
if (mClusterIterationHint < clusterCount)
339332
{
340333
const EmberAfCluster & cluster = endpoint->cluster[mClusterIterationHint];
341-
if (IsServerMask(cluster.mask) && (cluster.clusterId == id))
334+
if (cluster.IsServerMask() && (cluster.clusterId == id))
342335
{
343336
return std::make_optional(mClusterIterationHint);
344337
}
@@ -350,7 +343,7 @@ std::optional<unsigned> CodegenDataModel::TryFindServerClusterIndex(const EmberA
350343
for (unsigned cluster_idx = 0; cluster_idx < clusterCount; cluster_idx++)
351344
{
352345
const EmberAfCluster & cluster = endpoint->cluster[cluster_idx];
353-
if (IsServerMask(cluster.mask) && (cluster.clusterId == id))
346+
if (cluster.IsServerMask() && (cluster.clusterId == id))
354347
{
355348
return std::make_optional(cluster_idx);
356349
}

src/app/interaction-model/MetadataTypes.cpp

+3-8
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,10 @@ namespace chip {
2020
namespace app {
2121
namespace InteractionModel {
2222

23-
const AttributeEntry AttributeEntry::kInvalid
24-
{
25-
.path = ConcreteAttributePath(kInvalidEndpointId, kInvalidClusterId, kInvalidAttributeId)
26-
};
23+
const AttributeEntry AttributeEntry::kInvalid{ .path = ConcreteAttributePath(kInvalidEndpointId, kInvalidClusterId,
24+
kInvalidAttributeId) };
2725

28-
const CommandEntry CommandEntry::kInvalid
29-
{
30-
.path = ConcreteCommandPath(kInvalidEndpointId, kInvalidClusterId, kInvalidCommandId)
31-
};
26+
const CommandEntry CommandEntry::kInvalid{ .path = ConcreteCommandPath(kInvalidEndpointId, kInvalidClusterId, kInvalidCommandId) };
3227

3328
const ClusterEntry ClusterEntry::kInvalid{
3429
.path = ConcreteClusterPath(kInvalidEndpointId, kInvalidClusterId),

src/app/util/af-types.h

+3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
* @{
2424
*/
2525

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

@@ -116,6 +117,8 @@ typedef struct
116117
* Total number of events supported by the cluster instance (in eventList array).
117118
*/
118119
uint16_t eventCount;
120+
121+
bool IsServerMask() const { return (mask & CLUSTER_MASK_SERVER) != 0; }
119122
} EmberAfCluster;
120123

121124
/**

0 commit comments

Comments
 (0)