Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose commissionerNodeId as a variable for yaml #24197

Merged
merged 15 commits into from
Jan 16, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions examples/chip-tool/commands/tests/TestCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ class TestCommand : public TestRunner,

chip::Controller::DeviceCommissioner & GetCommissioner(const char * identity) override
{
// Best effort to get NodeId - if this fails, GetCommissioner will also fail
chip::NodeId id;
if (GetCommissionerNodeId(identity, &id) == CHIP_NO_ERROR)
{
mCommissionerNodeId.SetValue(id);
}
return CHIPCommand::GetCommissioner(identity);
};

Expand All @@ -95,6 +101,7 @@ class TestCommand : public TestRunner,

chip::Optional<char *> mPICSFilePath;
chip::Optional<uint16_t> mTimeout;
chip::Optional<chip::NodeId> mCommissionerNodeId;
std::map<std::string, std::unique_ptr<chip::OperationalDeviceProxy>> mDevices;

// When set to false, prevents interaction model events from affecting the current test status.
Expand Down
5 changes: 5 additions & 0 deletions examples/chip-tool/templates/tests/partials/test_cluster.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ private:
CHIP_ERROR DoTestStep(uint16_t testIndex) override
{
using namespace chip::app::Clusters;
// Allow yaml to access the current commissioner node id.
cecille marked this conversation as resolved.
Show resolved Hide resolved
// Default to 0 (undefined node id) so we know if this isn't
// set correctly.
chip::NodeId commissionerNodeId = mCommissionerNodeId.ValueOr(0);
(void) commissionerNodeId;
switch (testIndex)
{
{{#chip_tests_items}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ class TestCommandBridge : public CHIPCommandBridge,
VerifyOrReturnError(controller != nil, CHIP_ERROR_INCORRECT_STATE);

SetIdentity(identity);
if (controller.controllerNodeId != nil) {
mCommissionerNodeId.SetValue([controller.controllerNodeId unsignedLongLongValue]);
cecille marked this conversation as resolved.
Show resolved Hide resolved
}

// Invalidate our existing CASE session; otherwise trying to work with
// our device will just reuse it without establishing a new CASE
Expand Down Expand Up @@ -181,6 +184,9 @@ class TestCommandBridge : public CHIPCommandBridge,
VerifyOrReturnError(controller != nil, CHIP_ERROR_INCORRECT_STATE);

SetIdentity(identity);
if (controller.controllerNodeId != nil) {
mCommissionerNodeId.SetValue([controller.controllerNodeId unsignedLongLongValue]);
}

[controller setDeviceControllerDelegate:mDeviceControllerDelegate queue:mCallbackQueue];
[mDeviceControllerDelegate setDeviceId:value.nodeId];
Expand Down Expand Up @@ -255,6 +261,7 @@ class TestCommandBridge : public CHIPCommandBridge,
chip::Optional<char *> mPICSFilePath;
chip::Optional<chip::EndpointId> mEndpointId;
chip::Optional<uint16_t> mTimeout;
chip::Optional<chip::NodeId> mCommissionerNodeId;

bool CheckConstraintStartsWith(
const char * _Nonnull itemName, const NSString * _Nonnull current, const char * _Nonnull expected)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,16 @@ class {{filename}}: public TestCommandBridge
{
}

// Allow yaml to access the current commissioner node id.
cecille marked this conversation as resolved.
Show resolved Hide resolved
// Default to 0 (undefined node id) so we know if this isn't
// set correctly.
chip::NodeId commissionerNodeId = mCommissionerNodeId.ValueOr(0);

/////////// TestCommand Interface /////////
void NextTest() override
{
CHIP_ERROR err = CHIP_NO_ERROR;
commissionerNodeId = mCommissionerNodeId.ValueOr(0);

if (0 == mTestIndex)
{
Expand Down
Loading