Skip to content

Commit

Permalink
[chip-tool] Add discover-once parameter to DiscoverCommissionablesCom…
Browse files Browse the repository at this point in the history
…mand such that it only returns a single result by default to mimick what the test harness is doing (#25223)
  • Loading branch information
vivien-apple authored and pull[bot] committed Sep 18, 2023
1 parent d39f9ab commit 3781063
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ void DiscoverCommissionablesCommandBase::OnDiscoveredDevice(const chip::Dnssd::D
{
nodeData.LogDetail();
LogErrorOnFailure(RemoteDataModelLogger::LogDiscoveredNodeData(nodeData));
SetCommandExitStatus(CHIP_NO_ERROR);

if (mDiscoverOnce.ValueOr(true))
{
CurrentCommissioner().StopCommissionableDiscovery();
SetCommandExitStatus(CHIP_NO_ERROR);
}
}

CHIP_ERROR DiscoverCommissionablesCommand::RunCommand()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,19 @@ class DiscoverCommissionablesCommandBase : public CHIPCommand, public chip::Cont
public:
DiscoverCommissionablesCommandBase(const char * name, CredentialIssuerCommands * credsIssuerConfig) :
CHIPCommand(name, credsIssuerConfig)
{}
{
AddArgument("discover-once", 0, 1, &mDiscoverOnce,
"Boolean indicating whether to stop discovery after the first result. Defaults to true.");
}

/////////// DeviceDiscoveryDelegate Interface /////////
void OnDiscoveredDevice(const chip::Dnssd::DiscoveredNodeData & nodeData) override;

/////////// CHIPCommand Interface /////////
chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(30); }

private:
chip::Optional<bool> mDiscoverOnce;
};

class DiscoverCommissionablesCommand : public DiscoverCommissionablesCommandBase
Expand Down

0 comments on commit 3781063

Please sign in to comment.