diff --git a/src/lib/mdns/Discovery_ImplPlatform.cpp b/src/lib/mdns/Discovery_ImplPlatform.cpp index c92f0885b6cea5..8bc94ec62854a9 100644 --- a/src/lib/mdns/Discovery_ImplPlatform.cpp +++ b/src/lib/mdns/Discovery_ImplPlatform.cpp @@ -512,12 +512,7 @@ void DiscoveryImplPlatform::HandleNodeIdResolve(void * context, MdnsService * re nodeData.mAddress = result->mAddress.ValueOr({}); nodeData.mPort = result->mPort; -#if CHIP_PROGRESS_LOGGING - char addrBuffer[Inet::kMaxIPAddressStringLength + 1]; - nodeData.mAddress.ToString(addrBuffer); -#endif // CHIP_PROGRESS_LOGGING - ChipLogProgress(Discovery, "Node ID resolved for 0x" ChipLogFormatX64 " to %s", ChipLogValueX64(nodeData.mPeerId.GetNodeId()), - addrBuffer); + nodeData.LogNodeIdResolved(); mgr->mResolverDelegate->OnNodeIdResolved(nodeData); } diff --git a/src/lib/mdns/Resolver.h b/src/lib/mdns/Resolver.h index a9b8b60b041ac0..8e70155cb844a3 100644 --- a/src/lib/mdns/Resolver.h +++ b/src/lib/mdns/Resolver.h @@ -19,6 +19,7 @@ #include +#include "lib/support/logging/CHIPLogging.h" #include #include #include @@ -30,6 +31,18 @@ namespace Mdns { struct ResolvedNodeData { + void LogNodeIdResolved() + { +#if CHIP_PROGRESS_LOGGING + char addrBuffer[Inet::kMaxIPAddressStringLength + 1]; + mAddress.ToString(addrBuffer); + // Would be nice to log the interface id, but sorting out how to do so + // across our differnet InterfaceId implementations is a pain. + ChipLogProgress(Discovery, "Node ID resolved for 0x" ChipLogFormatX64 " to [%s]:%" PRIu16, + ChipLogValueX64(mPeerId.GetNodeId()), addrBuffer, mPort); +#endif // CHIP_PROGRESS_LOGGING + } + PeerId mPeerId; Inet::InterfaceId mInterfaceId; Inet::IPAddress mAddress; diff --git a/src/lib/mdns/Resolver_ImplMinimalMdns.cpp b/src/lib/mdns/Resolver_ImplMinimalMdns.cpp index 26a33faec498bd..3b4fb569d53513 100644 --- a/src/lib/mdns/Resolver_ImplMinimalMdns.cpp +++ b/src/lib/mdns/Resolver_ImplMinimalMdns.cpp @@ -308,6 +308,7 @@ void PacketDataReporter::OnComplete() } else if (mDiscoveryType == DiscoveryType::kOperational && mHasIP && mHasNodePort) { + mNodeData.LogNodeIdResolved(); mDelegate->OnNodeIdResolved(mNodeData); } }