Skip to content

Commit

Permalink
Enchance controller discovery output (project-chip#11585)
Browse files Browse the repository at this point in the history
  • Loading branch information
doublemis1 authored and PSONALl committed Dec 2, 2021
1 parent 6fe7f1b commit 329b389
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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());
Expand Down
3 changes: 2 additions & 1 deletion src/controller/python/ChipDeviceController-ScriptBinding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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());
Expand Down
1 change: 1 addition & 0 deletions src/lib/dnssd/Discovery_ImplPlatform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,7 @@ void DiscoveryImplPlatform::HandleNodeResolve(void * context, DnssdService * res
DiscoveryImplPlatform * mgr = static_cast<DiscoveryImplPlatform *>(context);
DiscoveredNodeData data;
Platform::CopyString(data.hostName, result->mHostName);
Platform::CopyString(data.instanceName, result->mName);

if (result->mAddress.HasValue() && data.numIPs < DiscoveredNodeData::kMaxIPAddresses)
{
Expand Down
7 changes: 6 additions & 1 deletion src/lib/dnssd/Resolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint32_t> GetMrpRetryIntervalIdle() const
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 329b389

Please sign in to comment.