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

Add a timeout argument to darwin-framework-tool data model commands. #33639

Merged
merged 1 commit into from
May 29, 2024
Merged
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
#include "../common/CHIPCommandBridge.h"
#include <lib/core/CHIPEncoding.h>

#define DFT_MODEL_COMMAND_DEFAULT_TIMEOUT 20
#define DFT_STRINGIFY_HELPER(arg) #arg
#define DFT_STRINGIFY(arg) DFT_STRINGIFY_HELPER(arg)

class ModelCommand : public CHIPCommandBridge
{
public:
Expand All @@ -30,6 +34,10 @@ class ModelCommand : public CHIPCommandBridge
{
AddArgument("node-id", 0, UINT64_MAX, &mNodeId);
AddArgument("endpoint-id", 0, UINT16_MAX, &mEndPointId);
AddArgument(
"timeout", 0, UINT16_MAX, &mTimeout,
"Amount of time to allow the command to run for before considering it to have timed out. Defaults to " DFT_STRINGIFY(
DFT_MODEL_COMMAND_DEFAULT_TIMEOUT) " seconds.");
}

void Shutdown() override;
Expand All @@ -38,11 +46,19 @@ class ModelCommand : public CHIPCommandBridge

/////////// CHIPCommand Interface /////////
CHIP_ERROR RunCommand() override;
chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(20); }
chip::System::Clock::Timeout GetWaitDuration() const override
{
return chip::System::Clock::Seconds16(mTimeout.ValueOr(DFT_MODEL_COMMAND_DEFAULT_TIMEOUT));
}

virtual CHIP_ERROR SendCommand(MTRBaseDevice * _Nonnull device, chip::EndpointId endPointId) = 0;

private:
chip::NodeId mNodeId;
chip::EndpointId mEndPointId;
chip::Optional<uint16_t> mTimeout;
};

#undef DFT_STRINGIFY
#undef DFT_STRINGIFY_HELPER
#undef DFT_MODEL_COMMAND_DEFAULT_TIMEOUT
Loading