diff --git a/src/controller/CHIPDeviceController.cpp b/src/controller/CHIPDeviceController.cpp index 4be4ab46314cb4..61350870fb1a0e 100644 --- a/src/controller/CHIPDeviceController.cpp +++ b/src/controller/CHIPDeviceController.cpp @@ -1649,7 +1649,6 @@ void DeviceCommissioner::OnNodeIdResolved(const chip::Dnssd::ResolvedNodeData & if (mDeviceBeingCommissioned != nullptr && mDeviceBeingCommissioned->GetDeviceId() == nodeData.mPeerId.GetNodeId()) { - RendezvousCleanup(CHIP_NO_ERROR); // Let's release the device that's being paired, if pairing was successful, // and the device is available on the operational network. ReleaseCommissioneeDevice(mDeviceBeingCommissioned); diff --git a/src/controller/SetUpCodePairer.cpp b/src/controller/SetUpCodePairer.cpp index a53c4fdcb2fa37..ddb460051b40b9 100644 --- a/src/controller/SetUpCodePairer.cpp +++ b/src/controller/SetUpCodePairer.cpp @@ -146,7 +146,9 @@ void SetUpCodePairer::OnDiscoveredDeviceOverBle(BLE_CONNECTION_OBJECT connObj) Transport::PeerAddress peerAddress = Transport::PeerAddress::BLE(); RendezvousParameters params = RendezvousParameters().SetPeerAddress(peerAddress).SetConnectionObject(connObj); - OnDeviceDiscovered(params); + // We don't have network credentials, so can't do the entire pairing flow. Just establish a PASE session to the + // device and let our consumer deal with the rest. + LogErrorOnFailure(mCommissioner->EstablishPASEConnection(mRemoteId, params.SetSetupPINCode(mSetUpPINCode))); } void SetUpCodePairer::OnDiscoveredDeviceOverBleSuccess(void * appState, BLE_CONNECTION_OBJECT connObj) diff --git a/src/darwin/CHIPTool/CHIPTool/View Controllers/QRCode/QRCodeViewController.m b/src/darwin/CHIPTool/CHIPTool/View Controllers/QRCode/QRCodeViewController.m index df63c6978e8aec..4e2ee4ba58bad8 100644 --- a/src/darwin/CHIPTool/CHIPTool/View Controllers/QRCode/QRCodeViewController.m +++ b/src/darwin/CHIPTool/CHIPTool/View Controllers/QRCode/QRCodeViewController.m @@ -628,62 +628,31 @@ - (void)retrieveAndSendWiFiCredentials } NSLog(@"New SSID: %@ Password: %@", networkSSID.text, networkPassword.text); - [strongSelf addOrUpdateWiFiNetwork:networkSSID.text password:networkPassword.text]; + [strongSelf commissionWithSSID:networkSSID.text password:networkPassword.text]; } }]]; [self presentViewController:alertController animated:YES completion:nil]; } -- (void)addOrUpdateWiFiNetwork:(NSString *)ssid password:(NSString *)password +- (void)commissionWithSSID:(NSString *)ssid password:(NSString *)password { - CHIPDevice * chipDevice = CHIPGetDeviceBeingCommissioned(); - if (chipDevice) { - self.cluster = [[CHIPNetworkCommissioning alloc] initWithDevice:chipDevice endpoint:0 queue:dispatch_get_main_queue()]; - __auto_type * params = [[CHIPNetworkCommissioningClusterAddOrUpdateWiFiNetworkParams alloc] init]; - params.ssid = [ssid dataUsingEncoding:NSUTF8StringEncoding]; - params.credentials = [password dataUsingEncoding:NSUTF8StringEncoding]; - params.breadcrumb = @(0); - - __weak typeof(self) weakSelf = self; - [self->_cluster - addOrUpdateWiFiNetworkWithParams:params - completionHandler:^(CHIPNetworkCommissioningClusterNetworkConfigResponseParams * _Nullable response, - NSError * _Nullable error) { - // TODO: addWiFiNetworkWithParams - // returns status in its response, - // not via the NSError! - [weakSelf onAddNetworkResponse:error isWiFi:YES]; - }]; - } else { - NSLog(@"Status: Failed to find a device being commissioned"); - } -} -- (void)addOrUpdateThreadNetwork:(NSData *)threadDataSet -{ - CHIPDevice * chipDevice = CHIPGetDeviceBeingCommissioned(); - if (chipDevice) { - self.cluster = [[CHIPNetworkCommissioning alloc] initWithDevice:chipDevice endpoint:0 queue:dispatch_get_main_queue()]; - __auto_type * params = [[CHIPNetworkCommissioningClusterAddOrUpdateThreadNetworkParams alloc] init]; - params.operationalDataset = threadDataSet; - params.breadcrumb = @(0); - - __weak typeof(self) weakSelf = self; - [self->_cluster - addOrUpdateThreadNetworkWithParams:params - completionHandler:^(CHIPNetworkCommissioningClusterNetworkConfigResponseParams * _Nullable response, - NSError * _Nullable error) { - // TODO: addThreadNetworkWithParams - // returns status in its response, - // not via the NSError! - [weakSelf onAddNetworkResponse:error isWiFi:NO]; - }]; - } else { - NSLog(@"Status: Failed to find a device being commissioned"); + NSError * error; + CHIPDeviceController * controller = [CHIPDeviceController sharedController]; + // create commissioning params in ObjC. Pass those in here with network credentials. + // maybe this just becomes the new norm + CHIPCommissioningParameters * params = [[CHIPCommissioningParameters alloc] init]; + params.wifiSSID = [ssid dataUsingEncoding:NSUTF8StringEncoding]; + params.wifiCredentials = [password dataUsingEncoding:NSUTF8StringEncoding]; + + uint64_t deviceId = CHIPGetNextAvailableDeviceID() - 1; + + if (![controller commissionDevice:deviceId commissioningParams:params error:&error]) { + NSLog(@"Failed to commission Device %llu, with error %@", deviceId, error); } } -- (void)onAddNetworkResponse:(NSError *)error isWiFi:(BOOL)isWiFi +- (void)onAddNetworkResponse:(NSError *)error { if (error != nil) { NSLog(@"Error adding network: %@", error); @@ -691,13 +660,9 @@ - (void)onAddNetworkResponse:(NSError *)error isWiFi:(BOOL)isWiFi } __auto_type * params = [[CHIPNetworkCommissioningClusterConnectNetworkParams alloc] init]; - if (isWiFi) { - NSString * ssid = CHIPGetDomainValueForKey(kCHIPToolDefaultsDomain, kNetworkSSIDDefaultsKey); - params.networkID = [ssid dataUsingEncoding:NSUTF8StringEncoding]; - } else { - uint8_t tempThreadNetworkId[] = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef }; - params.networkID = [NSData dataWithBytes:tempThreadNetworkId length:sizeof(tempThreadNetworkId)]; - } + + NSString * ssid = CHIPGetDomainValueForKey(kCHIPToolDefaultsDomain, kNetworkSSIDDefaultsKey); + params.networkID = [ssid dataUsingEncoding:NSUTF8StringEncoding]; params.breadcrumb = @(0); __weak typeof(self) weakSelf = self; @@ -721,7 +686,7 @@ - (void)onConnectNetworkResponse:(NSError *)error [controller updateDevice:deviceId fabricId:0]; } -- (void)onAddressUpdated:(NSError * _Nullable)error +- (void)onCommissioningComplete:(NSError * _Nullable)error { if (error != nil) { NSLog(@"Error retrieving device informations over Mdns: %@", error); diff --git a/src/darwin/Framework/CHIP.xcodeproj/project.pbxproj b/src/darwin/Framework/CHIP.xcodeproj/project.pbxproj index ad51c7f8c0ef25..9c5f2f2794e573 100644 --- a/src/darwin/Framework/CHIP.xcodeproj/project.pbxproj +++ b/src/darwin/Framework/CHIP.xcodeproj/project.pbxproj @@ -68,7 +68,9 @@ 998F286D26D55E10001846C6 /* CHIPKeypair.h in Headers */ = {isa = PBXBuildFile; fileRef = 998F286C26D55E10001846C6 /* CHIPKeypair.h */; settings = {ATTRIBUTES = (Public, ); }; }; 998F286F26D55EC5001846C6 /* CHIPP256KeypairBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 998F286E26D55EC5001846C6 /* CHIPP256KeypairBridge.h */; }; 998F287126D56940001846C6 /* CHIPP256KeypairBridge.mm in Sources */ = {isa = PBXBuildFile; fileRef = 998F287026D56940001846C6 /* CHIPP256KeypairBridge.mm */; }; + 99AECC802798A57F00B6355B /* CHIPCommissioningParameters.m in Sources */ = {isa = PBXBuildFile; fileRef = 99AECC7F2798A57E00B6355B /* CHIPCommissioningParameters.m */; }; 99C65E10267282F1003402F6 /* CHIPControllerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 99C65E0F267282F1003402F6 /* CHIPControllerTests.m */; }; + 99D466E12798936D0089A18F /* CHIPCommissioningParameters.h in Headers */ = {isa = PBXBuildFile; fileRef = 99D466E02798936D0089A18F /* CHIPCommissioningParameters.h */; settings = {ATTRIBUTES = (Public, ); }; }; B20252972459E34F00F97062 /* CHIP.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B202528D2459E34F00F97062 /* CHIP.framework */; }; B289D4212639C0D300D4E314 /* CHIPOnboardingPayloadParser.h in Headers */ = {isa = PBXBuildFile; fileRef = B289D41F2639C0D300D4E314 /* CHIPOnboardingPayloadParser.h */; settings = {ATTRIBUTES = (Public, ); }; }; B289D4222639C0D300D4E314 /* CHIPOnboardingPayloadParser.m in Sources */ = {isa = PBXBuildFile; fileRef = B289D4202639C0D300D4E314 /* CHIPOnboardingPayloadParser.m */; }; @@ -157,7 +159,9 @@ 998F286C26D55E10001846C6 /* CHIPKeypair.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CHIPKeypair.h; sourceTree = ""; }; 998F286E26D55EC5001846C6 /* CHIPP256KeypairBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CHIPP256KeypairBridge.h; sourceTree = ""; }; 998F287026D56940001846C6 /* CHIPP256KeypairBridge.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CHIPP256KeypairBridge.mm; sourceTree = ""; }; + 99AECC7F2798A57E00B6355B /* CHIPCommissioningParameters.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CHIPCommissioningParameters.m; sourceTree = ""; }; 99C65E0F267282F1003402F6 /* CHIPControllerTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CHIPControllerTests.m; sourceTree = ""; }; + 99D466E02798936D0089A18F /* CHIPCommissioningParameters.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CHIPCommissioningParameters.h; sourceTree = ""; }; B202528D2459E34F00F97062 /* CHIP.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = CHIP.framework; sourceTree = BUILT_PRODUCTS_DIR; }; B20252912459E34F00F97062 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; B20252962459E34F00F97062 /* CHIPTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CHIPTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -285,6 +289,8 @@ 997DED172695344800975E97 /* CHIPThreadOperationalDataset.h */, 2C8C8FBD253E0C2100797F05 /* CHIPPersistentStorageDelegateBridge.h */, 2C8C8FBF253E0C2100797F05 /* CHIPPersistentStorageDelegateBridge.mm */, + 99D466E02798936D0089A18F /* CHIPCommissioningParameters.h */, + 99AECC7F2798A57E00B6355B /* CHIPCommissioningParameters.m */, 2CB7163E252F731E0026E2BB /* CHIPDevicePairingDelegate.h */, 2CB71638252E8A7B0026E2BB /* CHIPDevicePairingDelegateBridge.h */, 2CB71639252E8A7B0026E2BB /* CHIPDevicePairingDelegateBridge.mm */, @@ -345,6 +351,7 @@ 2CB7163B252E8A7B0026E2BB /* CHIPDevicePairingDelegateBridge.h in Headers */, 1E16A90326B98AF100683C53 /* CHIPTestClustersObjc.h in Headers */, 2C1B027B2641DB4E00780EF1 /* CHIPOperationalCredentialsDelegate.h in Headers */, + 99D466E12798936D0089A18F /* CHIPCommissioningParameters.h in Headers */, B289D4212639C0D300D4E314 /* CHIPOnboardingPayloadParser.h in Headers */, 513DDB862761F69300DAA01A /* CHIPAttributeTLVValueDecoder_Internal.h in Headers */, 2CB7163F252F731E0026E2BB /* CHIPDevicePairingDelegate.h in Headers */, @@ -492,6 +499,7 @@ buildActionMask = 2147483647; files = ( 2C8C8FC2253E0C2100797F05 /* CHIPPersistentStorageDelegateBridge.mm in Sources */, + 99AECC802798A57F00B6355B /* CHIPCommissioningParameters.m in Sources */, 2CB7163C252E8A7C0026E2BB /* CHIPDevicePairingDelegateBridge.mm in Sources */, 997DED162695343400975E97 /* CHIPThreadOperationalDataset.mm in Sources */, 998F287126D56940001846C6 /* CHIPP256KeypairBridge.mm in Sources */, diff --git a/src/darwin/Framework/CHIP/CHIP.h b/src/darwin/Framework/CHIP/CHIP.h index 376ec2193a5a77..3fba51a63516b6 100644 --- a/src/darwin/Framework/CHIP/CHIP.h +++ b/src/darwin/Framework/CHIP/CHIP.h @@ -19,6 +19,7 @@ #import #import #import +#import #import #import #import diff --git a/src/darwin/Framework/CHIP/CHIPCommissioningParameters.h b/src/darwin/Framework/CHIP/CHIPCommissioningParameters.h new file mode 100644 index 00000000000000..5a2e65da00d13b --- /dev/null +++ b/src/darwin/Framework/CHIP/CHIPCommissioningParameters.h @@ -0,0 +1,51 @@ +/** + * + * Copyright (c) 2022 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 + +NS_ASSUME_NONNULL_BEGIN + +/** + * The class definition for the CHIPCommissioningParameters + * + */ +@interface CHIPCommissioningParameters : NSObject + +/** + * The CSRNonce + */ +@property (nonatomic, nullable, copy, readwrite) NSData * CSRNonce; +/** + * The AttestationNonce + */ +@property (nonatomic, nullable, copy, readwrite) NSData * attestationNonce; +/** + * The Wi-Fi SSID + */ +@property (nonatomic, nullable, copy, readwrite) NSData * wifiSSID; +/** + * The Wi-Fi Credentials + */ +@property (nonatomic, nullable, copy, readwrite) NSData * wifiCredentials; +/** + * The Thread operational dataset + */ +@property (nonatomic, nullable, copy, readwrite) NSData * threadOperationalDataset; + +@end + +NS_ASSUME_NONNULL_END diff --git a/src/darwin/Framework/CHIP/CHIPCommissioningParameters.m b/src/darwin/Framework/CHIP/CHIPCommissioningParameters.m new file mode 100644 index 00000000000000..a4ed0d8c257a04 --- /dev/null +++ b/src/darwin/Framework/CHIP/CHIPCommissioningParameters.m @@ -0,0 +1,26 @@ +/** + * + * Copyright (c) 2022 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 "CHIPCommissioningParameters.h" + +NS_ASSUME_NONNULL_BEGIN + +@implementation CHIPCommissioningParameters : NSObject + +@end + +NS_ASSUME_NONNULL_END diff --git a/src/darwin/Framework/CHIP/CHIPDeviceController.h b/src/darwin/Framework/CHIP/CHIPDeviceController.h index bd239b55de7cd8..0d53fb0e9a37bf 100644 --- a/src/darwin/Framework/CHIP/CHIPDeviceController.h +++ b/src/darwin/Framework/CHIP/CHIPDeviceController.h @@ -28,6 +28,7 @@ NS_ASSUME_NONNULL_BEGIN typedef void (^CHIPDeviceConnectionCallback)(CHIPDevice * _Nullable device, NSError * _Nullable error); +@class CHIPCommissioningParameters; @protocol CHIPDevicePairingDelegate; @protocol CHIPPersistentStorageDelegate; @protocol CHIPKeypair; @@ -49,6 +50,9 @@ typedef void (^CHIPDeviceConnectionCallback)(CHIPDevice * _Nullable device, NSEr error:(NSError * __autoreleasing *)error; - (BOOL)pairDevice:(uint64_t)deviceID onboardingPayload:(NSString *)onboardingPayload error:(NSError * __autoreleasing *)error; +- (BOOL)commissionDevice:(uint64_t)deviceId + commissioningParams:(CHIPCommissioningParameters *)commissioningParams + error:(NSError * __autoreleasing *)error; - (void)setListenPort:(uint16_t)port; - (BOOL)unpairDevice:(uint64_t)deviceID error:(NSError * __autoreleasing *)error; diff --git a/src/darwin/Framework/CHIP/CHIPDeviceController.mm b/src/darwin/Framework/CHIP/CHIPDeviceController.mm index 7b3a14afcb55e4..ff81c56cc7947b 100644 --- a/src/darwin/Framework/CHIP/CHIPDeviceController.mm +++ b/src/darwin/Framework/CHIP/CHIPDeviceController.mm @@ -16,6 +16,7 @@ */ #import "CHIPDeviceController.h" +#import "CHIPCommissioningParameters.h" #import "CHIPDevicePairingDelegateBridge.h" #import "CHIPDevice_Internal.h" #import "CHIPError_Internal.h" @@ -352,6 +353,47 @@ - (BOOL)pairDevice:(uint64_t)deviceID onboardingPayload:(NSString *)onboardingPa return success; } +- (BOOL)commissionDevice:(uint64_t)deviceId + commissioningParams:(CHIPCommissioningParameters *)commissioningParams + error:(NSError * __autoreleasing *)error +{ + __block CHIP_ERROR errorCode = CHIP_ERROR_INCORRECT_STATE; + __block BOOL success = NO; + if (![self isRunning]) { + success = ![self checkForError:errorCode logMsg:kErrorNotRunning error:error]; + return success; + } + dispatch_sync(_chipWorkQueue, ^{ + if ([self isRunning]) { + chip::Controller::CommissioningParameters params; + if (commissioningParams.CSRNonce) { + params.SetCSRNonce( + chip::ByteSpan((uint8_t *) commissioningParams.CSRNonce.bytes, commissioningParams.CSRNonce.length)); + } + if (commissioningParams.attestationNonce) { + params.SetAttestationNonce(chip::ByteSpan( + (uint8_t *) commissioningParams.attestationNonce.bytes, commissioningParams.attestationNonce.length)); + } + if (commissioningParams.threadOperationalDataset) { + params.SetThreadOperationalDataset(chip::ByteSpan((uint8_t *) commissioningParams.threadOperationalDataset.bytes, + commissioningParams.threadOperationalDataset.length)); + } + if (commissioningParams.wifiSSID && commissioningParams.wifiCredentials) { + chip::ByteSpan ssid((uint8_t *) commissioningParams.wifiSSID.bytes, commissioningParams.wifiSSID.length); + chip::ByteSpan credentials( + (uint8_t *) commissioningParams.wifiCredentials.bytes, commissioningParams.wifiCredentials.length); + chip::Controller::WiFiCredentials wifiCreds(ssid, credentials); + params.SetWiFiCredentials(wifiCreds); + } + + _operationalCredentialsDelegate->SetDeviceID(deviceId); + errorCode = self.cppCommissioner->Commission(deviceId, params); + } + success = ![self checkForError:errorCode logMsg:kErrorPairDevice error:error]; + }); + return success; +} + - (BOOL)unpairDevice:(uint64_t)deviceID error:(NSError * __autoreleasing *)error { __block CHIP_ERROR errorCode = CHIP_ERROR_INCORRECT_STATE; diff --git a/src/darwin/Framework/CHIP/CHIPDevicePairingDelegate.h b/src/darwin/Framework/CHIP/CHIPDevicePairingDelegate.h index 1c8293c67e0e1b..1c403911955f8f 100644 --- a/src/darwin/Framework/CHIP/CHIPDevicePairingDelegate.h +++ b/src/darwin/Framework/CHIP/CHIPDevicePairingDelegate.h @@ -45,16 +45,16 @@ typedef NS_ENUM(NSUInteger, CHIPPairingStatus) { - (void)onPairingComplete:(nullable NSError *)error; /** - * Notify the delegate when pairing is deleted + * Notify the delegate when commissioning is completed * */ -- (void)onPairingDeleted:(nullable NSError *)error; +- (void)onCommissioningComplete:(nullable NSError *)error; /** - * Notify the delegate when address is updated + * Notify the delegate when pairing is deleted * */ -- (void)onAddressUpdated:(nullable NSError *)error; +- (void)onPairingDeleted:(nullable NSError *)error; @end diff --git a/src/darwin/Framework/CHIP/CHIPDevicePairingDelegateBridge.h b/src/darwin/Framework/CHIP/CHIPDevicePairingDelegateBridge.h index c7ae4779ccb0c8..85dbf70eb8272a 100644 --- a/src/darwin/Framework/CHIP/CHIPDevicePairingDelegateBridge.h +++ b/src/darwin/Framework/CHIP/CHIPDevicePairingDelegateBridge.h @@ -38,6 +38,8 @@ class CHIPDevicePairingDelegateBridge : public chip::Controller::DevicePairingDe void OnPairingDeleted(CHIP_ERROR error) override; + void OnCommissioningComplete(chip::NodeId deviceId, CHIP_ERROR error) override; + void OnAddressUpdateComplete(chip::NodeId nodeId, CHIP_ERROR error) override; private: diff --git a/src/darwin/Framework/CHIP/CHIPDevicePairingDelegateBridge.mm b/src/darwin/Framework/CHIP/CHIPDevicePairingDelegateBridge.mm index 264726caca220c..c0a69fe17cb98d 100644 --- a/src/darwin/Framework/CHIP/CHIPDevicePairingDelegateBridge.mm +++ b/src/darwin/Framework/CHIP/CHIPDevicePairingDelegateBridge.mm @@ -95,17 +95,23 @@ } } -void CHIPDevicePairingDelegateBridge::OnAddressUpdateComplete(chip::NodeId nodeId, CHIP_ERROR error) +void CHIPDevicePairingDelegateBridge::OnCommissioningComplete(chip::NodeId nodeId, CHIP_ERROR error) { - NSLog(@"OnAddressUpdateComplete. Status %s", chip::ErrorStr(error)); + NSLog(@"DevicePairingDelegate Commissioning complete. NodeId %llu Status %s", nodeId, chip::ErrorStr(error)); id strongDelegate = mDelegate; - if ([strongDelegate respondsToSelector:@selector(onAddressUpdated:)]) { + if ([strongDelegate respondsToSelector:@selector(onCommissioningComplete:)]) { if (strongDelegate && mQueue) { dispatch_async(mQueue, ^{ NSError * nsError = [CHIPError errorForCHIPErrorCode:error]; - [strongDelegate onAddressUpdated:nsError]; + [strongDelegate onCommissioningComplete:nsError]; }); } } } + +void CHIPDevicePairingDelegateBridge::OnAddressUpdateComplete(chip::NodeId nodeId, CHIP_ERROR error) +{ + // Todo, is there any benefit of exposing this anymore? + NSLog(@"OnAddressUpdateComplete. Status %s", chip::ErrorStr(error)); +} diff --git a/src/darwin/Framework/CHIP/templates/clusters-tests.zapt b/src/darwin/Framework/CHIP/templates/clusters-tests.zapt index b510811b21b636..f76727aa9c7e06 100644 --- a/src/darwin/Framework/CHIP/templates/clusters-tests.zapt +++ b/src/darwin/Framework/CHIP/templates/clusters-tests.zapt @@ -90,6 +90,13 @@ CHIPDevice * GetConnectedDevice(void) _expectation = nil; } +- (void)onCommissioningComplete:(NSError *)error +{ + XCTAssertEqual(error.code, 0); + [_expectation fulfill]; + _expectation = nil; +} + - (void)onAddressUpdated:(NSError *)error { XCTAssertEqual(error.code, 0); diff --git a/src/darwin/Framework/CHIPTests/CHIPClustersTests.m b/src/darwin/Framework/CHIPTests/CHIPClustersTests.m index 835eb5fa2b4999..3ff04e01a59ac0 100644 --- a/src/darwin/Framework/CHIPTests/CHIPClustersTests.m +++ b/src/darwin/Framework/CHIPTests/CHIPClustersTests.m @@ -106,6 +106,13 @@ - (void)onPairingComplete:(NSError *)error _expectation = nil; } +- (void)onCommissioningComplete:(NSError *)error +{ + XCTAssertEqual(error.code, 0); + [_expectation fulfill]; + _expectation = nil; +} + - (void)onAddressUpdated:(NSError *)error { XCTAssertEqual(error.code, 0);