Skip to content

Commit

Permalink
Make SetUpCodePairer only browse for nodes that are in commissioning …
Browse files Browse the repository at this point in the history
…mode.

If we don't browse for the _CM subtype, we might find (and ignore) a
node that's not yet in commissioning mode (but has extended
commissioning discovery turned on) and when it enters commissioning
mode we won't notice because there won't be any new service instances
of the sort we are looking for, just TXT record changes.
  • Loading branch information
bzbarsky-apple committed Apr 13, 2022
1 parent be946b0 commit a0cfcbe
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/controller/SetUpCodePairer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,23 @@ CHIP_ERROR SetUpCodePairer::StartDiscoverOverIP(SetupPayload & payload)
: Dnssd::DiscoveryFilterType::kLongDiscriminator;
currentFilter.code =
payload.isShortDiscriminator ? static_cast<uint16_t>((payload.discriminator >> 8) & 0x0F) : payload.discriminator;

// We're going to ensure that anything we discover matches currentFilter
// before we use it, which will do our discriminator checks for us.
//
// For the actual discovery, use a "commissionable nodes only" subtype.
// This avoids a problem we can run into if we use the discriminator-based
// subtypes where we discover a (possibly stale) advertisement for a
// non-commissionable (CM=0) node, then it becomes commissionable but we
// don't notice that because it does not add or remove SRV records, just
// updates TXT records. But in this situation a PTR record _will_ get
// added, so that's what we look for.
Dnssd::DiscoveryFilter filter;
filter.type = Dnssd::DiscoveryFilterType::kCommissioningMode;

// Handle possibly-sync callbacks.
mWaitingForDiscovery[kIPTransport] = true;
CHIP_ERROR err = mCommissioner->DiscoverCommissionableNodes(currentFilter);
CHIP_ERROR err = mCommissioner->DiscoverCommissionableNodes(filter);
if (err != CHIP_NO_ERROR)
{
mWaitingForDiscovery[kIPTransport] = false;
Expand Down

0 comments on commit a0cfcbe

Please sign in to comment.