diff --git a/src/app/server/Dnssd.cpp b/src/app/server/Dnssd.cpp index a9c1c6b78d006a..f4faaa79536840 100644 --- a/src/app/server/Dnssd.cpp +++ b/src/app/server/Dnssd.cpp @@ -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(value & 0xFF)).SetLongDiscriminator(value); + advertiseParameters.SetShortDiscriminator(static_cast((value >> 8) & 0x0F)).SetLongDiscriminator(value); if (DeviceLayer::ConfigurationMgr().IsCommissionableDeviceTypeEnabled() && DeviceLayer::ConfigurationMgr().GetDeviceTypeId(value) == CHIP_NO_ERROR) diff --git a/src/controller/SetUpCodePairer.cpp b/src/controller/SetUpCodePairer.cpp index f4b7ac3ae6cfba..6763e7aa946075 100644 --- a/src/controller/SetUpCodePairer.cpp +++ b/src/controller/SetUpCodePairer.cpp @@ -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((discriminator >> 8) & 0x0F) : discriminator, isShort))) { isRunning = true; }