Skip to content

Commit

Permalink
Expose some more information on MTRDevice/MTRCluster*.
Browse files Browse the repository at this point in the history
* Node ID and controller on MTRDevice.
* Endpoint ID and device on MTRCluster.

The ids are NS_REFINED_FOR_SWIFT so we can add a nicer-typed Swift version once
we can do that.
  • Loading branch information
bzbarsky-apple committed Oct 13, 2023
1 parent a7c96f0 commit 3367135
Show file tree
Hide file tree
Showing 6 changed files with 495 additions and 384 deletions.
5 changes: 5 additions & 0 deletions src/darwin/Framework/CHIP/MTRCluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ NS_ASSUME_NONNULL_BEGIN
@interface MTRCluster : NSObject
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)new NS_UNAVAILABLE;

/**
* The endpoint this cluster lives on.
*/
@property (nonatomic, readonly) NSNumber * endpointID NS_REFINED_FOR_SWIFT MTR_NEWLY_AVAILABLE;
@end

/**
Expand Down
11 changes: 11 additions & 0 deletions src/darwin/Framework/CHIP/MTRDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,17 @@ typedef NS_ENUM(NSUInteger, MTRDeviceState) {
@property (nonatomic, readonly, nullable)
NSDate * estimatedStartTime MTR_AVAILABLE(ios(16.5), macos(13.4), watchos(9.5), tvos(16.5));

/**
* The controller this device was created for. May return nil if that
* controller has been shut down.
*/
@property (nonatomic, readonly, nullable) MTRDeviceController * deviceController MTR_NEWLY_AVAILABLE;

/**
* The node ID of the node this device corresponds to.
*/
@property (nonatomic, readonly, copy) NSNumber * nodeID NS_REFINED_FOR_SWIFT MTR_NEWLY_AVAILABLE;

/**
* Set the delegate to receive asynchronous callbacks about the device.
*
Expand Down
5 changes: 5 additions & 0 deletions src/darwin/Framework/CHIP/templates/MTRClusters.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ NS_ASSUME_NONNULL_BEGIN
endpointID:(NSNumber *)endpointID
queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER {{availability (asUpperCamelCase name preserveAcronyms=true) minimalRelease="First major API revamp"}};

/**
* The device this cluster object is associated with.
*/
@property (nonatomic, readonly) MTRDevice * device {{availability (asUpperCamelCase name preserveAcronyms=true) minimalRelease="Future"}};

{{#zcl_commands}}
{{#if (is_str_equal source 'client')}}
{{! Takes two arguments: cluster name and command name, plus the ambient state where the command is "this" }}
Expand Down
11 changes: 2 additions & 9 deletions src/darwin/Framework/CHIP/templates/MTRClusters_Internal.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,5 @@
#import "MTRDevice.h"
#import "MTRDevice_Internal.h"

{{#zcl_clusters}}

{{#if (isSupported (asUpperCamelCase name preserveAcronyms=true))}}
@interface MTRCluster{{asUpperCamelCase name preserveAcronyms=true}} ()
@property (nonatomic, readonly) MTRDevice *device;
@end
{{/if}}

{{/zcl_clusters}}
// Nothing here for now, but leaving this file in place in case we need to add
// something.
Loading

0 comments on commit 3367135

Please sign in to comment.