Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit a66c941

Browse files
committedApr 27, 2024·
Add Latching Switch taglist to Descriptor Cluster
1 parent 0ea42c4 commit a66c941

File tree

3 files changed

+99
-10
lines changed

3 files changed

+99
-10
lines changed
 

‎examples/chef/common/clusters/switch/SwitchManager.cpp

+63
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <app/clusters/switch-server/switch-server.h>
2121
#include <app/server/Server.h>
2222
#include <app/util/att-storage.h>
23+
#include <app/util/attribute-storage.h>
2324
#include <platform/PlatformManager.h>
2425
#include "SwitchEventHandler.h"
2526

@@ -143,11 +144,73 @@ void SwitchActionsDelegate::EventHandler(chip::EndpointId endpointId, chip::Even
143144
}
144145
};
145146

147+
// Please refer to https://github.com/CHIP-Specifications/connectedhomeip-spec/blob/master/src/namespaces
148+
constexpr const uint8_t kNamespaceCommonLevel = 5;
149+
// Common Number Namespace: 5, tag 0 (Low)
150+
constexpr const uint8_t kTagCommonLow = 0;
151+
// Common Number Namespace: 5, tag 1 (Medium)
152+
constexpr const uint8_t kTagCommonMedium = 1;
153+
// Common Number Namespace: 5, tag 2 (High)
154+
constexpr const uint8_t kTagCommonHigh = 2;
155+
156+
constexpr const uint8_t kNamespaceCommonNumber = 7;
157+
// Common Number Namespace: 7, tag 0 (Zero)
158+
constexpr const uint8_t kTagCommonZero = 0;
159+
// Common Number Namespace: 7, tag 1 (One)
160+
constexpr const uint8_t kTagCommonOne = 1;
161+
// Common Number Namespace: 7, tag 2 (Two)
162+
constexpr const uint8_t kTagCommonTwo = 2;
163+
164+
constexpr const uint8_t kNamespacePosition = 8;
165+
// Common Position Namespace: 8, tag: 0 (Left)
166+
constexpr const uint8_t kTagPositionLeft = 0;
167+
// Common Position Namespace: 8, tag: 1 (Right)
168+
constexpr const uint8_t kTagPositionRight = 1;
169+
// Common Position Namespace: 8, tag: 2 (Top)
170+
constexpr const uint8_t kTagPositionTop = 2;
171+
// Common Position Namespace: 8, tag: 3 (Bottom)
172+
constexpr const uint8_t kTagPositionBottom = 3;
173+
// Common Position Namespace: 8, tag: 4 (Middle)
174+
constexpr const uint8_t kTagPositionMiddle = 4;
175+
// Common Position Namespace: 8, tag: 5 (Row)
176+
constexpr const uint8_t kTagPositionRow = 5;
177+
// Common Position Namespace: 8, tag: 6 (Column)
178+
constexpr const uint8_t kTagPositionColumn = 6;
179+
180+
const Clusters::Descriptor::Structs::SemanticTagStruct::Type gLatchingSwitch[] = {
181+
{ .namespaceID = kNamespaceCommonLevel,
182+
.tag = kTagCommonLow,
183+
.label = chip::Optional<chip::app::DataModel::Nullable<chip::CharSpan>>(
184+
{ chip::app::DataModel::MakeNullable(chip::CharSpan("Low", 3)) })},
185+
{ .namespaceID = kNamespaceCommonLevel,
186+
.tag = kTagCommonMedium,
187+
.label = chip::Optional<chip::app::DataModel::Nullable<chip::CharSpan>>(
188+
{ chip::app::DataModel::MakeNullable(chip::CharSpan("Medium", 6)) })},
189+
{ .namespaceID = kNamespaceCommonLevel,
190+
.tag = kTagCommonHigh,
191+
.label = chip::Optional<chip::app::DataModel::Nullable<chip::CharSpan>>(
192+
{ chip::app::DataModel::MakeNullable(chip::CharSpan("High", 4)) })}
193+
};
194+
195+
#if 0
196+
const Clusters::Descriptor::Structs::SemanticTagStruct::Type gEp0TagList[] = {
197+
{ .namespaceID = kNamespaceCommonNumber, .tag = kTagCommonZero }, { .namespaceID = kNamespacePosition, .tag = kTagPositionBottom }
198+
};
199+
const Clusters::Descriptor::Structs::SemanticTagStruct::Type gEp1TagList[] = {
200+
{ .namespaceID = kNamespaceCommon, .tag = kTagCommonOne }, { .namespaceID = kNamespacePosition, .tag = kTagPositionLeft }
201+
};
202+
const Clusters::Descriptor::Structs::SemanticTagStruct::Type gEp2TagList[] = {
203+
{ .namespaceID = kNamespaceCommon, .tag = kTagCommonTwo }, { .namespaceID = kNamespacePosition, .tag = kTagPositionRight }
204+
};
205+
#endif
206+
207+
146208
void emberAfSwitchClusterInitCallback(EndpointId endpointId)
147209
{
148210
ChipLogProgress(Zcl, "Chef: emberAfSwitchClusterInitCallback");
149211
printf("\033[44m %s, %d, Switch::ID=%u \033[0m \n", __func__, __LINE__, Switch::Id);
150212
ChefRpcActionsWorker::Instance().RegisterRpcActionsDelegate(Clusters::Switch::Id, new SwitchActionsDelegate(Clusters::Switch::Id, new SwitchEventHandler()));
213+
SetTagList(/* endpoint= */ 1, Span<const Clusters::Descriptor::Structs::SemanticTagStruct::Type>(gLatchingSwitch));
151214
}
152215

153216

‎examples/chef/devices/rootnode_genericswitch_9866e35d0b.matter

+2
Original file line numberDiff line numberDiff line change
@@ -1425,6 +1425,7 @@ endpoint 0 {
14251425
}
14261426
}
14271427
endpoint 1 {
1428+
device type ma_powersource = 17, version 1;
14281429
device type ma_genericswitch = 15, version 1;
14291430

14301431

@@ -1447,6 +1448,7 @@ endpoint 1 {
14471448
callback attribute serverList;
14481449
callback attribute clientList;
14491450
callback attribute partsList;
1451+
callback attribute tagList;
14501452
callback attribute generatedCommandList;
14511453
callback attribute acceptedCommandList;
14521454
callback attribute eventList;

‎examples/chef/devices/rootnode_genericswitch_9866e35d0b.zap

+34-10
Original file line numberDiff line numberDiff line change
@@ -1935,13 +1935,21 @@
19351935
"profileId": 259,
19361936
"label": "MA-genericswitch",
19371937
"name": "MA-genericswitch"
1938+
},
1939+
{
1940+
"code": 17,
1941+
"profileId": 259,
1942+
"label": "MA-powersource",
1943+
"name": "MA-powersource"
19381944
}
19391945
],
19401946
"deviceVersions": [
1947+
1,
19411948
1
19421949
],
19431950
"deviceIdentifiers": [
1944-
15
1951+
15,
1952+
17
19451953
],
19461954
"deviceTypeName": "MA-genericswitch",
19471955
"deviceTypeCode": 15,
@@ -1984,7 +1992,7 @@
19841992
"singleton": 0,
19851993
"bounded": 0,
19861994
"defaultValue": "0x0",
1987-
"reportable": 1,
1995+
"reportable": 0,
19881996
"minInterval": 1,
19891997
"maxInterval": 65534,
19901998
"reportableChange": 0
@@ -2000,7 +2008,7 @@
20002008
"singleton": 0,
20012009
"bounded": 0,
20022010
"defaultValue": "0x00",
2003-
"reportable": 1,
2011+
"reportable": 0,
20042012
"minInterval": 1,
20052013
"maxInterval": 65534,
20062014
"reportableChange": 0
@@ -2138,7 +2146,7 @@
21382146
"singleton": 0,
21392147
"bounded": 0,
21402148
"defaultValue": null,
2141-
"reportable": 1,
2149+
"reportable": 0,
21422150
"minInterval": 1,
21432151
"maxInterval": 65534,
21442152
"reportableChange": 0
@@ -2154,7 +2162,7 @@
21542162
"singleton": 0,
21552163
"bounded": 0,
21562164
"defaultValue": null,
2157-
"reportable": 1,
2165+
"reportable": 0,
21582166
"minInterval": 1,
21592167
"maxInterval": 65534,
21602168
"reportableChange": 0
@@ -2170,6 +2178,22 @@
21702178
"singleton": 0,
21712179
"bounded": 0,
21722180
"defaultValue": null,
2181+
"reportable": 0,
2182+
"minInterval": 1,
2183+
"maxInterval": 65534,
2184+
"reportableChange": 0
2185+
},
2186+
{
2187+
"name": "TagList",
2188+
"code": 4,
2189+
"mfgCode": null,
2190+
"side": "server",
2191+
"type": "array",
2192+
"included": 1,
2193+
"storageOption": "External",
2194+
"singleton": 0,
2195+
"bounded": 0,
2196+
"defaultValue": null,
21732197
"reportable": 1,
21742198
"minInterval": 1,
21752199
"maxInterval": 65534,
@@ -2483,7 +2507,7 @@
24832507
"storageOption": "External",
24842508
"singleton": 0,
24852509
"bounded": 0,
2486-
"defaultValue": "",
2510+
"defaultValue": null,
24872511
"reportable": 1,
24882512
"minInterval": 1,
24892513
"maxInterval": 65534,
@@ -2499,7 +2523,7 @@
24992523
"storageOption": "External",
25002524
"singleton": 0,
25012525
"bounded": 0,
2502-
"defaultValue": "",
2526+
"defaultValue": null,
25032527
"reportable": 1,
25042528
"minInterval": 1,
25052529
"maxInterval": 65534,
@@ -2515,7 +2539,7 @@
25152539
"storageOption": "External",
25162540
"singleton": 0,
25172541
"bounded": 0,
2518-
"defaultValue": "",
2542+
"defaultValue": null,
25192543
"reportable": 1,
25202544
"minInterval": 1,
25212545
"maxInterval": 65534,
@@ -2531,7 +2555,7 @@
25312555
"storageOption": "External",
25322556
"singleton": 0,
25332557
"bounded": 0,
2534-
"defaultValue": "",
2558+
"defaultValue": null,
25352559
"reportable": 1,
25362560
"minInterval": 1,
25372561
"maxInterval": 65534,
@@ -2547,7 +2571,7 @@
25472571
"storageOption": "External",
25482572
"singleton": 0,
25492573
"bounded": 0,
2550-
"defaultValue": "",
2574+
"defaultValue": null,
25512575
"reportable": 1,
25522576
"minInterval": 1,
25532577
"maxInterval": 65534,

0 commit comments

Comments
 (0)
Please sign in to comment.