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] Duplicate / begin raising MTRDeviceController #34832

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
177695e
Keep MTRDeviceController.mm
kiel-apple Aug 6, 2024
162d162
Copy MTRDeviceController.mm into MTRDeviceController_Concrete.mm
kiel-apple Aug 6, 2024
e96c7ba
Duplicate MTRDeviceController.mm history.
kiel-apple Aug 6, 2024
b056fce
Set back MTRDeviceController.mm file
kiel-apple Aug 6, 2024
c42b2f5
Keep MTRDeviceController.h
kiel-apple Aug 6, 2024
478be89
Copy MTRDeviceController.h into MTRDeviceController_Concrete.h
kiel-apple Aug 6, 2024
4067625
Duplicate MTRDeviceController.h history.
kiel-apple Aug 6, 2024
fea5da6
Set back MTRDeviceController.h file
kiel-apple Aug 6, 2024
3b98dcf
add `MTRDeviceController_Concrete` files
kiel-apple Aug 6, 2024
0df0bad
WIP: bring up `MTRDeviceController_Concrete`
kiel-apple Aug 7, 2024
ce26b94
Merge branch 'master' into darwin-duplicate-mtrdevicecontroller
kiel-apple Aug 7, 2024
ccd72dd
temporary init implementation
kiel-apple Aug 8, 2024
6357e6a
only vend `MTRDeviceController` pointers
kiel-apple Aug 8, 2024
805ed08
add `storedFabricIndex` (currently broken)
kiel-apple Aug 8, 2024
905f226
Merge branch 'master' into darwin-duplicate-mtrdevicecontroller
kiel-apple Aug 8, 2024
1d24e09
reduce access of internal properties
kiel-apple Aug 9, 2024
e1234a3
move C++-style fabric index and keypairs to protected ivars
kiel-apple Aug 9, 2024
6f9cad7
return base class pointer from constructors
kiel-apple Aug 9, 2024
f2ce12a
clean up property synthesis/ivars in concrete
kiel-apple Aug 9, 2024
fac9668
update merged code
kiel-apple Aug 9, 2024
b097785
WIP: get us building again, plus plan comments
kiel-apple Aug 12, 2024
224a9b5
remove superfluous comments
kiel-apple Aug 12, 2024
dbfd96b
Merge branch 'master' into darwin-duplicate-mtrdevicecontroller
kiel-apple Aug 12, 2024
7a572d9
Update src/darwin/Framework/CHIP/MTRDeviceControllerFactory.h
woody-apple Aug 12, 2024
3cac77a
Restyled by clang-format
restyled-commits Aug 12, 2024
8d2cdf4
move MTRDeviceController protected ivars
kiel-apple Aug 13, 2024
0d59aa1
`MTRDeviceController_Concrete` isn't public API
kiel-apple Aug 13, 2024
83bb862
remove commented code
kiel-apple Aug 13, 2024
c4d2c1c
move ivar extension back to internal header
kiel-apple Aug 13, 2024
8004fa9
Fixing TAPI
woody-apple Aug 15, 2024
f798530
Restyled by whitespace
restyled-commits Aug 15, 2024
9037d3a
Restyled by clang-format
restyled-commits Aug 15, 2024
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
4 changes: 2 additions & 2 deletions src/darwin/Framework/CHIP/MTRDeviceController.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1))
* Once this returns non-nil, it's the caller's responsibility to call shutdown
* on the controller to avoid leaking it.
*/
- (nullable instancetype)initWithParameters:(MTRDeviceControllerAbstractParameters *)parameters
error:(NSError * __autoreleasing *)error MTR_AVAILABLE(ios(17.6), macos(14.6), watchos(10.6), tvos(17.6));
- (nullable MTRDeviceController *)initWithParameters:(MTRDeviceControllerAbstractParameters *)parameters
woody-apple marked this conversation as resolved.
Show resolved Hide resolved
error:(NSError * __autoreleasing *)error MTR_AVAILABLE(ios(17.6), macos(14.6), watchos(10.6), tvos(17.6));

/**
* If true, the controller has not been shut down yet.
Expand Down
30 changes: 14 additions & 16 deletions src/darwin/Framework/CHIP/MTRDeviceController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,6 @@
using namespace chip::Tracing::DarwinFramework;

@implementation MTRDeviceController {
// Atomic because they can be touched from multiple threads.
std::atomic<chip::FabricIndex> _storedFabricIndex;
std::atomic<std::optional<uint64_t>> _storedCompressedFabricID;

// queue used to serialize all work performed by the MTRDeviceController
dispatch_queue_t _chipWorkQueue;

Expand All @@ -120,8 +116,6 @@ @implementation MTRDeviceController {
chip::Credentials::DefaultDACVerifier * _defaultDACVerifier;
MTRDeviceControllerDelegateBridge * _deviceControllerDelegateBridge;
MTROperationalCredentialsDelegate * _operationalCredentialsDelegate;
MTRP256KeypairBridge _signingKeypairBridge;
MTRP256KeypairBridge _operationalKeypairBridge;
MTRDeviceAttestationDelegateBridge * _deviceAttestationDelegateBridge;
MTRDeviceControllerFactory * _factory;
NSMapTable * _nodeIDToDeviceMap;
Expand All @@ -133,9 +127,22 @@ @implementation MTRDeviceController {
NSMutableArray<MTRServerEndpoint *> * _serverEndpoints;

MTRDeviceStorageBehaviorConfiguration * _storageBehaviorConfiguration;
std::atomic<chip::FabricIndex> _storedFabricIndex;
std::atomic<std::optional<uint64_t>> _storedCompressedFabricID;
MTRP256KeypairBridge _signingKeypairBridge;
MTRP256KeypairBridge _operationalKeypairBridge;
}

- (instancetype)initForSubclasses
{
if (self = [super init]) {
// nothing, as superclass of MTRDeviceController is NSObject
}

return self;
}

- (nullable instancetype)initWithParameters:(MTRDeviceControllerAbstractParameters *)parameters error:(NSError * __autoreleasing *)error
- (nullable MTRDeviceController *)initWithParameters:(MTRDeviceControllerAbstractParameters *)parameters error:(NSError * __autoreleasing *)error
{
if (![parameters isKindOfClass:MTRDeviceControllerParameters.class]) {
MTR_LOG_ERROR("Unsupported type of MTRDeviceControllerAbstractParameters: %@", parameters);
Expand Down Expand Up @@ -1575,15 +1582,6 @@ + (void)forceLocalhostAdvertisingOnly

@end

/**
* Shim to allow us to treat an MTRDevicePairingDelegate as an
* MTRDeviceControllerDelegate.
*/
@interface MTRDevicePairingDelegateShim : NSObject <MTRDeviceControllerDelegate>
@property (nonatomic, readonly) id<MTRDevicePairingDelegate> delegate;
- (instancetype)initWithDelegate:(id<MTRDevicePairingDelegate>)delegate;
@end

@implementation MTRDevicePairingDelegateShim
- (instancetype)initWithDelegate:(id<MTRDevicePairingDelegate>)delegate
{
Expand Down
2 changes: 1 addition & 1 deletion src/darwin/Framework/CHIP/MTRDeviceControllerFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#import <Foundation/Foundation.h>
#import <Matter/MTRCertificates.h>
#import <Matter/MTRDefines.h>
#import <Matter/MTRDeviceController.h>

NS_ASSUME_NONNULL_BEGIN

Expand All @@ -31,7 +32,6 @@ NS_ASSUME_NONNULL_BEGIN
@protocol MTROTAProviderDelegate;
@protocol MTRKeypair;

@class MTRDeviceController;
@class MTRDeviceControllerStartupParams;
@class MTRFabricInfo;

Expand Down
6 changes: 3 additions & 3 deletions src/darwin/Framework/CHIP/MTRDeviceControllerFactory.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1133,9 +1133,9 @@ - (void)operationalInstanceAdded:(chip::PeerId &)operationalID
}
}

- (MTRDeviceController * _Nullable)initializeController:(MTRDeviceController *)controller
withParameters:(MTRDeviceControllerParameters *)parameters
error:(NSError * __autoreleasing *)error
- (nullable MTRDeviceController *)initializeController:(MTRDeviceController *)controller
withParameters:(MTRDeviceControllerParameters *)parameters
error:(NSError * __autoreleasing *)error
{
[self _assertCurrentQueueIsNotMatterQueue];

Expand Down
17 changes: 5 additions & 12 deletions src/darwin/Framework/CHIP/MTRDeviceController_Concrete.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#import <Matter/MTRCommissionableBrowserDelegate.h>
#import <Matter/MTRDefines.h>
#import <Matter/MTRDeviceController.h>
#import <Matter/MTROperationalCertificateIssuer.h>

@class MTRBaseDevice;
Expand All @@ -37,15 +38,7 @@ typedef void (^MTRDeviceConnectionCallback)(MTRBaseDevice * _Nullable device, NS
@protocol MTRDevicePairingDelegate;
@protocol MTRDeviceControllerDelegate;

MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1))
@interface MTRDeviceController : NSObject

/**
* Controllers are created via the MTRDeviceControllerFactory object or
* initialized via initWithParameters:error:.
*/
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)new NS_UNAVAILABLE;
@interface MTRDeviceController_Concrete : MTRDeviceController

/**
* Initialize a device controller with the provided parameters. This will:
Expand All @@ -57,8 +50,8 @@ MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1))
* Once this returns non-nil, it's the caller's responsibility to call shutdown
* on the controller to avoid leaking it.
*/
- (nullable instancetype)initWithParameters:(MTRDeviceControllerAbstractParameters *)parameters
error:(NSError * __autoreleasing *)error MTR_AVAILABLE(ios(17.6), macos(14.6), watchos(10.6), tvos(17.6));
- (nullable MTRDeviceController *)initWithParameters:(MTRDeviceControllerAbstractParameters *)parameters
error:(NSError * __autoreleasing *)error MTR_AVAILABLE(ios(17.6), macos(14.6), watchos(10.6), tvos(17.6));

/**
* If true, the controller has not been shut down yet.
Expand Down Expand Up @@ -262,7 +255,7 @@ MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1))

@end

@interface MTRDeviceController (Deprecated)
@interface MTRDeviceController_Concrete (Deprecated)

@property (readonly, nonatomic, nullable) NSNumber * controllerNodeId MTR_DEPRECATED(
"Please use controllerNodeID", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4));
Expand Down
Loading
Loading