Skip to content

Commit

Permalink
Use provided PIN for opening commissioning window if caller used kTok…
Browse files Browse the repository at this point in the history
…enWithProvidedPIN (#13147)

* Use provided PIN for opening commissioning window if requested

* update doc
  • Loading branch information
pan-apple authored and pull[bot] committed Jul 11, 2023
1 parent 40ce75f commit 4066d50
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/controller/CHIPDeviceController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,7 @@ CHIP_ERROR DeviceController::OpenCommissioningWindowWithCallback(NodeId deviceId
break;
case 2:
mCommissioningWindowOption = CommissioningWindowOption::kTokenWithProvidedPIN;
mSetupPayload.setUpPINCode = mSuggestedSetUpPINCode;
break;
default:
ChipLogError(Controller, "Invalid Pairing Window option");
Expand Down
8 changes: 6 additions & 2 deletions src/controller/CHIPDeviceController.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ class DLL_EXPORT DeviceController : public SessionReleaseDelegate,
* @param[in] option The commissioning window can be opened using the original setup code, or an
* onboarding token can be generated using a random setup PIN code (or with
* the PIN code provied in the setupPayload).
* @param[out] payload The generated setup payload.
* @param[in,out] payload The generated setup payload.
* - The payload is generated only if the user didn't ask for using the original setup code.
* - If the user asked to use the provided setup PIN, the PIN must be provided as part of
* this payload
Expand All @@ -279,7 +279,10 @@ class DLL_EXPORT DeviceController : public SessionReleaseDelegate,
CHIP_ERROR OpenCommissioningWindow(NodeId deviceId, uint16_t timeout, uint16_t iteration, uint16_t discriminator,
uint8_t option, SetupPayload & payload)
{
return OpenCommissioningWindowWithCallback(deviceId, timeout, iteration, discriminator, option, nullptr);
mSuggestedSetUpPINCode = payload.setUpPINCode;
ReturnErrorOnFailure(OpenCommissioningWindowWithCallback(deviceId, timeout, iteration, discriminator, option, nullptr));
payload = mSetupPayload;
return CHIP_NO_ERROR;
}

/**
Expand Down Expand Up @@ -405,6 +408,7 @@ class DLL_EXPORT DeviceController : public SessionReleaseDelegate,
Callback::Callback<OnOpenCommissioningWindow> * mCommissioningWindowCallback = nullptr;
SetupPayload mSetupPayload;
NodeId mDeviceWithCommissioningWindowOpen;
uint32_t mSuggestedSetUpPINCode = 0;

uint16_t mCommissioningWindowTimeout;
uint16_t mCommissioningWindowIteration;
Expand Down

0 comments on commit 4066d50

Please sign in to comment.