Skip to content

Commit b179d70

Browse files
authored
Merge branch 'master' into feature/enable-message-cluster
2 parents d6a533a + e59f2ad commit b179d70

File tree

6 files changed

+8801
-0
lines changed

6 files changed

+8801
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
*
3+
* Copyright (c) 2023 Project CHIP Authors
4+
* All rights reserved.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
#pragma once
20+
21+
#import <Matter/MTRClusterConstants.h>
22+
#import <Matter/MTRDefines.h>
23+
24+
/**
25+
* This file defines functions to resolve Matter cluster and attribute IDs into
26+
* strings.
27+
*/
28+
29+
/**
30+
* Resolve Matter cluster IDs into a descriptive string.
31+
*
32+
* For unknown IDs, a string '<Unknown clusterID %d>' will be returned.
33+
*/
34+
MTR_EXTERN MTR_NEWLY_AVAILABLE NSString * MTRClusterNameForID(MTRClusterIDType clusterID);
35+
36+
/**
37+
* Resolve Matter attribute IDs into a descriptive string.
38+
*
39+
* For unknown IDs, a string '<Unknown clusterID %d>' (if the cluster ID is not known)
40+
* or '<Unknown attributeID %d>' (if the cluster ID is known but the attribute ID is not known)
41+
* will be returned.
42+
*/
43+
MTR_EXTERN MTR_NEWLY_AVAILABLE NSString * MTRAttributeNameForID(MTRClusterIDType clusterID, MTRAttributeIDType attributeID);

src/darwin/Framework/CHIP/Matter.h

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#import <Matter/MTRCertificates.h>
3030
#import <Matter/MTRCluster.h>
3131
#import <Matter/MTRClusterConstants.h>
32+
#import <Matter/MTRClusterNames.h>
3233
#import <Matter/MTRClusterStateCacheContainer.h>
3334
#import <Matter/MTRClusters.h>
3435
#import <Matter/MTRCommandPayloadsObjc.h>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
{{> header excludeZapComment=true}}
2+
3+
4+
#import <Matter/MTRClusterNames.h>
5+
6+
// @implementation MTRClusterAttributeIDType
7+
8+
#pragma mark - Clusters IDs
9+
10+
NSString * MTRClusterNameForID(MTRClusterIDType clusterID)
11+
{
12+
NSString * result = nil;
13+
14+
switch (clusterID) {
15+
16+
{{#zcl_clusters}}
17+
{{#if (isSupported (asUpperCamelCase label preserveAcronyms=true) isForIds=true)}}
18+
{{~#*inline "cluster"}}{{asUpperCamelCase label preserveAcronyms=true}}{{/inline~}}
19+
case MTRClusterIDType{{>cluster}}ID:
20+
result = @"{{>cluster}}";
21+
break;
22+
{{/if}}
23+
{{/zcl_clusters}}
24+
25+
default:
26+
result = [NSString stringWithFormat:@"<Unknown clusterID %d>", clusterID];
27+
break;
28+
}
29+
30+
return result;
31+
}
32+
33+
34+
#pragma mark - Attributes IDs
35+
36+
NSString * MTRAttributeNameForID(MTRClusterIDType clusterID, MTRAttributeIDType attributeID)
37+
{
38+
NSString * result = nil;
39+
40+
switch (clusterID) {
41+
42+
{{#zcl_clusters}}
43+
{{#if (isSupported (asUpperCamelCase label preserveAcronyms=true) isForIds=true)}}
44+
{{~#*inline "cluster"}}{{asUpperCamelCase label preserveAcronyms=true}}{{/inline~}}
45+
case MTRClusterIDType{{>cluster}}ID:
46+
47+
switch (attributeID) {
48+
49+
{{/if}}
50+
51+
{{#*inline "attributeIDs"}}
52+
{{#zcl_attributes_server}}
53+
{{~#*inline "cluster"}}{{asUpperCamelCase ../clusterName preserveAcronyms=true}}{{/inline~}}
54+
{{~#*inline "attribute"}}{{asUpperCamelCase label preserveAcronyms=true}}{{/inline~}}
55+
{{#first}}
56+
{{#if (isSupported (asUpperCamelCase ../clusterName preserveAcronyms=true) isForIds=true)}}
57+
// Cluster {{> cluster}} attributes
58+
{{/if}}
59+
{{/first}}
60+
{{#if (and (isSupported (asUpperCamelCase ../clusterName preserveAcronyms=true) attribute=(asUpperCamelCase label preserveAcronyms=true) isForIds=true)
61+
(or clusterRef
62+
(isSupported "" globalAttribute=(asUpperCamelCase label preserveAcronyms=true) isForIds=true)))}}
63+
case MTRAttributeIDTypeCluster{{>cluster}}Attribute{{>attribute}}ID:
64+
result = @"{{>attribute}}";
65+
break;
66+
67+
{{/if}}
68+
{{/zcl_attributes_server}}
69+
{{/inline}}
70+
71+
{{> attributeIDs clusterName=label}}
72+
73+
{{#if (isSupported (asUpperCamelCase label preserveAcronyms=true) isForIds=true)}}
74+
default:
75+
result = [NSString stringWithFormat:@"<Unknown attributeID %d>", attributeID];
76+
break;
77+
}
78+
{{/if}}
79+
80+
{{/zcl_clusters}}
81+
default:
82+
result = [NSString stringWithFormat:@"<Unknown clusterID %d>", clusterID];
83+
break;
84+
}
85+
86+
return result;
87+
}
88+
89+
// @end

src/darwin/Framework/CHIP/templates/templates.json

+5
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,11 @@
120120
"name": "Constants for cluster IDs",
121121
"output": "src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h"
122122
},
123+
{
124+
"path": "MTRClusterNames-src.zapt",
125+
"name": "Objc Cluster Names API",
126+
"output": "src/darwin/Framework/CHIP/zap-generated/MTRClusterNames.mm"
127+
},
123128
{
124129
"path": "MTRAttributeSpecifiedCheck-src.zapt",
125130
"name": "Function to check if attribute is specified",

0 commit comments

Comments
 (0)