From 3540782d751d304365bd3f7713de3fc1bd58f60f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Szablowski?= <56074162+doublemis1@users.noreply.github.com> Date: Wed, 10 Nov 2021 07:20:23 +0100 Subject: [PATCH] Enchance controller discovery output (#11585) --- .../discover/DiscoverCommissionablesCommand.cpp | 13 +++++++------ ...ipCommissionableNodeController-ScriptBinding.cpp | 3 ++- .../python/ChipDeviceController-ScriptBinding.cpp | 3 ++- src/lib/dnssd/Discovery_ImplPlatform.cpp | 1 + src/lib/dnssd/Resolver.h | 7 ++++++- 5 files changed, 18 insertions(+), 9 deletions(-) diff --git a/examples/chip-tool/commands/discover/DiscoverCommissionablesCommand.cpp b/examples/chip-tool/commands/discover/DiscoverCommissionablesCommand.cpp index af7b276d4554a3..653bc23caef3e8 100644 --- a/examples/chip-tool/commands/discover/DiscoverCommissionablesCommand.cpp +++ b/examples/chip-tool/commands/discover/DiscoverCommissionablesCommand.cpp @@ -34,17 +34,18 @@ void DiscoverCommissionablesCommand::OnDiscoveredDevice(const chip::Dnssd::Disco Encoding::BytesToUppercaseHexString(nodeData.rotatingId, nodeData.rotatingIdLen, rotatingId, sizeof(rotatingId)); ChipLogProgress(Discovery, "Discovered Node: "); + ChipLogProgress(Discovery, "\tInstance name:\t\t%s", nodeData.instanceName); ChipLogProgress(Discovery, "\tHost name:\t\t%s", nodeData.hostName); ChipLogProgress(Discovery, "\tPort:\t\t\t%u", nodeData.port); ChipLogProgress(Discovery, "\tLong discriminator:\t%u", nodeData.longDiscriminator); ChipLogProgress(Discovery, "\tVendor ID:\t\t%u", nodeData.vendorId); ChipLogProgress(Discovery, "\tProduct ID:\t\t%u", nodeData.productId); - ChipLogProgress(Discovery, "\tCommissioning Mode\t%u", nodeData.commissioningMode); - ChipLogProgress(Discovery, "\tDevice Type\t\t%u", nodeData.deviceType); - ChipLogProgress(Discovery, "\tDevice Name\t\t%s", nodeData.deviceName); - ChipLogProgress(Discovery, "\tRotating Id\t\t%s", rotatingId); - ChipLogProgress(Discovery, "\tPairing Instruction\t%s", nodeData.pairingInstruction); - ChipLogProgress(Discovery, "\tPairing Hint\t\t0x%x", nodeData.pairingHint); + ChipLogProgress(Discovery, "\tCommissioning Mode:\t%u", nodeData.commissioningMode); + ChipLogProgress(Discovery, "\tDevice Type:\t\t%u", nodeData.deviceType); + ChipLogProgress(Discovery, "\tDevice Name:\t\t%s", nodeData.deviceName); + ChipLogProgress(Discovery, "\tRotating Id:\t\t%s", rotatingId); + ChipLogProgress(Discovery, "\tPairing Instruction:\t%s", nodeData.pairingInstruction); + ChipLogProgress(Discovery, "\tPairing Hint:\t\t%u", nodeData.pairingHint); for (int i = 0; i < nodeData.numIPs; i++) { char buf[chip::Inet::IPAddress::kMaxStringLength]; diff --git a/src/controller/python/ChipCommissionableNodeController-ScriptBinding.cpp b/src/controller/python/ChipCommissionableNodeController-ScriptBinding.cpp index c802ded0a16bb2..5c2b76296b7e61 100644 --- a/src/controller/python/ChipCommissionableNodeController-ScriptBinding.cpp +++ b/src/controller/python/ChipCommissionableNodeController-ScriptBinding.cpp @@ -86,6 +86,7 @@ void pychip_CommissionableNodeController_PrintDiscoveredCommissioners( Encoding::BytesToUppercaseHexString(dnsSdInfo->rotatingId, dnsSdInfo->rotatingIdLen, rotatingId, sizeof(rotatingId)); ChipLogProgress(Discovery, "Commissioner %d", i); + ChipLogProgress(Discovery, "\tInstance name:\t\t%s", dnsSdInfo->instanceName); ChipLogProgress(Discovery, "\tHost name:\t\t%s", dnsSdInfo->hostName); ChipLogProgress(Discovery, "\tPort:\t\t\t%u", dnsSdInfo->port); ChipLogProgress(Discovery, "\tLong discriminator:\t%u", dnsSdInfo->longDiscriminator); @@ -96,7 +97,7 @@ void pychip_CommissionableNodeController_PrintDiscoveredCommissioners( ChipLogProgress(Discovery, "\tDevice Name\t\t%s", dnsSdInfo->deviceName); ChipLogProgress(Discovery, "\tRotating Id\t\t%s", rotatingId); ChipLogProgress(Discovery, "\tPairing Instruction\t%s", dnsSdInfo->pairingInstruction); - ChipLogProgress(Discovery, "\tPairing Hint\t\t0x%x", dnsSdInfo->pairingHint); + ChipLogProgress(Discovery, "\tPairing Hint\t\t%u", dnsSdInfo->pairingHint); if (dnsSdInfo->GetMrpRetryIntervalIdle().HasValue()) { ChipLogProgress(Discovery, "\tMrp Interval idle\t%u", dnsSdInfo->GetMrpRetryIntervalIdle().Value()); diff --git a/src/controller/python/ChipDeviceController-ScriptBinding.cpp b/src/controller/python/ChipDeviceController-ScriptBinding.cpp index 9405d7bba204ad..c38373d1c5fa52 100644 --- a/src/controller/python/ChipDeviceController-ScriptBinding.cpp +++ b/src/controller/python/ChipDeviceController-ScriptBinding.cpp @@ -407,6 +407,7 @@ void pychip_DeviceController_PrintDiscoveredDevices(chip::Controller::DeviceComm Encoding::BytesToUppercaseHexString(dnsSdInfo->rotatingId, dnsSdInfo->rotatingIdLen, rotatingId, sizeof(rotatingId)); ChipLogProgress(Discovery, "Commissionable Node %d", i); + ChipLogProgress(Discovery, "\tInstance name:\t\t%s", dnsSdInfo->instanceName); ChipLogProgress(Discovery, "\tHost name:\t\t%s", dnsSdInfo->hostName); ChipLogProgress(Discovery, "\tPort:\t\t\t%u", dnsSdInfo->port); ChipLogProgress(Discovery, "\tLong discriminator:\t%u", dnsSdInfo->longDiscriminator); @@ -417,7 +418,7 @@ void pychip_DeviceController_PrintDiscoveredDevices(chip::Controller::DeviceComm ChipLogProgress(Discovery, "\tDevice Name\t\t%s", dnsSdInfo->deviceName); ChipLogProgress(Discovery, "\tRotating Id\t\t%s", rotatingId); ChipLogProgress(Discovery, "\tPairing Instruction\t%s", dnsSdInfo->pairingInstruction); - ChipLogProgress(Discovery, "\tPairing Hint\t\t0x%x", dnsSdInfo->pairingHint); + ChipLogProgress(Discovery, "\tPairing Hint\t\t%u", dnsSdInfo->pairingHint); if (dnsSdInfo->GetMrpRetryIntervalIdle().HasValue()) { ChipLogProgress(Discovery, "\tMrp Interval idle\t%u", dnsSdInfo->GetMrpRetryIntervalIdle().Value()); diff --git a/src/lib/dnssd/Discovery_ImplPlatform.cpp b/src/lib/dnssd/Discovery_ImplPlatform.cpp index 012412d587fb93..8a289a82fa75d4 100644 --- a/src/lib/dnssd/Discovery_ImplPlatform.cpp +++ b/src/lib/dnssd/Discovery_ImplPlatform.cpp @@ -514,6 +514,7 @@ void DiscoveryImplPlatform::HandleNodeResolve(void * context, DnssdService * res DiscoveryImplPlatform * mgr = static_cast(context); DiscoveredNodeData data; Platform::CopyString(data.hostName, result->mHostName); + Platform::CopyString(data.instanceName, result->mName); if (result->mAddress.HasValue() && data.numIPs < DiscoveredNodeData::kMaxIPAddresses) { diff --git a/src/lib/dnssd/Resolver.h b/src/lib/dnssd/Resolver.h index 24d0f1a27e821c..73ab5120f39024 100644 --- a/src/lib/dnssd/Resolver.h +++ b/src/lib/dnssd/Resolver.h @@ -126,6 +126,7 @@ struct DiscoveredNodeData } DiscoveredNodeData() { Reset(); } bool IsHost(const char * host) const { return strcmp(host, hostName) == 0; } + bool IsInstanceName(const char * instance) const { return strcmp(instance, instanceName) == 0; } bool IsValid() const { return !IsHost("") && ipAddress[0] != chip::Inet::IPAddress::Any; } Optional GetMrpRetryIntervalIdle() const @@ -175,12 +176,16 @@ struct DiscoveredNodeData } if (pairingHint > 0) { - ChipLogDetail(Discovery, "\tPairing Hint: 0x%x", pairingHint); + ChipLogDetail(Discovery, "\tPairing Hint: %u", pairingHint); } if (!IsHost("")) { ChipLogDetail(Discovery, "\tHostname: %s", hostName); } + if (!IsInstanceName("")) + { + ChipLogDetail(Discovery, "\tInstance Name: %s", instanceName); + } for (int j = 0; j < numIPs; j++) { #if CHIP_DETAIL_LOGGING