Skip to content

Commit

Permalink
Avoid errors when using on-network commissioning
Browse files Browse the repository at this point in the history
When on network commissioning is used from Python we currently don't
stop discovery even though we already found a device. Future devices
found won't be processed, so it is fine to stop discovery of
commissionable nodes at this point.

Also avoid "Unknown filter type; all matches will fail" errors in the
log: If the filter type is set to None, it wasn't the SetUpCodePairer
which set up the discovery. Avoid printing errors in this case.

A potential alternative to this would be to skip notifying the
SetUpCodePairer in DeviceCommissioner::OnNodeDiscovered in this case.
  • Loading branch information
agners committed Jun 13, 2024
1 parent bbd3419 commit 45e6568
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/controller/SetUpCodePairer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,9 @@ bool SetUpCodePairer::NodeMatchesCurrentFilter(const Dnssd::DiscoveredNodeData &
case Dnssd::DiscoveryFilterType::kLongDiscriminator:
discriminatorMatches = (nodeData.longDiscriminator == mCurrentFilter.code);
break;
case Dnssd::DiscoveryFilterType::kNone:
ChipLogDetail(Controller, "Filter type none; all matches will fail");
return false;
default:
ChipLogError(Controller, "Unknown filter type; all matches will fail");
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ void ScriptPairingDeviceDiscoveryDelegate::OnDiscoveredDevice(const Dnssd::Commi
nodeData.ipAddress[0].ToString(buf);
ChipLogProgress(chipTool, "Discovered Device: %s:%u", buf, port);

// Stop active discovery.
mActiveDeviceCommissioner->StopCommissionableDiscovery();

// Cancel discovery timer.
chip::DeviceLayer::SystemLayer().CancelTimer(OnDiscoveredTimeout, this);

Expand Down

0 comments on commit 45e6568

Please sign in to comment.