Skip to content

Commit 41fe827

Browse files
committed
Introduce ClusterId_t and AttributeId_t
1 parent 4901e06 commit 41fe827

File tree

4 files changed

+23
-19
lines changed

4 files changed

+23
-19
lines changed

src/lib/datamodel/Attribute.h

+7-4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
namespace chip {
3333
namespace DataModel {
3434

35+
typedef uint16_t AttributeId_t;
3536
/**
3637
* @brief
3738
* This class implements a single attribute.
@@ -43,14 +44,16 @@ class Attribute
4344
friend class Cluster;
4445

4546
public:
46-
uint16_t mAttrId;
47+
AttributeId_t mAttrId;
4748
Value mValue;
4849
Value mMin;
4950
Value mMax;
5051

51-
Attribute(uint16_t attrId, ValueTypes type) : mDeque(this), mAttrId(attrId), mValue(type), mMin(type), mMax(type) {}
52-
Attribute(uint16_t attrId, Value value) : mDeque(this), mAttrId(attrId), mValue(value), mMin(value.mType), mMax(value.mType) {}
53-
Attribute(uint16_t attrId, ValueTypes type, uint64_t min, uint64_t max) :
52+
Attribute(AttributeId_t attrId, ValueTypes type) : mDeque(this), mAttrId(attrId), mValue(type), mMin(type), mMax(type) {}
53+
Attribute(AttributeId_t attrId, Value value) :
54+
mDeque(this), mAttrId(attrId), mValue(value), mMin(value.mType), mMax(value.mType)
55+
{}
56+
Attribute(AttributeId_t attrId, ValueTypes type, uint64_t min, uint64_t max) :
5457
mDeque(this), mAttrId(attrId), mValue(type), mMin(type, min), mMax(type, max)
5558
{}
5659

src/lib/datamodel/Cluster.h

+6-5
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
namespace chip {
3131
namespace DataModel {
3232

33+
typedef uint16_t ClusterId_t;
3334
/**
3435
* @brief
3536
* This class implements the cluster object that maintains its attributes. Typically specific
@@ -38,10 +39,10 @@ namespace DataModel {
3839
class Cluster : public Deque<Cluster>
3940
{
4041
public:
41-
uint16_t mClusterId;
42+
ClusterId_t mClusterId;
4243
Deque<Attribute> mAttrs;
4344

44-
Cluster(uint16_t clusterId) : Deque(this), mClusterId(clusterId), mAttrs(nullptr) {}
45+
Cluster(ClusterId_t clusterId) : Deque(this), mClusterId(clusterId), mAttrs(nullptr) {}
4546

4647
virtual ~Cluster() {}
4748

@@ -63,7 +64,7 @@ class Cluster : public Deque<Cluster>
6364
*
6465
* @param attrId the attribute identifer that we are looking for
6566
*/
66-
Attribute * GetAttribute(uint16_t attrId)
67+
Attribute * GetAttribute(AttributeId_t attrId)
6768
{
6869
return mAttrs.Find([attrId](Attribute * item) -> bool { return (item->mAttrId == attrId); });
6970
}
@@ -75,7 +76,7 @@ class Cluster : public Deque<Cluster>
7576
* @param attrId the attribute identifer that should be set
7677
* @param value the new value that the attribute should be updated with
7778
*/
78-
virtual CHIP_ERROR Set(uint16_t attrId, const Value & value)
79+
virtual CHIP_ERROR Set(AttributeId_t attrId, const Value & value)
7980
{
8081
/* Just hand-off to update the value internally */
8182
auto attr = GetAttribute(attrId);
@@ -93,7 +94,7 @@ class Cluster : public Deque<Cluster>
9394
* @param attrId the attribute identifer that should be queried
9495
* @param value the value that the attribute has
9596
*/
96-
virtual CHIP_ERROR Get(uint16_t attrId, Value & value)
97+
virtual CHIP_ERROR Get(AttributeId_t attrId, Value & value)
9798
{
9899
/* Just hand-off to update the value internally */
99100
auto attr = GetAttribute(attrId);

src/lib/datamodel/ClusterBasic.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ namespace chip {
3030
namespace DataModel {
3131

3232
/* Cluster ID */
33-
static const uint16_t kClusterIdBase = 0x0000;
33+
static const ClusterId_t kClusterIdBase = 0x0000;
3434

3535
/* Attribute IDs */
36-
static const uint16_t kAttributeIdZCLVersion = 0x0000;
37-
static const uint16_t kAttributeIdApplicationVersion = 0x0001;
38-
static const uint16_t kAttributeIdStackVersion = 0x0002;
39-
static const uint16_t kAttributeIdHWVersion = 0x0003;
36+
static const AttributeId_t kAttributeIdZCLVersion = 0x0000;
37+
static const AttributeId_t kAttributeIdApplicationVersion = 0x0001;
38+
static const AttributeId_t kAttributeIdStackVersion = 0x0002;
39+
static const AttributeId_t kAttributeIdHWVersion = 0x0003;
4040

4141
/**
4242
* @brief

src/lib/datamodel/ClusterOnOff.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ namespace chip {
3030
namespace DataModel {
3131

3232
/* Cluster ID */
33-
static const uint16_t kClusterIdOnOff = 0x0006;
33+
static const ClusterId_t kClusterIdOnOff = 0x0006;
3434

3535
/* Attribute IDs */
36-
static const uint16_t kAttributeIdOnOff = 0x0000;
37-
static const uint16_t kAttributeIdGlobalSceneControl = 0x4000;
38-
static const uint16_t kAttributeIdOnTime = 0x4001;
39-
static const uint16_t kAttributeIdOffWaitTime = 0x4002;
36+
static const AttributeId_t kAttributeIdOnOff = 0x0000;
37+
static const AttributeId_t kAttributeIdGlobalSceneControl = 0x4000;
38+
static const AttributeId_t kAttributeIdOnTime = 0x4001;
39+
static const AttributeId_t kAttributeIdOffWaitTime = 0x4002;
4040

4141
/**
4242
* @brief

0 commit comments

Comments
 (0)