Skip to content

Commit

Permalink
Fix short code on dnssd advertising and chip-tool (#12319)
Browse files Browse the repository at this point in the history
* Fix short code on dnssd advertising and chip-tool

The short discriminator is the UPPER four bits of the discriminator.

* Update src/controller/SetUpCodePairer.cpp

Co-authored-by: Tennessee Carmel-Veilleux <[email protected]>

* Update src/app/server/Dnssd.cpp

Co-authored-by: Tennessee Carmel-Veilleux <[email protected]>

Co-authored-by: Justin Wood <[email protected]>
Co-authored-by: Tennessee Carmel-Veilleux <[email protected]>
  • Loading branch information
3 people authored and pull[bot] committed Jan 24, 2022
1 parent e3bf329 commit 1743980
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/app/server/Dnssd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ CHIP_ERROR DnssdServer::Advertise(bool commissionableNode, chip::Dnssd::Commissi
ChipLogError(Discovery, "Setup discriminator not known. Using a default.");
value = 840;
}
advertiseParameters.SetShortDiscriminator(static_cast<uint8_t>(value & 0xFF)).SetLongDiscriminator(value);
advertiseParameters.SetShortDiscriminator(static_cast<uint8_t>((value >> 8) & 0x0F)).SetLongDiscriminator(value);

if (DeviceLayer::ConfigurationMgr().IsCommissionableDeviceTypeEnabled() &&
DeviceLayer::ConfigurationMgr().GetDeviceTypeId(value) == CHIP_NO_ERROR)
Expand Down
3 changes: 2 additions & 1 deletion src/controller/SetUpCodePairer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ CHIP_ERROR SetUpCodePairer::Connect(RendezvousInformationFlag rendezvousInformat

if (searchOverAll || rendezvousInformation == RendezvousInformationFlag::kOnNetwork)
{
if (CHIP_NO_ERROR == (err = StartDiscoverOverIP(discriminator, isShort)))
if (CHIP_NO_ERROR ==
(err = StartDiscoverOverIP(isShort ? static_cast<uint16_t>((discriminator >> 8) & 0x0F) : discriminator, isShort)))
{
isRunning = true;
}
Expand Down

0 comments on commit 1743980

Please sign in to comment.