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

Remove all mention of "pairing" from Darwin public APIs. #22676

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
@property MTRDeviceController * commissioner;
@property MTRCommissioningParameters * params;

- (void)onPairingComplete:(NSError *)error;
- (void)onPairingDeleted:(NSError *)error;
- (void)onCommissioningSessionEstablishmentDone:(NSError *)error;
- (void)onCommissioningComplete:(NSError *)error;

@end
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ - (void)onStatusUpdate:(MTRCommissioningStatus)status
}
}

- (void)onPairingComplete:(NSError *)error
- (void)onCommissioningSessionEstablishmentDone:(NSError *)error
{
if (error != nil) {
ChipLogProgress(chipTool, "PASE establishment failed");
Expand All @@ -61,11 +61,6 @@ - (void)onPairingComplete:(NSError *)error
}
}

- (void)onPairingDeleted:(NSError *)error
{
_commandBridge->SetCommandExitStatus(error, "Pairing Delete");
}

- (void)onCommissioningComplete:(NSError *)error
{
_commandBridge->SetCommandExitStatus(error, "Pairing Commissioning Complete");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ constexpr const char * kDefaultKey = "default";
@property BOOL active; // Whether to pass on notifications to the commandBridge

- (void)onStatusUpdate:(MTRCommissioningStatus)status;
- (void)onPairingComplete:(NSError * _Nullable)error;
- (void)onPairingDeleted:(NSError * _Nullable)error;
- (void)onCommissioningSessionEstablishmentDone:(NSError * _Nullable)error;
- (void)onCommissioningComplete:(NSError * _Nullable)error;

- (instancetype)init NS_UNAVAILABLE;
Expand Down Expand Up @@ -543,7 +542,7 @@ NS_ASSUME_NONNULL_BEGIN
}
}

- (void)onPairingComplete:(NSError * _Nullable)error
- (void)onCommissioningSessionEstablishmentDone:(NSError * _Nullable)error
{
if (_active) {
if (error != nil) {
Expand All @@ -557,13 +556,6 @@ NS_ASSUME_NONNULL_BEGIN
}
}

- (void)onPairingDeleted:(NSError * _Nullable)error
{
if (_active) {
_commandBridge->PairingDeleted();
}
}

- (void)onCommissioningComplete:(NSError * _Nullable)error
{
if (_active) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ - (void)viewDidLoad

dispatch_queue_t callbackQueue = dispatch_queue_create("com.csa.matter.qrcodevc.callback", DISPATCH_QUEUE_SERIAL);
self.chipController = InitializeMTR();
[self.chipController setPairingDelegate:self queue:callbackQueue];
[self.chipController setDeviceControllerDelegate:self queue:callbackQueue];

UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismissKeyboard)];
[self.view addGestureRecognizer:tap];
Expand Down Expand Up @@ -490,7 +490,7 @@ - (void)setVendorIDOnAccessory
}

// MARK: MTRDeviceControllerDelegate
- (void)onPairingComplete:(NSError * _Nullable)error
- (void)onCommissioningSessionEstablishmentDone:(NSError * _Nullable)error
{
if (error != nil) {
NSLog(@"Got pairing error back %@", error);
Expand Down Expand Up @@ -803,7 +803,7 @@ - (void)_restartMatterStack
{
self.chipController = MTRRestartController(self.chipController);
dispatch_queue_t callbackQueue = dispatch_queue_create("com.csa.matter.qrcodevc.callback", DISPATCH_QUEUE_SERIAL);
[self.chipController setPairingDelegate:self queue:callbackQueue];
[self.chipController setDeviceControllerDelegate:self queue:callbackQueue];
}

- (void)handleRendezVousDefault:(NSString *)payload
Expand Down
8 changes: 4 additions & 4 deletions src/darwin/Framework/CHIP/MTRDeviceController.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ NS_ASSUME_NONNULL_BEGIN
* provided discriminator.
*
* Then a PASE session will be established with the device, unless an error
* occurs. MTRDevicePairingDelegate will be notified as follows:
* occurs. MTRDeviceControllerDelegate will be notified as follows:
*
* * Discovery fails: onStatusUpdate with MTRPairingStatusFailed.
* * Discovery fails: onStatusUpdate with MTRCommissioningStatusFailed.
*
* * Discovery succeeds but commissioning session setup fails: onPairingComplete
* with an error.
Expand Down Expand Up @@ -103,9 +103,9 @@ NS_ASSUME_NONNULL_BEGIN
+ (instancetype)new NS_UNAVAILABLE;

/**
* Set the Delegate for the Device Pairing as well as the Queue on which the Delegate callbacks will be triggered
* Set the Delegate for the device controller as well as the Queue on which the Delegate callbacks will be triggered
*
* @param[in] delegate The delegate the pairing process should use
* @param[in] delegate The delegate the commissioning process should use
*
* @param[in] queue The queue on which the callbacks will be delivered
*/
Expand Down
20 changes: 6 additions & 14 deletions src/darwin/Framework/CHIP/MTRDeviceControllerDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,36 +27,28 @@ typedef NS_ENUM(NSUInteger, MTRCommissioningStatus) {
};

/**
* The protocol definition for the MTRDeviceControllerDelegate
* The protocol definition for the MTRDeviceControllerDelegate.
*
* All delegate methods will be called on the supplied Delegate Queue.
*/
@protocol MTRDeviceControllerDelegate <NSObject>
@optional
/**
* Notify the delegate when pairing status gets updated
*
* Notify the delegate when commissioning status gets updated.
*/
- (void)onStatusUpdate:(MTRCommissioningStatus)status;

/**
* Notify the delegate when pairing is completed
*
* Notify the delegate when a commissioning session is established or the
* establishment has errored out.
*/
- (void)onPairingComplete:(NSError * _Nullable)error;
- (void)onCommissioningSessionEstablishmentDone:(NSError * _Nullable)error;

/**
* Notify the delegate when commissioning is completed
*
* Notify the delegate when commissioning is completed.
*/
- (void)onCommissioningComplete:(NSError * _Nullable)error;

/**
* Notify the delegate when pairing is deleted
*
*/
- (void)onPairingDeleted:(NSError * _Nullable)error;

@end

NS_ASSUME_NONNULL_END
14 changes: 3 additions & 11 deletions src/darwin/Framework/CHIP/MTRDeviceControllerDelegateBridge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@
NSLog(@"DeviceControllerDelegate Pairing complete. Status %s", chip::ErrorStr(error));

id<MTRDeviceControllerDelegate> strongDelegate = mDelegate;
if ([strongDelegate respondsToSelector:@selector(onPairingComplete:)]) {
if ([strongDelegate respondsToSelector:@selector(onCommissioningSessionEstablishmentDone:)]) {
if (strongDelegate && mQueue) {
dispatch_async(mQueue, ^{
NSError * nsError = [MTRError errorForCHIPErrorCode:error];
[strongDelegate onPairingComplete:nsError];
[strongDelegate onCommissioningSessionEstablishmentDone:nsError];
});
}
}
Expand All @@ -87,15 +87,7 @@
{
NSLog(@"DeviceControllerDelegate Pairing deleted. Status %s", chip::ErrorStr(error));

id<MTRDeviceControllerDelegate> strongDelegate = mDelegate;
if ([strongDelegate respondsToSelector:@selector(onPairingDeleted:)]) {
if (strongDelegate && mQueue) {
dispatch_async(mQueue, ^{
NSError * nsError = [MTRError errorForCHIPErrorCode:error];
[strongDelegate onPairingDeleted:nsError];
});
}
}
// This is never actually called; just do nothing.
}

void MTRDeviceControllerDelegateBridge::OnCommissioningComplete(chip::NodeId nodeId, CHIP_ERROR error)
Expand Down
13 changes: 8 additions & 5 deletions src/darwin/Framework/CHIP/MTRSetupPayload.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
NS_ASSUME_NONNULL_BEGIN

typedef NS_OPTIONS(NSUInteger, MTRDiscoveryCapabilities) {
MTRDiscoveryCapabilitiesUnknown = 0, // Device capabilties are not known (e.g. all we have is a manual pairing code).
MTRDiscoveryCapabilitiesUnknown = 0, // Device capabilties are not known
// (e.g. all we have is a numeric code).
MTRDiscoveryCapabilitiesSoftAP = 1 << 0, // Device supports WiFi softAP
MTRDiscoveryCapabilitiesBLE = 1 << 1, // Device supports BLE
MTRDiscoveryCapabilitiesOnNetwork = 1 << 2, // Device supports On Network setup
Expand All @@ -30,8 +31,8 @@ typedef NS_OPTIONS(NSUInteger, MTRDiscoveryCapabilities) {
};

typedef NS_ENUM(NSUInteger, MTRCommissioningFlow) {
MTRCommissioningFlowStandard = 0, // Device automatically enters pairing mode upon power-up
MTRCommissioningFlowUserActionRequired = 1, // Device requires a user interaction to enter pairing mode
MTRCommissioningFlowStandard = 0, // Device automatically enters commissioning mode upon power-up
MTRCommissioningFlowUserActionRequired = 1, // Device requires a user interaction to enter commissioning mode
MTRCommissioningFlowCustom = 2, // Commissioning steps should be retrieved from the distributed compliance ledger
MTRCommissioningFlowInvalid = 3,
};
Expand All @@ -53,8 +54,10 @@ typedef NS_ENUM(NSUInteger, MTROptionalQRCodeInfoType) { MTROptionalQRCodeInfoTy
@end

/**
* A setup payload that can be created from a pairing code and serialized to a
* pairing code.
* A setup payload that can be created from a numeric code or QR code and
* serialized to a numeric code or QR code, though serializing to QR code after
* creating from numeric code will not work, because some required information
* will be missing.
*/
@interface MTRSetupPayload : NSObject <NSSecureCoding>

Expand Down
2 changes: 1 addition & 1 deletion src/darwin/Framework/CHIPTests/MTRDeviceTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ - (id)initWithExpectation:(XCTestExpectation *)expectation
return self;
}

- (void)onPairingComplete:(NSError *)error
- (void)onCommissioningSessionEstablishmentDone:(NSError *)error
{
XCTAssertEqual(error.code, 0);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ - (id)initWithExpectation:(XCTestExpectation *)expectation
return self;
}

- (void)onPairingComplete:(NSError *)error
- (void)onCommissioningSessionEstablishmentDone:(NSError *)error
{
XCTAssertEqual(error.code, 0);
NSError * commissionError = nil;
Expand Down