|
17 | 17 |
|
18 | 18 | #include <Matter.h>
|
19 | 19 | #include <app/server/Server.h>
|
| 20 | +#include <app/util/attribute-storage.h> |
20 | 21 | #include <MatterEndpoints/MatterGenericSwitch.h>
|
21 | 22 |
|
22 | 23 | using namespace esp_matter;
|
23 | 24 | using namespace esp_matter::endpoint;
|
24 | 25 | using namespace esp_matter::cluster;
|
25 | 26 | using namespace chip::app::Clusters;
|
26 | 27 |
|
| 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 | + |
27 | 51 | MatterGenericSwitch::MatterGenericSwitch() {}
|
28 | 52 |
|
29 | 53 | MatterGenericSwitch::~MatterGenericSwitch() {
|
@@ -76,10 +100,15 @@ bool MatterGenericSwitch::begin() {
|
76 | 100 |
|
77 | 101 | switch_cluster::attribute::create_current_position(aCluster, 0);
|
78 | 102 | switch_cluster::attribute::create_number_of_positions(aCluster, 2);
|
| 103 | + |
| 104 | + descriptor::attribute::create_tag_list(aCluster, NULL, 0, 0); |
79 | 105 |
|
80 | 106 | setEndPointId(endpoint::get_id(endpoint));
|
81 | 107 | log_i("Generic Switch created with endpoint_id %d", getEndPointId());
|
82 | 108 | started = true;
|
| 109 | + |
| 110 | + // TODO: Make it dynamic |
| 111 | + SetTagList(getEndPointId(), chip::Span<const Descriptor::Structs::SemanticTagStruct::Type>(gEp1TagList)); |
83 | 112 | return true;
|
84 | 113 | }
|
85 | 114 |
|
|
0 commit comments