Skip to content

Commit bb87db3

Browse files
authored
Avoid errors when using on-network commissioning (#33880)
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.
1 parent 4a16aaa commit bb87db3

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/controller/SetUpCodePairer.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,9 @@ bool SetUpCodePairer::NodeMatchesCurrentFilter(const Dnssd::DiscoveredNodeData &
377377
case Dnssd::DiscoveryFilterType::kLongDiscriminator:
378378
discriminatorMatches = (nodeData.longDiscriminator == mCurrentFilter.code);
379379
break;
380+
case Dnssd::DiscoveryFilterType::kNone:
381+
ChipLogDetail(Controller, "Filter type none; all matches will fail");
382+
return false;
380383
default:
381384
ChipLogError(Controller, "Unknown filter type; all matches will fail");
382385
return false;

src/controller/python/ChipDeviceController-ScriptPairingDeviceDiscoveryDelegate.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ void ScriptPairingDeviceDiscoveryDelegate::OnDiscoveredDevice(const Dnssd::Commi
3232
nodeData.ipAddress[0].ToString(buf);
3333
ChipLogProgress(chipTool, "Discovered Device: %s:%u", buf, port);
3434

35+
// Stop active discovery.
36+
mActiveDeviceCommissioner->StopCommissionableDiscovery();
37+
3538
// Cancel discovery timer.
3639
chip::DeviceLayer::SystemLayer().CancelTimer(OnDiscoveredTimeout, this);
3740

0 commit comments

Comments
 (0)