Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Darwin] Implement multiple read and subscribe #25840

Merged
Show file tree
Hide file tree
Changes from 72 commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
23dc3a6
Implement darwin multiple attribute, event read / subscribe
joonhaengHeo Mar 17, 2023
fce7525
restyle
joonhaengHeo Mar 17, 2023
46ffc58
Merge branch 'master' of github.com:joonhaengHeo/connectedhomeip into…
joonhaengHeo Mar 24, 2023
4b84448
Merge branch 'implement_darwin_multiple_read_subscribe' of github.com…
joonhaengHeo Mar 24, 2023
bc5eeb3
Merge branch 'master' of github.com:joonhaengHeo/connectedhomeip into…
joonhaengHeo Mar 25, 2023
a36a2e9
Add Exception check
joonhaengHeo Mar 27, 2023
5be3414
Remove unused code
joonhaengHeo Mar 27, 2023
2e7495e
Restyle
joonhaengHeo Mar 27, 2023
4488b7e
Merge branch 'master' into implement_darwin_multiple_read_subscribe
joonhaengHeo Mar 27, 2023
69548b2
Modify from comment
joonhaengHeo Mar 28, 2023
51c8670
Restyle
joonhaengHeo Mar 28, 2023
f8d8c69
Add MTRAttributeRequestPath, EventRequestPath
joonhaengHeo Apr 7, 2023
09d9521
restyle
joonhaengHeo Apr 7, 2023
d9c09b0
Update src/darwin/Framework/CHIP/MTRBaseDevice.h
joonhaengHeo Apr 8, 2023
4b65716
Update src/darwin/Framework/CHIP/MTRBaseDevice.h
joonhaengHeo Apr 8, 2023
5c4302f
Update src/darwin/Framework/CHIP/MTRBaseDevice.h
joonhaengHeo Apr 8, 2023
bfc594a
Update src/darwin/Framework/CHIP/MTRBaseDevice.h
joonhaengHeo Apr 8, 2023
23bdf38
Update src/darwin/Framework/CHIP/MTRBaseDevice.h
joonhaengHeo Apr 8, 2023
e5d6acb
Update src/darwin/Framework/CHIP/MTRBaseDevice.h
joonhaengHeo Apr 8, 2023
b084dc9
Update src/darwin/Framework/CHIP/MTRBaseDevice.h
joonhaengHeo Apr 8, 2023
392e276
Update src/darwin/Framework/CHIP/MTRBaseDevice.h
joonhaengHeo Apr 8, 2023
3d01392
Update src/darwin/Framework/CHIP/MTRBaseDevice.h
joonhaengHeo Apr 8, 2023
00831ca
Update src/darwin/Framework/CHIP/MTRBaseDevice.h
joonhaengHeo Apr 8, 2023
d4a25dc
Update src/darwin/Framework/CHIP/MTRBaseDevice.h
joonhaengHeo Apr 8, 2023
9a11f72
Update src/darwin/Framework/CHIP/MTRBaseDevice.h
joonhaengHeo Apr 8, 2023
4131e35
Update src/darwin/Framework/CHIP/MTRBaseDevice.h
joonhaengHeo Apr 8, 2023
fc27a7c
Update src/darwin/Framework/CHIP/MTRBaseDevice.h
joonhaengHeo Apr 8, 2023
d6ff44c
Update src/darwin/Framework/CHIP/MTRBaseDevice.h
joonhaengHeo Apr 8, 2023
dd9dfda
Update src/darwin/Framework/CHIP/MTRBaseDevice.mm
joonhaengHeo Apr 8, 2023
b05f10e
Update src/darwin/Framework/CHIP/MTRBaseDevice.h
joonhaengHeo Apr 8, 2023
465963a
Update src/darwin/Framework/CHIP/MTRBaseDevice.h
joonhaengHeo Apr 8, 2023
287d75d
Update src/darwin/Framework/CHIP/MTRBaseDevice.h
joonhaengHeo Apr 8, 2023
574120f
Update src/darwin/Framework/CHIP/MTRBaseDevice.mm
joonhaengHeo Apr 8, 2023
b8cb57d
Update src/darwin/Framework/CHIP/MTRBaseDevice.mm
joonhaengHeo Apr 8, 2023
39978a5
Update src/darwin/Framework/CHIP/MTRBaseDevice.mm
joonhaengHeo Apr 8, 2023
95ec85b
Update src/darwin/Framework/CHIP/MTRBaseDevice.mm
joonhaengHeo Apr 8, 2023
cae5d81
Update src/darwin/Framework/CHIP/MTRBaseDevice.mm
joonhaengHeo Apr 8, 2023
1160cf8
Update src/darwin/Framework/CHIP/MTRBaseDevice.mm
joonhaengHeo Apr 8, 2023
374845b
Update src/darwin/Framework/CHIP/MTRBaseDevice.mm
joonhaengHeo Apr 8, 2023
ec0434a
Update src/darwin/Framework/CHIP/MTRBaseDevice.mm
joonhaengHeo Apr 8, 2023
5981cbd
Update src/darwin/Framework/CHIP/MTRBaseDevice.mm
joonhaengHeo Apr 8, 2023
ebfbfce
fix build error
joonhaengHeo Apr 9, 2023
a26987a
restyle
joonhaengHeo Apr 9, 2023
dca26f6
Add set null eventPath
joonhaengHeo Apr 9, 2023
d6027d0
Merge branch 'implement_darwin_multiple_read_subscribe' of github.com…
joonhaengHeo Apr 9, 2023
6267b37
Modify memort allocation
joonhaengHeo Apr 11, 2023
e77bd17
restyle
joonhaengHeo Apr 11, 2023
cc4f374
Modify delete -> memoryfree
joonhaengHeo Apr 11, 2023
7144454
Update code
joonhaengHeo Apr 12, 2023
32cc8ce
remove unused code
joonhaengHeo Apr 12, 2023
7eb0bbb
restyle
joonhaengHeo Apr 12, 2023
5c9d323
Merge branch 'master' into implement_darwin_multiple_read_subscribe
joonhaengHeo Apr 12, 2023
12373e9
Fix crash in Test
joonhaengHeo Apr 12, 2023
0d0de78
Add TestCases, modify some issues
joonhaengHeo Apr 12, 2023
3adafc0
restyle
joonhaengHeo Apr 12, 2023
069c9ee
Add comment, modify testcase
joonhaengHeo Apr 12, 2023
a1cd0cc
Update src/darwin/Framework/CHIP/MTRBaseDevice.h
joonhaengHeo Apr 12, 2023
debd9aa
Update src/darwin/Framework/CHIP/MTRBaseDevice.mm
joonhaengHeo Apr 12, 2023
ac6a7ab
Update src/darwin/Framework/CHIP/MTRBaseDevice.mm
joonhaengHeo Apr 12, 2023
580746f
Update src/darwin/Framework/CHIP/MTRBaseDevice.h
joonhaengHeo Apr 12, 2023
bd0ff2a
Update src/darwin/Framework/CHIP/MTRBaseDevice.h
joonhaengHeo Apr 12, 2023
3212054
Update src/darwin/Framework/CHIP/MTRBaseDevice.h
joonhaengHeo Apr 12, 2023
48e88fd
Update src/darwin/Framework/CHIP/MTRBaseDevice.h
joonhaengHeo Apr 12, 2023
85aac30
modify code location, add some patch
joonhaengHeo Apr 12, 2023
3c7b624
modify typo
joonhaengHeo Apr 12, 2023
477a88e
Add assert code
joonhaengHeo Apr 12, 2023
c83dfd5
restyle
joonhaengHeo Apr 12, 2023
e442c8c
Update src/darwin/Framework/CHIP/MTRBaseDevice.mm
joonhaengHeo Apr 13, 2023
dd40779
Update src/darwin/Framework/CHIP/MTRBaseDevice.mm
joonhaengHeo Apr 13, 2023
994c73e
Add subscribe null check
joonhaengHeo Apr 13, 2023
3619342
Merge branch 'master' into implement_darwin_multiple_read_subscribe
joonhaengHeo Apr 13, 2023
c97da79
modify
joonhaengHeo Apr 14, 2023
40eca60
Modify using uniqur_ptr
joonhaengHeo Apr 17, 2023
f855ea5
restyle
joonhaengHeo Apr 17, 2023
fb12a69
Revert "restyle"
joonhaengHeo Apr 18, 2023
5428b0a
Revert "Modify using uniqur_ptr"
joonhaengHeo Apr 18, 2023
b8cdaf1
modify using scopeBuffer
joonhaengHeo Apr 18, 2023
d493f31
restyle
joonhaengHeo Apr 18, 2023
995d77f
Dispatch resubscription callback to the right queue.
bzbarsky-apple Apr 18, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/app/EventPathParams.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ struct EventPathParams
inline bool HasWildcardEndpointId() const { return mEndpointId == kInvalidEndpointId; }
inline bool HasWildcardClusterId() const { return mClusterId == kInvalidClusterId; }
inline bool HasWildcardEventId() const { return mEventId == kInvalidEventId; }
inline void SetWildcardEndpointId() { mEndpointId = kInvalidEndpointId; }
inline void SetWildcardClusterId() { mClusterId = kInvalidClusterId; }
inline void SetWildcardEventId() { mEventId = kInvalidEventId; }

bool IsEventPathSupersetOf(const ConcreteEventPath & other) const
{
Expand Down
73 changes: 73 additions & 0 deletions src/darwin/Framework/CHIP/MTRBaseDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,38 @@ typedef NS_ENUM(uint8_t, MTRTransportType) {
MTRTransportTypeTCP,
} API_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4));

/**
* A path indicating an attribute being requested (for read or subscribe).
*
* nil is used to represent wildcards.
*/
MTR_NEWLY_AVAILABLE
@interface MTRAttributeRequestPath : NSObject <NSCopying>
@property (nonatomic, readonly, copy, nullable) NSNumber * endpoint;
@property (nonatomic, readonly, copy, nullable) NSNumber * cluster;
@property (nonatomic, readonly, copy, nullable) NSNumber * attribute;

+ (MTRAttributeRequestPath *)requestPathWithEndpointID:(NSNumber * _Nullable)endpointID
clusterID:(NSNumber * _Nullable)clusterID
attributeID:(NSNumber * _Nullable)attributeID MTR_NEWLY_AVAILABLE;
@end

/**
* A path indicating an event being requested (for read or subscribe).
*
* nil is used to represent wildcards.
*/
MTR_NEWLY_AVAILABLE
@interface MTREventRequestPath : NSObject <NSCopying>
@property (nonatomic, readonly, copy, nullable) NSNumber * endpoint;
@property (nonatomic, readonly, copy, nullable) NSNumber * cluster;
@property (nonatomic, readonly, copy, nullable) NSNumber * event;

+ (MTREventRequestPath *)requestPathWithEndpointID:(NSNumber * _Nullable)endpointID
clusterID:(NSNumber * _Nullable)clusterID
eventID:(NSNumber * _Nullable)eventID MTR_NEWLY_AVAILABLE;
@end

@interface MTRBaseDevice : NSObject

- (instancetype)init NS_UNAVAILABLE;
Expand Down Expand Up @@ -229,6 +261,26 @@ typedef NS_ENUM(uint8_t, MTRTransportType) {
completion:(MTRDeviceResponseHandler)completion
API_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4));

/**
* Reads multiple attribute or event paths from the device.
*
* Nil is treated as an empty array for attributePaths and eventPaths.
*
* Lists of attribute and event paths to read can be provided via attributePaths and eventPaths.
*
* The completion will be called with an error if the input parameters are invalid (e.g., both attributePaths and eventPaths are
* empty.) or the entire read interaction fails. Otherwise it will be called with values, which may be empty (e.g. if no paths
* matched the wildcard paths passed in) or may include per-path errors if particular paths failed.
*
* If the sum of the lengths of attributePaths and eventPaths exceeds 9, the read may fail due to the device not supporting that
* many read paths.
*/
- (void)readAttributePaths:(NSArray<MTRAttributeRequestPath *> * _Nullable)attributePaths
eventPaths:(NSArray<MTREventRequestPath *> * _Nullable)eventPaths
params:(MTRReadParams * _Nullable)params
queue:(dispatch_queue_t)queue
completion:(MTRDeviceResponseHandler)completion MTR_NEWLY_AVAILABLE;

/**
* Write to attribute in a designated attribute path
*
Expand Down Expand Up @@ -305,6 +357,27 @@ typedef NS_ENUM(uint8_t, MTRTransportType) {
subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished
API_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4));

/**
* Subscribes to multiple attribute or event paths.
*
* Nil is treated as an empty array for attributePaths and eventPaths.
*
* Lists of attribute and event paths to subscribe to can be provided via attributePaths and eventPaths.
*
* The reportHandler will be called with an error if the inputs are invalid (e.g., both attributePaths and eventPaths are
* empty), or if the subscription fails entirely.
*
* If the sum of the lengths of attributePaths and eventPaths exceeds 3, the subscribe may fail due to the device not supporting
* that many paths for a subscription.
*/
- (void)subscribeToAttributePaths:(NSArray<MTRAttributeRequestPath *> * _Nullable)attributePaths
eventPaths:(NSArray<MTREventRequestPath *> * _Nullable)eventPaths
params:(MTRSubscribeParams * _Nullable)params
queue:(dispatch_queue_t)queue
reportHandler:(MTRDeviceResponseHandler)reportHandler
subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished
resubscriptionScheduled:(MTRDeviceResubscriptionScheduledHandler _Nullable)resubscriptionScheduled MTR_NEWLY_AVAILABLE;

/**
* Deregister all local report handlers for a remote device
*
Expand Down
Loading