Skip to content

Commit

Permalink
Darwin framework: add new header generation for cluster/attribute/com…
Browse files Browse the repository at this point in the history
…mand/event IDs to expose in darwin public framework (#18172)

Issue #18164 - Need obj-c friendly constants header for cluster/attribute/command/event IDs
  • Loading branch information
jtung-apple authored and pull[bot] committed Jan 15, 2024
1 parent 3d4649a commit 2845221
Show file tree
Hide file tree
Showing 8 changed files with 2,704 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,9 @@ - (void)reportFromUserEnteredSettings
}
for (CHIPAttributeReport * report in reports) {
// These should be exposed by the SDK
if ([report.path.cluster isEqualToNumber:@(1026)] &&
[report.path.attribute isEqualToNumber:@(0)]) {
if ([report.path.cluster isEqualToNumber:@(kMatterClusterTemperatureMeasurementID)] &&
[report.path.attribute
isEqualToNumber:@(kMatterClusterTemperatureMeasurementAttributeMeasuredValueID)]) {
if (report.error != nil) {
NSLog(@"Error reading temperature: %@", report.error);
} else {
Expand Down
4 changes: 4 additions & 0 deletions src/darwin/Framework/CHIP.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
5AE6D4E427A99041001F2493 /* CHIPDeviceTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5AE6D4E327A99041001F2493 /* CHIPDeviceTests.m */; };
754F3DF427FBB94B00E60580 /* CHIPEventTLVValueDecoder_Internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 754F3DF327FBB94B00E60580 /* CHIPEventTLVValueDecoder_Internal.h */; };
7560FD1C27FBBD3F005E85B3 /* CHIPEventTLVValueDecoder.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7560FD1B27FBBD3F005E85B3 /* CHIPEventTLVValueDecoder.mm */; };
75C645A42825AAC3007E2C29 /* MatterClusterConstants.h in Headers */ = {isa = PBXBuildFile; fileRef = 75C645A32825AAC3007E2C29 /* MatterClusterConstants.h */; settings = {ATTRIBUTES = (Public, ); }; };
88EBF8CE27FABDD500686BC1 /* CHIPDeviceAttestationDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 88EBF8CB27FABDD500686BC1 /* CHIPDeviceAttestationDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; };
88EBF8CF27FABDD500686BC1 /* CHIPDeviceAttestationDelegateBridge.mm in Sources */ = {isa = PBXBuildFile; fileRef = 88EBF8CC27FABDD500686BC1 /* CHIPDeviceAttestationDelegateBridge.mm */; };
88EBF8D027FABDD500686BC1 /* CHIPDeviceAttestationDelegateBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 88EBF8CD27FABDD500686BC1 /* CHIPDeviceAttestationDelegateBridge.h */; };
Expand Down Expand Up @@ -172,6 +173,7 @@
5AE6D4E327A99041001F2493 /* CHIPDeviceTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CHIPDeviceTests.m; sourceTree = "<group>"; };
754F3DF327FBB94B00E60580 /* CHIPEventTLVValueDecoder_Internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CHIPEventTLVValueDecoder_Internal.h; sourceTree = "<group>"; };
7560FD1B27FBBD3F005E85B3 /* CHIPEventTLVValueDecoder.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = CHIPEventTLVValueDecoder.mm; path = "zap-generated/CHIPEventTLVValueDecoder.mm"; sourceTree = "<group>"; };
75C645A32825AAC3007E2C29 /* MatterClusterConstants.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MatterClusterConstants.h; path = "MatterClusterConstants.h"; sourceTree = "<group>"; };
88EBF8CB27FABDD500686BC1 /* CHIPDeviceAttestationDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CHIPDeviceAttestationDelegate.h; sourceTree = "<group>"; };
88EBF8CC27FABDD500686BC1 /* CHIPDeviceAttestationDelegateBridge.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CHIPDeviceAttestationDelegateBridge.mm; sourceTree = "<group>"; };
88EBF8CD27FABDD500686BC1 /* CHIPDeviceAttestationDelegateBridge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CHIPDeviceAttestationDelegateBridge.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -252,6 +254,7 @@
1E857307265519AE0050A4D9 /* callback-stub.cpp */,
1EC4CE6325CC276600D7304F /* CHIPClustersObjc.h */,
1EC4CE5925CC26E900D7304F /* CHIPClustersObjc.mm */,
75C645A32825AAC3007E2C29 /* MatterClusterConstants.h */,
);
name = CHIPGeneratedFiles;
sourceTree = "<group>";
Expand Down Expand Up @@ -395,6 +398,7 @@
2C1B027B2641DB4E00780EF1 /* CHIPOperationalCredentialsDelegate.h in Headers */,
99D466E12798936D0089A18F /* CHIPCommissioningParameters.h in Headers */,
5136661528067D550025EDAE /* MatterControllerFactory_Internal.h in Headers */,
75C645A42825AAC3007E2C29 /* MatterClusterConstants.h in Headers */,
B289D4212639C0D300D4E314 /* CHIPOnboardingPayloadParser.h in Headers */,
513DDB862761F69300DAA01A /* CHIPAttributeTLVValueDecoder_Internal.h in Headers */,
2CB7163F252F731E0026E2BB /* CHIPDevicePairingDelegate.h in Headers */,
Expand Down
1 change: 1 addition & 0 deletions src/darwin/Framework/CHIP/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ static_library("framework") {
"zap-generated/CHIPEventTLVValueDecoder.mm",
"zap-generated/CHIPStructsObjc.h",
"zap-generated/CHIPStructsObjc.mm",
"zap-generated/MatterClusterConstants.h",
]

public_deps = [
Expand Down
1 change: 1 addition & 0 deletions src/darwin/Framework/CHIP/CHIP.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#import <CHIP/CHIPSetupPayload.h>
#import <CHIP/CHIPStructsObjc.h>
#import <CHIP/CHIPThreadOperationalDataset.h>
#import <CHIP/MatterClusterConstants.h>
#import <CHIP/MatterControllerFactory.h>

#import <Foundation/Foundation.h>
Expand Down
1 change: 1 addition & 0 deletions src/darwin/Framework/CHIP/MatterClusterConstants.h
76 changes: 76 additions & 0 deletions src/darwin/Framework/CHIP/templates/MatterClusterConstants.zapt
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{{> header}}

#ifndef MATTER_CLUSTER_CONSTANTS_H
#define MATTER_CLUSTER_CONSTANTS_H

#import <Foundation/Foundation.h>
#import <stdint.h>

#pragma mark - Clusters IDs

typedef NS_ENUM(uint32_t, MatterClusterIDType) {
{{#zcl_clusters}}
kMatterCluster{{asUpperCamelCase label}}ID = {{asMEI manufacturerCode code}},
{{/zcl_clusters}}
};

#pragma mark - Attributes IDs

typedef NS_ENUM(uint32_t, MatterClusterAttributeIDType) {
// Global attributes
{{#zcl_attributes_server}}
{{#unless clusterRef}}
kMatterClusterGlobalAttribute{{asUpperCamelCase label}}ID = {{asMEI manufacturerCode code}},
{{/unless}}
{{/zcl_attributes_server}}

{{#zcl_clusters}}
{{#zcl_attributes_server}}
{{#first}}
// Cluster {{asUpperCamelCase parent.label}} attributes
{{/first}}
{{#if clusterRef}}
kMatterCluster{{asUpperCamelCase parent.label}}Attribute{{asUpperCamelCase label}}ID = {{asMEI manufacturerCode code}},
{{else}}
kMatterCluster{{asUpperCamelCase parent.label}}Attribute{{asUpperCamelCase label}}ID = kMatterClusterGlobalAttribute{{asUpperCamelCase label}}ID,
{{/if}}
{{#last}}

{{/last}}
{{/zcl_attributes_server}}
{{/zcl_clusters}}
};

#pragma mark - Commands IDs

typedef NS_ENUM(uint32_t, MatterClusterCommandIDType) {
{{#zcl_clusters}}
{{#zcl_commands}}
{{#first}}
// Cluster {{asUpperCamelCase parent.label}} commands
{{/first}}
kMatterCluster{{asUpperCamelCase parent.label}}Command{{asUpperCamelCase label}}ID = {{asMEI manufacturerCode code}},
{{#last}}

{{/last}}
{{/zcl_commands}}
{{/zcl_clusters}}
};

#pragma mark - Events IDs

typedef NS_ENUM(uint32_t, MatterClusterEventIDType) {
{{#zcl_clusters}}
{{#zcl_events}}
{{#first}}
// Cluster {{asUpperCamelCase parent.label}} events
{{/first}}
kMatterCluster{{asUpperCamelCase parent.label}}Event{{asUpperCamelCase name}}ID = {{asMEI manufacturerCode code}},
{{#last}}

{{/last}}
{{/zcl_events}}
{{/zcl_clusters}}
};

#endif
5 changes: 5 additions & 0 deletions src/darwin/Framework/CHIP/templates/templates.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@
"path": "CHIPEventTLVValueDecoder-src.zapt",
"name": "Decode TLV event values into Objc objects",
"output": "src/darwin/Framework/CHIP/zap-generated/CHIPEventTLVValueDecoder.mm"
},
{
"path": "MatterClusterConstants.zapt",
"name": "Constants for cluster IDs",
"output": "src/darwin/Framework/CHIP/zap-generated/MatterClusterConstants.h"
}
]
}
Loading

0 comments on commit 2845221

Please sign in to comment.