Skip to content

Commit

Permalink
Incorporating chrisdecenzo's comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sharadb-amazon committed Aug 5, 2021
1 parent 997ac1f commit 6a8f6b1
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 33 deletions.
2 changes: 1 addition & 1 deletion BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") {
deps += [ ":linux_tv_app" ]
}
if (enable_linux_tv_casting_app_build) {
deps += [ ":linux_tv_app" ]
deps += [ ":linux_tv_casting_app" ]
}
if (enable_linux_bridge_app_build) {
deps += [ ":linux_bridge_app" ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ void DiscoverCommissionersCommand::Shutdown()
const Mdns::DiscoveredNodeData * commissioner = mCommissionableNodeController.GetDiscoveredCommissioner(i);
if (commissioner != nullptr)
{
printf("Discovered Commisioner #%d\n", ++commissionerCount);
commissioner->Print();
printf("\n");
ChipLogProgress(chipTool, "Discovered Commisioner #%d", ++commissionerCount);
commissioner->Log();
}
}

printf("Total of %d commissioner(s) discovered in %" PRIu16 " sec\n", commissionerCount, GetWaitDurationInSeconds());
ChipLogProgress(chipTool, "Total of %d commissioner(s) discovered in %" PRIu16 " sec", commissionerCount,
GetWaitDurationInSeconds());
}
23 changes: 11 additions & 12 deletions examples/tv-casting-app/linux/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ CHIP_ERROR RunTimedEventLoop(uint32_t aDelayMilliseconds)
return CHIP_NO_ERROR;
}

void printOnboardingPayload(chip::SetupPayload payload)
void LogOnboardingPayload(chip::SetupPayload payload)
{
printf("Onboarding Payload::\n");
printf("PIN: %d\n", payload.setUpPINCode);
printf("Discriminator: %d\n", payload.discriminator);
printf("Vendor ID: %d\n", payload.vendorID);
printf("Product ID: %d\n", payload.productID);
ChipLogProgress(Zcl, "Onboarding Payload::");
ChipLogProgress(Zcl, "PIN: %u", payload.setUpPINCode);
ChipLogProgress(Zcl, "Discriminator: %u", payload.discriminator);
ChipLogProgress(Zcl, "Vendor ID: %u", payload.vendorID);
ChipLogProgress(Zcl, "Product ID: %u", payload.productID);
}

int main(int argc, char * argv[])
Expand All @@ -75,23 +75,22 @@ int main(int argc, char * argv[])
const Mdns::DiscoveredNodeData * commissioner = mCommissionableNodeController.GetDiscoveredCommissioner(i);
if (commissioner != nullptr)
{
printf("Discovered Commisioner #%d\n", ++commissionerCount);
commissioner->Print();
printf("\n");
ChipLogProgress(Zcl, "Discovered Commisioner #%d", ++commissionerCount);
commissioner->Log();
}
}
printf("%d commissioner(s) discovered\n", commissionerCount);
ChipLogProgress(Zcl, "%d commissioner(s) discovered", commissionerCount);

// Accept user selection for commissioner TV
VerifyOrExit(commissionerCount > 0, err = CHIP_NO_ERROR);
printf("Choose a commissioner TV (by number# above) to request commissioning from: ");
ChipLogProgress(Zcl, "Choose a commissioner TV (by number# above) to request commissioning from: ");
scanf("%d", &selectedCommissioner);

// Initiate commissionning with selected commissioner TV
SuccessOrExit(chip::DeviceLayer::PlatformMgr().InitChipStack());
SuccessOrExit(mCommissionableNodeController.RequestCommissioning(selectedCommissioner));
SuccessOrExit(mCommissionableNodeController.GetOnboardingPayload(payload));
printOnboardingPayload(payload);
LogOnboardingPayload(payload);
SuccessOrExit(RunTimedEventLoop(3 * 60 * 1000));

// TBD: Implement casting to TV
Expand Down
31 changes: 15 additions & 16 deletions src/lib/mdns/Resolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,65 +102,64 @@ struct DiscoveredNodeData
DiscoveredNodeData() { Reset(); }
bool IsHost(const char * host) const { return strcmp(host, hostName) == 0; }
bool IsValid() const { return !IsHost("") && ipAddress[0] != chip::Inet::IPAddress::Any; }
void Print() const
void Log() const
{
if (rotatingIdLen > 0)
{
char rotatingIdString[chip::Mdns::kMaxRotatingIdLen * 2 + 1] = "";
Encoding::BytesToUppercaseHexString(rotatingId, rotatingIdLen, rotatingIdString, sizeof(rotatingIdString));
printf("Rotating ID: %s\n", rotatingIdString);
ChipLogProgress(Discovery, "Rotating ID: %s", rotatingIdString);
}
if (strcmp(deviceName, "") != 0)
{
printf("Device Name: %s\n", deviceName);
ChipLogProgress(Discovery, "Device Name: %s", deviceName);
}
if (vendorId > 0)
{
printf("Vendor ID: %u\n", vendorId);
ChipLogProgress(Discovery, "Vendor ID: %u", vendorId);
}
if (productId > 0)
{
printf("Product ID: %u\n", productId);
ChipLogProgress(Discovery, "Product ID: %u", productId);
}
if (deviceType > 0)
{
printf("Device Type: %u\n", deviceType);
ChipLogProgress(Discovery, "Device Type: %u", deviceType);
}
if (longDiscriminator > 0)
{
printf("Long Discriminator: %u\n", longDiscriminator);
ChipLogProgress(Discovery, "Long Discriminator: %u", longDiscriminator);
}
if (!IsHost(""))
{
printf("Hostname: %s\n", hostName);
ChipLogProgress(Discovery, "Hostname: %s", hostName);
}
if (additionalPairing > 0)
{
printf("Additional Pairing: %u\n", additionalPairing);
ChipLogProgress(Discovery, "Additional Pairing: %u", additionalPairing);
}
if (strcmp(pairingInstruction, "") != 0)
{
printf("Pairing Instruction: %s\n", pairingInstruction);
ChipLogProgress(Discovery, "Pairing Instruction: %s", pairingInstruction);
}
if (pairingHint > 0)
{
printf("Pairing Hint: 0x%x\n", pairingHint);
ChipLogProgress(Discovery, "Pairing Hint: 0x%x", pairingHint);
}
if (port > 0)
{
printf("Port: %u\n", port);
ChipLogProgress(Discovery, "Port: %u", port);
}
if (numIPs > 0)
{
printf("Number of IP addresses: %d. IP Adddress(es): ", numIPs);
ChipLogProgress(Discovery, "Number of IP addresses: %d. IP Adddress(es): ", numIPs);
for (int j = 0; j < numIPs; j++)
{
char ipAddressString[Inet::kMaxIPAddressStringLength];
printf("%s, ", ipAddress[j].ToString(ipAddressString, sizeof(ipAddressString)));
ChipLogProgress(Discovery, "%s, ", ipAddress[j].ToString(ipAddressString, sizeof(ipAddressString)));
}
printf("\n");
}
printf("Commissioning Mode: %u\n", commissioningMode);
ChipLogProgress(Discovery, "Commissioning Mode: %u", commissioningMode);
}
};

Expand Down

0 comments on commit 6a8f6b1

Please sign in to comment.