Skip to content

Commit

Permalink
Add a server cluster to the several_clusters unit test, to validate t…
Browse files Browse the repository at this point in the history
…hat we generate server callbacks to
  • Loading branch information
andy31415 committed Oct 20, 2022
1 parent 892e39a commit ae38dc4
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 2 deletions.
20 changes: 20 additions & 0 deletions scripts/idl/tests/inputs/several_clusters.matter
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,23 @@ client cluster Third = 3 {

attribute MyEnum someEnum = 10;
}

server cluster Third = 3 {
enum MyEnum : enum8 {
kUnknown = 0;
kKnown = 100;
}

attribute MyEnum someEnum = 10;
readonly attribute int16u clusterRevision = 65533;
}

endpoint 0 {
device type rootdevice = 22;
binding cluster Second;

server cluster Third {
ram attribute someEnum;
ram attribute clusterRevision default = 2;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "bridge/First.h"
#include "bridge/Second.h"
#include "bridge/Third.h"
#include "bridge/Third.h"

namespace clusters {

Expand Down Expand Up @@ -39,6 +40,14 @@ struct ClusterInfo
return new(mem) ThirdCluster();
},
},
{
3,
"Third",
sizeof(ThirdCluster),
[](void *mem) -> GeneratedCluster* {
return new(mem) ThirdCluster();
},
},
};

}
5 changes: 4 additions & 1 deletion scripts/idl/tests/outputs/several_clusters/bridge/Third.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ struct ThirdCluster : public GeneratedCluster
{

ThirdCluster() :
mSomeEnum(chip::CharSpan("someEnum"), 10, ATTRIBUTE_MASK_WRITABLE, ZCL_ENUM8_ATTRIBUTE_TYPE, 1)
mSomeEnum(chip::CharSpan("someEnum"), 10, ATTRIBUTE_MASK_WRITABLE, ZCL_ENUM8_ATTRIBUTE_TYPE, 1),
mClusterRevision(chip::CharSpan("clusterRevision"), 65533, 0, ZCL_INT16U_ATTRIBUTE_TYPE, 2, ZCL_THIRD_CLUSTER_REVISION)
{
}

Expand All @@ -19,11 +20,13 @@ struct ThirdCluster : public GeneratedCluster
{
return std::vector<AttributeInterface*>({
static_cast<AttributeInterface*>(&mSomeEnum),
static_cast<AttributeInterface*>(&mClusterRevision),
});
}


Attribute<uint8_t> mSomeEnum;
Attribute<uint16_t> mClusterRevision;
};

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
#define MATTER_PLUGINS_INIT \
MatterFirstPluginClientInitCallback(); \
MatterSecondPluginClientInitCallback(); \
MatterThirdPluginClientInitCallback();
MatterThirdPluginClientInitCallback(); \
MatterThirdPluginServerInitCallback();

0 comments on commit ae38dc4

Please sign in to comment.