forked from project-chip/connectedhomeip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMTRDeviceControllerFactory.h
257 lines (227 loc) · 10.5 KB
/
MTRDeviceControllerFactory.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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
/**
*
* Copyright (c) 2022-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.
*/
/**
* An object that allows creating Matter controllers. There can be only one such
* object in a given process.
*/
#import <Foundation/Foundation.h>
#import <Matter/MTRCertificates.h>
#import <Matter/MTRDefines.h>
#import <Matter/MTRDeviceController.h>
NS_ASSUME_NONNULL_BEGIN
@protocol MTRStorage;
@protocol MTRPersistentStorageDelegate;
@protocol MTROTAProviderDelegate;
@protocol MTRKeypair;
@class MTRDeviceControllerStartupParams;
@class MTRFabricInfo;
MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4))
@interface MTRDeviceControllerFactoryParams : NSObject
- (instancetype)init NS_UNAVAILABLE;
/*
* Storage used to store persistent information for the fabrics the
* controllers ends up interacting with. This is only used if "initWithStorage"
* is used to initialize the MTRDeviceControllerFactoryParams. If "init" is
* used, this property will contain a dummy storage that will not be used for
* anything.
*/
@property (nonatomic, strong, readonly) id<MTRStorage> storage;
/*
* OTA Provider delegate to be called when an OTA Requestor is requesting a software update.
* Defaults to nil.
*
* Calls to this delegate can happen on an arbitrary thread, but will not happen
* concurrently.
*/
@property (nonatomic, strong, nullable) id<MTROTAProviderDelegate> otaProviderDelegate;
/*
* The Product Attestation Authority certificates that are trusted to sign
* device attestation information (and in particular to sign Product Attestation
* Intermediate certificates, which then sign Device Attestation Certificates).
*
* Defaults to nil.
*/
@property (nonatomic, copy, nullable) NSArray<MTRCertificateDERBytes> * productAttestationAuthorityCertificates;
/*
* The Certification Declaration certificates whose public keys correspond to
* private keys that are trusted to sign certification declarations. Defaults
* to nil.
*
* These certificates are used in addition to, not replacing, the default set of
* well-known certification declaration signing keys.
*/
@property (nonatomic, copy, nullable) NSArray<MTRCertificateDERBytes> * certificationDeclarationCertificates;
/*
* The network port to bind to. If not specified, an ephemeral port will be
* used.
*/
@property (nonatomic, copy, nullable) NSNumber * port;
/*
* Whether to run a server capable of accepting incoming CASE
* connections. Defaults to NO.
*/
@property (nonatomic, assign) BOOL shouldStartServer;
/*
* Initialize the device controller factory with storage. In this mode, the
* storage will be used to store various information needed by the Matter
* framework.
*/
- (instancetype)initWithStorage:(id<MTRStorage>)storage;
@end
MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4))
@interface MTRDeviceControllerFactory : NSObject
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)new NS_UNAVAILABLE;
/**
* Return the single MTRDeviceControllerFactory we support existing. It starts off
* in a "not started" state.
*/
+ (MTRDeviceControllerFactory *)sharedInstance;
/**
* If true, the factory is in a state where it can create controllers:
* startControllerFactory has been called, but stopControllerFactory has not been called
* since then.
*/
@property (readonly, nonatomic, getter=isRunning) BOOL running;
/**
* Returns the list of MTRFabricInfo representing the fabrics the
* MTRDeviceControllerFactory knows about and the corresponding node identities
* of the controller factory on those fabrics. Returns nil if the factory is
* not running or if there is an error reading fabric information.
*
* All entries in this list will have a non-nil rootCertificate.
*/
@property (readonly, nonatomic, nullable) NSArray<MTRFabricInfo *> * knownFabrics;
/**
* Start the controller factory. Repeated calls to startControllerFactory
* without calls to stopControllerFactory in between are NO-OPs. Use the
* isRunning property to check whether the controller factory needs to be
* started up.
*
* @param[in] startupParams data needed to start up the controller factory.
*
* @return Whether startup succeded.
*/
- (BOOL)startControllerFactory:(MTRDeviceControllerFactoryParams *)startupParams error:(NSError * __autoreleasing *)error;
/**
* Stop the controller factory. This will shut down any outstanding
* controllers as part of the factory stopping.
*
* Repeated calls to stopControllerFactory without calls to
* startControllerFactory in between are NO-OPs.
*/
- (void)stopControllerFactory;
/**
* Create a MTRDeviceController on an existing fabric. Returns nil on failure.
*
* This method will fail if there is no such fabric or if there is
* already a controller started for that fabric.
*
* The fabric is identified by the root public key and fabric id in
* the startupParams.
*
* This method can only be used if the factory was initialized with storage.
* When using per-controller storage, use [MTRDeviceController initWithParameters:error:].
*/
- (MTRDeviceController * _Nullable)createControllerOnExistingFabric:(MTRDeviceControllerStartupParams *)startupParams
error:(NSError * __autoreleasing *)error;
/**
* Create a MTRDeviceController on a new fabric. Returns nil on failure.
*
* This method will fail if the given fabric already exists.
*
* The fabric is identified by the root public key and fabric id in
* the startupParams.
*
* This method can only be used if the factory was initialized with storage.
* When using per-controller storage, use [MTRDeviceController initWithParameters:error:].
*/
- (MTRDeviceController * _Nullable)createControllerOnNewFabric:(MTRDeviceControllerStartupParams *)startupParams
error:(NSError * __autoreleasing *)error;
/**
* If possible, pre-warm the Matter stack for setting up a commissioning session.
*
* This may be called before -[MTRDeviceController setupCommissioningSessionWithPayload:]
* if it is known that a commissioning attempt will soon take place, but the commissioning
* payload is not known yet.
*
* The controller factory must be running for pre-warming to take place. Pre-warming can take place
* before any controllers are started.
*/
- (void)preWarmCommissioningSession MTR_AVAILABLE(ios(17.6), macos(14.6), watchos(10.6), tvos(17.6));
@end
/**
* Set the Message Reliability Protocol parameters for all controllers,
* including already-running ones. This allows control over retransmit delays
* to account for high-latency networks.
*
* Since MRP parameters are communicated to peers during session setup, existing
* sessions will not be affected when this function is called, but all sessions
* established after the call will be.
*
* Setting all arguments to nil will reset to the MRP parameters to their
* default values.
*
* Setting some arguments to non-nil will change just those values, keeping
* current values for any arguments that are nil (not resetting them to
* defaults).
*
* Non-nil arguments are specified as an integer number of milliseconds.
*
* @param idleRetransmitMs the minimal interval between retransmits for someone
* sending messages to us, when they think we are
* "idle" and might have our radio only turned on
* intermittently.
* @param activeRetransmitMs the minimal interval between retransmits for
* someone sending messages to us, when they think we
* are "active" and have the radio turned on
* consistently.
* @param activeThresholdMs the amount of time we will stay in "active" mode after
* network activity.
* @param additionalRetransmitDelayMs additional delay between retransmits for
* messages we send, on top of whatever delay
* the other side requests via its MRP
* parameters.
*/
MTR_EXTERN MTR_AVAILABLE(ios(17.6), macos(14.6), watchos(10.6), tvos(17.6)) void MTRSetMessageReliabilityParameters(NSNumber * _Nullable idleRetransmitMs,
NSNumber * _Nullable activeRetransmitMs,
NSNumber * _Nullable activeThresholdMs,
NSNumber * _Nullable additionalRetransmitDelayMs);
MTR_DEPRECATED(
"Please use MTRDeviceControllerFactoryParams", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4))
@interface MTRControllerFactoryParams : MTRDeviceControllerFactoryParams
@property (nonatomic, strong, readonly) id<MTRPersistentStorageDelegate> storageDelegate MTR_DEPRECATED(
"Please use the storage property", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4));
@property (nonatomic, assign) BOOL startServer MTR_DEPRECATED(
"Please use shouldStartServer", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4));
@property (nonatomic, copy, nullable) NSArray<NSData *> * paaCerts MTR_DEPRECATED(
"Please use productAttestationAuthorityCertificates", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4));
@property (nonatomic, copy, nullable) NSArray<NSData *> * cdCerts MTR_DEPRECATED(
"Please use certificationDeclarationCertificates", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4));
@end
MTR_DEPRECATED("Please use MTRDeviceControllerFactory", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4))
@interface MTRControllerFactory : NSObject
@property (readonly, nonatomic) BOOL isRunning;
+ (MTRControllerFactory *)sharedInstance;
- (BOOL)startup:(MTRControllerFactoryParams *)startupParams;
- (void)shutdown;
- (MTRDeviceController * _Nullable)startControllerOnExistingFabric:(MTRDeviceControllerStartupParams *)startupParams;
- (MTRDeviceController * _Nullable)startControllerOnNewFabric:(MTRDeviceControllerStartupParams *)startupParams;
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)new NS_UNAVAILABLE;
@end
NS_ASSUME_NONNULL_END