Skip to content

Commit

Permalink
Expose some more information on MTRDevice/MTRCluster*. (#29769)
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 authored Oct 26, 2023
1 parent df468d4 commit c5549a1
Show file tree
Hide file tree
Showing 7 changed files with 495 additions and 386 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
2 changes: 0 additions & 2 deletions src/darwin/Framework/CHIP/MTRDevice_Internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ typedef void (^MTRDevicePerformAsyncBlock)(MTRBaseDevice * baseDevice);
queue:(dispatch_queue_t)queue
completion:(void (^)(id _Nullable response, NSError * _Nullable error))completion;

@property (nonatomic, readonly) MTRDeviceController * deviceController;
@property (nonatomic, readonly, copy) NSNumber * nodeID;
// Queue used for various internal bookkeeping work.
@property (nonatomic) dispatch_queue_t queue;
@property (nonatomic, readonly) MTRAsyncWorkQueue<MTRDevice *> * asyncWorkQueue;
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.
470 changes: 470 additions & 0 deletions src/darwin/Framework/CHIP/zap-generated/MTRClusters.h

Large diffs are not rendered by default.

Loading

0 comments on commit c5549a1

Please sign in to comment.