Skip to content

Commit

Permalink
[placeholder] Allow placeholder examples to emit dnssd requests
Browse files Browse the repository at this point in the history
  • Loading branch information
vivien-apple committed Mar 3, 2022
1 parent 8895bdb commit 8135e43
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
11 changes: 9 additions & 2 deletions examples/placeholder/linux/include/TestCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
#include <app/tests/suites/commands/delay/DelayCommands.h>
#include <app/tests/suites/commands/discovery/DiscoveryCommands.h>
#include <app/tests/suites/commands/log/LogCommands.h>
#include <app/tests/suites/include/ConstraintsChecker.h>
#include <app/tests/suites/include/PICSChecker.h>
#include <app/tests/suites/include/ValueChecker.h>

#include <app-common/zap-generated/ids/Attributes.h>
#include <app-common/zap-generated/ids/Clusters.h>
Expand All @@ -36,7 +38,12 @@ constexpr const char kIdentityAlpha[] = "";
constexpr const char kIdentityBeta[] = "";
constexpr const char kIdentityGamma[] = "";

class TestCommand : public PICSChecker, public LogCommands, public DiscoveryCommands, public DelayCommands
class TestCommand : public PICSChecker,
public LogCommands,
public DiscoveryCommands,
public DelayCommands,
public ValueChecker,
public ConstraintsChecker
{
public:
TestCommand(const char * commandName) : mCommandPath(0, 0, 0), mAttributePath(0, 0, 0) {}
Expand Down Expand Up @@ -75,7 +82,7 @@ class TestCommand : public PICSChecker, public LogCommands, public DiscoveryComm
return CHIP_NO_ERROR;
}

void Exit(std::string message)
void Exit(std::string message) override
{
ChipLogError(chipTool, " ***** Test Failure: %s\n", message.c_str());
SetCommandExitStatus(CHIP_ERROR_INTERNAL);
Expand Down
13 changes: 13 additions & 0 deletions examples/placeholder/templates/templates.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"../../../src/app/zap-templates/templates/chip/helper.js",
"../../../src/app/zap-templates/common/ClusterTestGeneration.js",
"../../../examples/chip-tool/templates/helper.js",
"../../../examples/chip-tool/templates/tests/helper.js",
"helper.js"
],
"override": "../../../src/app/zap-templates/common/override.js",
Expand All @@ -20,6 +21,18 @@
"name": "test_cluster",
"path": "../../../examples/chip-tool/templates/tests/partials/test_cluster.zapt"
},
{
"name": "maybeCheckExpectedValue",
"path": "../../../examples/chip-tool/templates/tests/partials/checks/maybeCheckExpectedValue.zapt"
},
{
"name": "maybeCheckExpectedConstraints",
"path": "../../../examples/chip-tool/templates/tests/partials/checks/maybeCheckExpectedConstraints.zapt"
},
{
"name": "maybeSaveAs",
"path": "../../../examples/chip-tool/templates/tests/partials/saveAs/maybeSaveAs.zapt"
},
{
"name": "setupSaveAs",
"path": "../../../examples/chip-tool/templates/tests/partials/saveAs/setupSaveAs.zapt"
Expand Down
2 changes: 2 additions & 0 deletions src/app/tests/suites/commands/discovery/DiscoveryCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,14 @@ CHIP_ERROR DiscoveryCommands::SetupDiscoveryCommands()
ReturnErrorOnFailure(mDNSResolver.Init(chip::DeviceLayer::UDPEndPointManager()));
mReady = true;
}
mDNSResolver.SetOperationalDelegate(this);
mDNSResolver.SetCommissioningDelegate(this);
return CHIP_NO_ERROR;
}

CHIP_ERROR DiscoveryCommands::TearDownDiscoveryCommands()
{
mDNSResolver.SetOperationalDelegate(nullptr);
mDNSResolver.SetCommissioningDelegate(nullptr);
return CHIP_NO_ERROR;
}
Expand Down
6 changes: 5 additions & 1 deletion src/app/tests/suites/commands/discovery/DiscoveryCommands.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ struct DiscoveryCommandResult
chip::Optional<uint32_t> mrpRetryIntervalActive;
};

class DiscoveryCommands : public chip::Dnssd::CommissioningResolveDelegate
class DiscoveryCommands : public chip::Dnssd::CommissioningResolveDelegate, public chip::Dnssd::OperationalResolveDelegate
{
public:
DiscoveryCommands(){};
Expand All @@ -69,6 +69,10 @@ class DiscoveryCommands : public chip::Dnssd::CommissioningResolveDelegate
/////////// CommissioningDelegate Interface /////////
void OnNodeDiscovered(const chip::Dnssd::DiscoveredNodeData & nodeData) override;

/////////// OperationalDelegate Interface /////////
void OnOperationalNodeResolved(const chip::Dnssd::ResolvedNodeData & nodeData) override{};
void OnOperationalNodeResolutionFailed(const chip::PeerId & peerId, CHIP_ERROR error) override{};

private:
bool mReady = false;
chip::Dnssd::ResolverProxy mDNSResolver;
Expand Down

0 comments on commit 8135e43

Please sign in to comment.