Skip to content

Commit

Permalink
[ICD] Skip Get RegistrationInfo when parameter is already added (#31123)
Browse files Browse the repository at this point in the history
* Skip Get RegistrationInfo when param is already added

* Remove onICDRegistrationInfoRequired callback in chip-tool

* Restyled by clang-format

* Add comment

* Restyled by whitespace

---------

Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
2 people authored and pull[bot] committed Apr 11, 2024
1 parent 57bcfe0 commit 682e255
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
9 changes: 2 additions & 7 deletions examples/chip-tool/commands/pairing/PairingCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,13 +403,6 @@ void PairingCommand::OnCommissioningComplete(NodeId nodeId, CHIP_ERROR err)
SetCommandExitStatus(err);
}

void PairingCommand::OnICDRegistrationInfoRequired()
{
// Since we compute our ICD Registration info up front, we can call ICDRegistrationInfoReady() directly.
CurrentCommissioner().ICDRegistrationInfoReady();
mDeviceIsICD = true;
}

void PairingCommand::OnICDRegistrationComplete(NodeId nodeId, uint32_t icdCounter)
{
char icdSymmetricKeyHex[chip::Crypto::kAES_CCM128_Key_Length * 2 + 1];
Expand Down Expand Up @@ -437,6 +430,8 @@ void PairingCommand::OnICDRegistrationComplete(NodeId nodeId, uint32_t icdCounte
return;
}

mDeviceIsICD = true;

ChipLogProgress(chipTool, "Saved ICD Symmetric key for " ChipLogFormatX64, ChipLogValueX64(nodeId));
ChipLogProgress(chipTool,
"ICD Registration Complete for device " ChipLogFormatX64 " / Check-In NodeID: " ChipLogFormatX64
Expand Down
1 change: 0 additions & 1 deletion examples/chip-tool/commands/pairing/PairingCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ class PairingCommand : public CHIPCommand,
void OnPairingComplete(CHIP_ERROR error) override;
void OnPairingDeleted(CHIP_ERROR error) override;
void OnCommissioningComplete(NodeId deviceId, CHIP_ERROR error) override;
void OnICDRegistrationInfoRequired() override;
void OnICDRegistrationComplete(NodeId deviceId, uint32_t icdCounter) override;

/////////// DeviceDiscoveryDelegate Interface /////////
Expand Down
5 changes: 5 additions & 0 deletions src/controller/AutoCommissioner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,11 @@ CommissioningStage AutoCommissioner::GetNextCommissioningStageInternal(Commissio
case CommissioningStage::kConfigureTrustedTimeSource:
if (mNeedIcdRegistration)
{
if (mParams.GetICDCheckInNodeId().HasValue() && mParams.GetICDMonitoredSubject().HasValue() &&
mParams.GetICDSymmetricKey().HasValue())
{
return CommissioningStage::kICDRegistration;
}
return CommissioningStage::kICDGetRegistrationInfo;
}
return GetNextCommissioningStageInternal(CommissioningStage::kICDSendStayActive, lastErr);
Expand Down
2 changes: 1 addition & 1 deletion src/controller/DevicePairingDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class DLL_EXPORT DevicePairingDelegate
* using CommissioningDelegate.SetCommissioningParameters(), and then call DeviceCommissioner.ICDRegistrationInfoReady()
* in order to resume the commissioning process.
*
* The implementation may set the credentials before start commissioning, and call ICDRegistrationInfoReady() directly.
* Not called if the ICD registration info is provided up front.
*/
virtual void OnICDRegistrationInfoRequired() {}

Expand Down

0 comments on commit 682e255

Please sign in to comment.