Skip to content

Commit

Permalink
Expose csrNonce param to pairDevice() in Darwin
Browse files Browse the repository at this point in the history
  • Loading branch information
austinh0 committed Jun 29, 2021
1 parent e5fef37 commit bdf1308
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ - (void)handleRendezVousBLE:(uint16_t)discriminator setupPINCode:(uint32_t)setup
{
NSError * error;
uint64_t deviceID = CHIPGetNextAvailableDeviceID();
if ([self.chipController pairDevice:deviceID discriminator:discriminator setupPINCode:setupPINCode error:&error]) {
if ([self.chipController pairDevice:deviceID discriminator:discriminator setupPINCode:setupPINCode csrNonce:nil error:&error]) {
deviceID++;
CHIPSetNextAvailableDeviceID(deviceID);
}
Expand Down
1 change: 1 addition & 0 deletions src/darwin/Framework/CHIP/CHIPDeviceController.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ NS_ASSUME_NONNULL_BEGIN
- (BOOL)pairDevice:(uint64_t)deviceID
discriminator:(uint16_t)discriminator
setupPINCode:(uint32_t)setupPINCode
csrNonce:(nullable NSData *)csrNonce
error:(NSError * __autoreleasing *)error;

- (BOOL)pairDevice:(uint64_t)deviceID
Expand Down
7 changes: 6 additions & 1 deletion src/darwin/Framework/CHIP/CHIPDeviceController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ - (NSNumber *)_getControllerNodeId
- (BOOL)pairDevice:(uint64_t)deviceID
discriminator:(uint16_t)discriminator
setupPINCode:(uint32_t)setupPINCode
csrNonce:(nullable NSData *)csrNonce
error:(NSError * __autoreleasing *)error
{
__block CHIP_ERROR errorCode = CHIP_ERROR_INCORRECT_STATE;
Expand All @@ -224,6 +225,10 @@ - (BOOL)pairDevice:(uint64_t)deviceID
chip::RendezvousParameters params
= chip::RendezvousParameters().SetSetupPINCode(setupPINCode).SetDiscriminator(discriminator);

if (csrNonce != nil) {
params = params.SetCSRNonce(chip::ByteSpan((const uint8_t *) csrNonce.bytes, csrNonce.length));
}

if ([self isRunning]) {
_operationalCredentialsDelegate->SetDeviceID(deviceID);
errorCode = self.cppCommissioner->PairDevice(deviceID, params);
Expand Down Expand Up @@ -306,7 +311,7 @@ - (BOOL)pairDevice:(uint64_t)deviceID
uint16_t discriminator = setupPayload.discriminator.unsignedShortValue;
uint32_t setupPINCode = setupPayload.setUpPINCode.unsignedIntValue;
_operationalCredentialsDelegate->SetDeviceID(deviceID);
didSucceed = [self pairDevice:deviceID discriminator:discriminator setupPINCode:setupPINCode error:error];
didSucceed = [self pairDevice:deviceID discriminator:discriminator setupPINCode:setupPINCode csrNonce:nil error:error];
} else {
CHIP_LOG_ERROR("Failed to create CHIPSetupPayload for pairing with error %@", *error);
}
Expand Down

0 comments on commit bdf1308

Please sign in to comment.