forked from project-chip/connectedhomeip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMTRDeviceController+XPC.h
223 lines (187 loc) · 8.68 KB
/
MTRDeviceController+XPC.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
/**
*
* Copyright (c) 2020-2023 Project CHIP Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#import <Foundation/Foundation.h>
#import <Matter/MTRCluster.h>
#import <Matter/MTRDefines.h>
#import <Matter/MTRDeviceController.h>
#import <Matter/MTRDiagnosticLogsType.h>
NS_ASSUME_NONNULL_BEGIN
typedef NSXPCConnection * _Nonnull (^MTRXPCConnectBlock)(void);
typedef void (^MTRDeviceControllerGetterHandler)(id _Nullable controller, NSError * _Nullable error);
typedef void (^MTRValuesHandler)(id _Nullable values, NSError * _Nullable error);
/**
* Extended methods for MTRDeviceController object over XPC
*/
@interface MTRDeviceController (XPC)
/**
* Returns a shared device controller proxy for the controller object over XPC connection.
*
* @param controllerID an implementation specific id in case multiple shared device controllers are available over XPC connection
* @param xpcConnectBlock block to connect to an XPC listener serving the shared device controllers in an implementation specific
* way
*/
+ (MTRDeviceController *)sharedControllerWithID:(id<NSCopying> _Nullable)controllerID
xpcConnectBlock:(MTRXPCConnectBlock)xpcConnectBlock
MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4));
/**
* Returns an encoded values object to send over XPC for read, write and command interactions
*/
+ (NSArray<NSDictionary<NSString *, id> *> * _Nullable)encodeXPCResponseValues:
(NSArray<NSDictionary<NSString *, id> *> * _Nullable)values;
/**
* Returns a decoded values object from a values object received from XPC for read, write and command interactions
*/
+ (NSArray<NSDictionary<NSString *, id> *> * _Nullable)decodeXPCResponseValues:
(NSArray<NSDictionary<NSString *, id> *> * _Nullable)values;
/**
* Returns a serialized read parameter object to send over XPC
*/
+ (NSDictionary<NSString *, id> * _Nullable)encodeXPCReadParams:(MTRReadParams *)params;
/**
* Returns a deserialized read parameter object from an object received over XPC
*/
+ (MTRReadParams * _Nullable)decodeXPCReadParams:(NSDictionary<NSString *, id> * _Nullable)params;
/**
* Returns a serialized subscribe parameter object to send over XPC
*/
+ (NSDictionary<NSString *, id> * _Nullable)encodeXPCSubscribeParams:(MTRSubscribeParams * _Nullable)params;
/**
* Returns a deserialized subscribe parameter object from an object received over XPC
*/
+ (MTRSubscribeParams * _Nullable)decodeXPCSubscribeParams:(NSDictionary<NSString *, id> * _Nullable)params;
/**
* Returns an NSXPCInterface configured for MTRDeviceControllerServerProtocol.
*/
+ (NSXPCInterface *)xpcInterfaceForServerProtocol MTR_AVAILABLE(ios(16.5), macos(13.4), watchos(9.5), tvos(16.5));
/**
* Returns an NSXPCInterface configured for MTRDeviceControllerClientProtocol.
*/
+ (NSXPCInterface *)xpcInterfaceForClientProtocol MTR_AVAILABLE(ios(16.5), macos(13.4), watchos(9.5), tvos(16.5));
@end
/**
* Protocol that remote object must support over XPC
*/
@protocol MTRDeviceControllerServerProtocol <NSObject>
@required
/**
* Gets any available device controller ID
*/
- (void)getAnyDeviceControllerWithCompletion:(MTRDeviceControllerGetterHandler)completion;
/**
* Requests reading attribute
*/
- (void)readAttributeWithController:(id _Nullable)controller
nodeId:(uint64_t)nodeId
endpointId:(NSNumber * _Nullable)endpointId
clusterId:(NSNumber * _Nullable)clusterId
attributeId:(NSNumber * _Nullable)attributeId
params:(NSDictionary<NSString *, id> * _Nullable)params
completion:(MTRValuesHandler)completion;
/**
* Requests writing attribute
*/
- (void)writeAttributeWithController:(id _Nullable)controller
nodeId:(uint64_t)nodeId
endpointId:(NSNumber *)endpointId
clusterId:(NSNumber *)clusterId
attributeId:(NSNumber *)attributeId
value:(id)value
timedWriteTimeout:(NSNumber * _Nullable)timeoutMs
completion:(MTRValuesHandler)completion;
/**
* Requests invoking command
*/
- (void)invokeCommandWithController:(id _Nullable)controller
nodeId:(uint64_t)nodeId
endpointId:(NSNumber *)endpointId
clusterId:(NSNumber *)clusterId
commandId:(NSNumber *)commandId
fields:(id)fields
timedInvokeTimeout:(NSNumber * _Nullable)timeoutMs
completion:(MTRValuesHandler)completion;
/**
* Requests subscribing attribute. The minInterval/maxInterval arguments
* override whatever intervals might be present in params.
*/
- (void)subscribeAttributeWithController:(id _Nullable)controller
nodeId:(uint64_t)nodeId
endpointId:(NSNumber * _Nullable)endpointId
clusterId:(NSNumber * _Nullable)clusterId
attributeId:(NSNumber * _Nullable)attributeId
minInterval:(NSNumber *)minInterval
maxInterval:(NSNumber *)maxInterval
params:(NSDictionary<NSString *, id> * _Nullable)params
establishedHandler:(dispatch_block_t)establishedHandler;
/**
* Requests to stop reporting
*/
- (void)stopReportsWithController:(id _Nullable)controller nodeId:(uint64_t)nodeId completion:(dispatch_block_t)completion;
/**
* Requests subscription of all attributes. The minInterval/maxInterval
* arguments override whatever intervals might be present in params.
*/
- (void)subscribeWithController:(id _Nullable)controller
nodeId:(uint64_t)nodeId
minInterval:(NSNumber *)minInterval
maxInterval:(NSNumber *)maxInterval
params:(NSDictionary<NSString *, id> * _Nullable)params
shouldCache:(BOOL)shouldCache
completion:(MTRStatusCompletion)completion;
/**
* Requests reading attribute cache
*/
- (void)readAttributeCacheWithController:(id _Nullable)controller
nodeId:(uint64_t)nodeId
endpointId:(NSNumber * _Nullable)endpointId
clusterId:(NSNumber * _Nullable)clusterId
attributeId:(NSNumber * _Nullable)attributeId
completion:(MTRValuesHandler)completion;
@optional
/**
* Gets device controller ID corresponding to a specific fabric ID
*/
- (void)getDeviceControllerWithFabricId:(uint64_t)fabricId
completion:(MTRDeviceControllerGetterHandler)completion
MTR_DEPRECATED("This never called.", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4));
/**
* Requests downloading some logs
*/
- (void)downloadLogWithController:(id _Nullable)controller
nodeId:(NSNumber *)nodeId
type:(MTRDiagnosticLogType)type
timeout:(NSTimeInterval)timeout
completion:(void (^)(NSString * _Nullable url, NSError * _Nullable error))completion MTR_AVAILABLE(ios(17.6), macos(14.6), watchos(10.6), tvos(17.6));
@end
/**
* Protocol that the XPC client local object must support
*/
@protocol MTRDeviceControllerClientProtocol <NSObject>
/**
* Handles a report received by a device controller
*/
- (void)handleReportWithController:(id _Nullable)controller
nodeId:(uint64_t)nodeId
values:(id _Nullable)values
error:(NSError * _Nullable)error;
@end
@interface MTRDeviceController (Deprecated_XPC)
+ (MTRDeviceController *)sharedControllerWithId:(id<NSCopying> _Nullable)controllerID
xpcConnectBlock:(MTRXPCConnectBlock)xpcConnectBlock
MTR_DEPRECATED("Please use sharedControllerWithID:xpcConnectBlock:", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4),
tvos(16.1, 16.4));
@end
NS_ASSUME_NONNULL_END