Skip to content

Commit 1a7d048

Browse files
[Darwin] Implement MTREventNameForID function (project-chip#34653)
* Implement MTREventNameForID in darwin * Restyled by whitespace --------- Co-authored-by: Restyled.io <[email protected]>
1 parent 6da66b7 commit 1a7d048

File tree

3 files changed

+1919
-0
lines changed

3 files changed

+1919
-0
lines changed

src/darwin/Framework/CHIP/MTRClusterNames.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,12 @@ MTR_EXTERN MTR_AVAILABLE(ios(17.6), macos(14.6), watchos(10.6), tvos(17.6)) NSSt
4141
* will be returned.
4242
*/
4343
MTR_EXTERN MTR_AVAILABLE(ios(17.6), macos(14.6), watchos(10.6), tvos(17.6)) NSString * MTRAttributeNameForID(MTRClusterIDType clusterID, MTRAttributeIDType attributeID);
44+
45+
/**
46+
* Resolve Matter event IDs into a descriptive string.
47+
*
48+
* For unknown IDs, a string '<Unknown clusterID %d>' (if the cluster ID is not known)
49+
* or '<Unknown eventID %d>' (if the cluster ID is known but the event ID is not known)
50+
* will be returned.
51+
*/
52+
MTR_EXTERN MTR_NEWLY_AVAILABLE NSString * MTREventNameForID(MTRClusterIDType clusterID, MTREventIDType eventID);

src/darwin/Framework/CHIP/templates/MTRClusterNames-src.zapt

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,62 @@ NSString * MTRAttributeNameForID(MTRClusterIDType clusterID, MTRAttributeIDType
7575
result = [NSString stringWithFormat:@"<Unknown attributeID %d>", attributeID];
7676
break;
7777
}
78+
break;
79+
{{/if}}
80+
81+
{{/zcl_clusters}}
82+
default:
83+
result = [NSString stringWithFormat:@"<Unknown clusterID %d>", clusterID];
84+
break;
85+
}
86+
87+
return result;
88+
}
89+
90+
91+
#pragma mark - Event IDs
92+
93+
NSString * MTREventNameForID(MTRClusterIDType clusterID, MTREventIDType eventID)
94+
{
95+
NSString * result = nil;
96+
97+
switch (clusterID) {
98+
99+
{{#zcl_clusters}}
100+
{{#if (isSupported (asUpperCamelCase label preserveAcronyms=true) isForIds=true)}}
101+
{{~#*inline "cluster"}}{{asUpperCamelCase label preserveAcronyms=true}}{{/inline~}}
102+
case MTRClusterIDType{{>cluster}}ID:
103+
104+
switch (eventID) {
105+
106+
{{/if}}
107+
108+
{{#*inline "eventIDs"}}
109+
{{#zcl_events}}
110+
{{~#*inline "cluster"}}{{asUpperCamelCase ../clusterName preserveAcronyms=true}}{{/inline~}}
111+
{{~#*inline "event"}}{{asUpperCamelCase name preserveAcronyms=true}}{{/inline~}}
112+
{{#first}}
113+
{{#if (isSupported (asUpperCamelCase ../clusterName preserveAcronyms=true) isForIds=true)}}
114+
// Cluster {{> cluster}} events
115+
{{/if}}
116+
{{/first}}
117+
{{#if (isSupported (asUpperCamelCase ../clusterName preserveAcronyms=true) event=(asUpperCamelCase name preserveAcronyms=true) isForIds=true)}}
118+
case MTREventIDTypeCluster{{>cluster}}Event{{>event}}ID:
119+
result = @"{{>event}}";
120+
break;
121+
122+
{{/if}}
123+
{{/zcl_events}}
124+
{{/inline}}
125+
126+
{{> eventIDs clusterName=label}}
127+
128+
{{#if (isSupported (asUpperCamelCase label preserveAcronyms=true) isForIds=true)}}
129+
default:
130+
result = [NSString stringWithFormat:@"<Unknown eventID %d>", eventID];
131+
break;
132+
}
133+
break;
78134
{{/if}}
79135

80136
{{/zcl_clusters}}

0 commit comments

Comments
 (0)