Skip to content

Commit bbd3419

Browse files
jtung-applewoody-appleksperling-applebzbarsky-apple
authored
[Darwin] MTRDevice should support multiple delegates (#32491)
* [Darwin] MTRDevice should support multiple delegates * Better naming, comments, and removal of unused ivar * Update src/darwin/Framework/CHIP/MTRDevice.mm Co-authored-by: Karsten Sperling <113487422+ksperling-apple@users.noreply.github.com> * Update src/darwin/Framework/CHIP/MTRDevice.mm Co-authored-by: Karsten Sperling <113487422+ksperling-apple@users.noreply.github.com> * Update src/darwin/Framework/CHIP/MTRDevice.h Co-authored-by: Karsten Sperling <113487422+ksperling-apple@users.noreply.github.com> * Update src/darwin/Framework/CHIP/MTRDevice.mm Co-authored-by: Karsten Sperling <113487422+ksperling-apple@users.noreply.github.com> * Update src/darwin/Framework/CHIP/MTRDevice.mm Co-authored-by: Karsten Sperling <113487422+ksperling-apple@users.noreply.github.com> * Update src/darwin/Framework/CHIP/MTRDevice.mm Co-authored-by: Karsten Sperling <113487422+ksperling-apple@users.noreply.github.com> * Update src/darwin/Framework/CHIP/MTRDevice.mm Co-authored-by: Boris Zbarsky <bzbarsky@apple.com> * Update src/darwin/Framework/CHIP/MTRDevice.mm Co-authored-by: Karsten Sperling <113487422+ksperling-apple@users.noreply.github.com> * Addressed review comments * Address logging review comment * Fix tests caused by new nullability change * Fix unit test --------- Co-authored-by: Justin Wood <woody@apple.com> Co-authored-by: Karsten Sperling <113487422+ksperling-apple@users.noreply.github.com> Co-authored-by: Boris Zbarsky <bzbarsky@apple.com>
1 parent b081572 commit bbd3419

File tree

5 files changed

+809
-158
lines changed

5 files changed

+809
-158
lines changed

src/darwin/Framework/CHIP/MTRDevice.h

+31-2
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,36 @@ MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1))
114114
*
115115
* The delegate will be called on the provided queue, for attribute reports, event reports, and device state changes.
116116
*/
117-
- (void)setDelegate:(id<MTRDeviceDelegate>)delegate queue:(dispatch_queue_t)queue;
117+
- (void)setDelegate:(id<MTRDeviceDelegate>)delegate queue:(dispatch_queue_t)queue MTR_NEWLY_DEPRECATED("Please use addDelegate:queue:interestedPaths:");
118+
119+
/**
120+
* Adds a delegate to receive asynchronous callbacks about the device.
121+
*
122+
* The delegate will be called on the provided queue, for attribute reports, event reports, and device state changes.
123+
*
124+
* MTRDevice holds a weak reference to the delegate object.
125+
*/
126+
- (void)addDelegate:(id<MTRDeviceDelegate>)delegate queue:(dispatch_queue_t)queue MTR_NEWLY_AVAILABLE;
127+
128+
/**
129+
* Adds a delegate to receive asynchronous callbacks about the device, and limit attribute and/or event reports to a specific set of paths.
130+
*
131+
* interestedPathsForAttributes may contain either MTRClusterPath or MTRAttributePath to specify interested clusters and attributes, or NSNumber for endpoints.
132+
*
133+
* interestedPathsForAttributes may contain either MTRClusterPath or MTREventPath to specify interested clusters and events, or NSNumber for endpoints.
134+
*
135+
* For both interested paths arguments, if nil is specified, then no filter will be applied.
136+
*
137+
* Calling addDelegate: again with the same delegate object will update the interested paths for attributes and events for this delegate.
138+
*
139+
* MTRDevice holds a weak reference to the delegate object.
140+
*/
141+
- (void)addDelegate:(id<MTRDeviceDelegate>)delegate queue:(dispatch_queue_t)queue interestedPathsForAttributes:(NSArray * _Nullable)interestedPathsForAttributes interestedPathsForEvents:(NSArray * _Nullable)interestedPathsForEvents MTR_NEWLY_AVAILABLE;
142+
143+
/**
144+
* Removes the delegate from receiving callbacks about the device.
145+
*/
146+
- (void)removeDelegate:(id<MTRDeviceDelegate>)delegate MTR_NEWLY_AVAILABLE;
118147

119148
/**
120149
* Read attribute in a designated attribute path. If there is no value available
@@ -389,7 +418,7 @@ MTR_EXTERN NSString * const MTRDataVersionKey MTR_AVAILABLE(ios(17.6), macos(14.
389418
*
390419
* The data-value dictionary also contains this key:
391420
*
392-
* MTRDataVersionKey : NSNumber-wrapped uin32_t. Monotonically increaseing data version for the cluster.
421+
* MTRDataVersionKey : NSNumber-wrapped uin32_t.
393422
*/
394423
- (void)device:(MTRDevice *)device receivedAttributeReport:(NSArray<NSDictionary<NSString *, id> *> *)attributeReport;
395424

0 commit comments

Comments
 (0)