Skip to content

Commit

Permalink
Improve discovery logging in SetUpCodePairer. (#26534)
Browse files Browse the repository at this point in the history
We should log why we are ignoring discovered devices.
  • Loading branch information
bzbarsky-apple authored and pull[bot] committed May 24, 2023
1 parent 6dcfa66 commit b9e638c
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/controller/SetUpCodePairer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,33 +309,44 @@ bool SetUpCodePairer::NodeMatchesCurrentFilter(const Dnssd::DiscoveredNodeData &
{
if (nodeData.commissionData.commissioningMode == 0)
{
ChipLogProgress(Controller, "Discovered device does not have an open commissioning window.");
return false;
}

// The advertisement may not include a vendor id.
if (IdIsPresent(mPayloadVendorID) && IdIsPresent(nodeData.commissionData.vendorId) &&
mPayloadVendorID != nodeData.commissionData.vendorId)
{
ChipLogProgress(Controller, "Discovered device does not match our vendor id.");
return false;
}

// The advertisement may not include a product id.
if (IdIsPresent(mPayloadProductID) && IdIsPresent(nodeData.commissionData.productId) &&
mPayloadProductID != nodeData.commissionData.productId)
{
ChipLogProgress(Controller, "Discovered device does not match our product id.");
return false;
}

bool discriminatorMatches = false;
switch (mCurrentFilter.type)
{
case Dnssd::DiscoveryFilterType::kShortDiscriminator:
return ((nodeData.commissionData.longDiscriminator >> 8) & 0x0F) == mCurrentFilter.code;
discriminatorMatches = (((nodeData.commissionData.longDiscriminator >> 8) & 0x0F) == mCurrentFilter.code);
break;
case Dnssd::DiscoveryFilterType::kLongDiscriminator:
return nodeData.commissionData.longDiscriminator == mCurrentFilter.code;
discriminatorMatches = (nodeData.commissionData.longDiscriminator == mCurrentFilter.code);
break;
default:
ChipLogError(Controller, "Unknown filter type; all matches will fail");
return false;
}
return false;
if (!discriminatorMatches)
{
ChipLogProgress(Controller, "Discovered device does not match our discriminator.");
}
return discriminatorMatches;
}

void SetUpCodePairer::NotifyCommissionableDeviceDiscovered(const Dnssd::DiscoveredNodeData & nodeData)
Expand Down

0 comments on commit b9e638c

Please sign in to comment.