From f84259f64c05afe354246bd0de7cc37af39197b0 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Mon, 15 May 2023 21:45:27 -0400 Subject: [PATCH] Improve discovery logging in SetUpCodePairer. (#26534) We should log why we are ignoring discovered devices. --- src/controller/SetUpCodePairer.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/controller/SetUpCodePairer.cpp b/src/controller/SetUpCodePairer.cpp index ee5a31365ad82c..de32224c4fc9c6 100644 --- a/src/controller/SetUpCodePairer.cpp +++ b/src/controller/SetUpCodePairer.cpp @@ -309,6 +309,7 @@ bool SetUpCodePairer::NodeMatchesCurrentFilter(const Dnssd::DiscoveredNodeData & { if (nodeData.commissionData.commissioningMode == 0) { + ChipLogProgress(Controller, "Discovered device does not have an open commissioning window."); return false; } @@ -316,6 +317,7 @@ bool SetUpCodePairer::NodeMatchesCurrentFilter(const Dnssd::DiscoveredNodeData & if (IdIsPresent(mPayloadVendorID) && IdIsPresent(nodeData.commissionData.vendorId) && mPayloadVendorID != nodeData.commissionData.vendorId) { + ChipLogProgress(Controller, "Discovered device does not match our vendor id."); return false; } @@ -323,19 +325,28 @@ bool SetUpCodePairer::NodeMatchesCurrentFilter(const Dnssd::DiscoveredNodeData & 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)