8000 feat(matter): NamespaceSwitches · espressif/arduino-esp32@42398c7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 42398c7

Browse files
authored
feat(matter): NamespaceSwitches
1 parent 9e61fa7 commit 42398c7

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

libraries/Matter/src/MatterEndpoints/MatterGenericSwitch.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,37 @@
1717

1818
#include <Matter.h>
1919
#include <app/server/Server.h>
20+
#include <app/util/attribute-storage.h>
2021
#include <MatterEndpoints/MatterGenericSwitch.h>
2122

2223
using namespace esp_matter;
2324
using namespace esp_matter::endpoint;
2425
using namespace esp_matter::cluster;
2526
using namespace chip::app::Clusters;
2627

28+
namespace {
29+
// Please refer to https://github.com/CHIP-Specifications/connectedhomeip-spec/blob/master/src/namespaces
30+
constexpr const uint8_t kNamespaceSwitches = 0x43;
31+
// Switches Namespace: 67, tag 0 (SwitchOn)
32+
constexpr const uint8_t kTagSwitchOn = 0;
33+
// Switches Namespace: 67, tag 1 (SwitchOff)
34+
constexpr const uint8_t kTagSwitchOff = 1;
35+
36+
constexpr const uint8_t kNamespacePosition = 8;
37+
// Common Position Namespace: 8, tag: 0 (Left)
38+
constexpr const uint8_t kTagPositionLeft = 0;
39+
// Common Position Namespace: 8, tag: 1 (Right)
40+
constexpr const uint8_t kTagPositionRight = 1;
41+
42+
const Descriptor::Structs::SemanticTagStruct::Type gEp1TagList[] = {
43+
{.namespaceID = kNamespaceSwitches, .tag = kTagSwitchOn},
44+
{.namespaceID = kNamespacePosition, .tag = kTagPositionRight}};
45+
const Descriptor::Structs::SemanticTagStruct::Type gEp2TagList[] = {
46+
{.namespaceID = kNamespaceSwitches, .tag = kTagSwitchOff},
47+
{.namespaceID = kNamespacePosition, .tag = kTagPositionLeft}};
48+
49+
}
50+
2751
MatterGenericSwitch::MatterGenericSwitch() {}
2852

2953
MatterGenericSwitch::~MatterGenericSwitch() {
@@ -76,10 +100,15 @@ bool MatterGenericSwitch::begin() {
76100

77101
switch_cluster::attribute::create_current_position(aCluster, 0);
78102
switch_cluster::attribute::create_number_of_positions(aCluster, 2);
103+
104+
descriptor::attribute::create_tag_list(aCluster, NULL, 0, 0);
79105

80106
setEndPointId(endpoint::get_id(endpoint));
81107
log_i("Generic Switch created with endpoint_id %d", getEndPointId());
82108
started = true;
109+
110+
// TODO: Make it dynamic
111+
SetTagList(getEndPointId(), chip::Span<const Descriptor::Structs::SemanticTagStruct::Type>(gEp1TagList));
83112
return true;
84113
}
85114

0 commit comments

Comments
 (0)
0