Skip to content

Commit

Permalink
Add a timeout argument to darwin-framework-tool data model commands. (p…
Browse files Browse the repository at this point in the history
…roject-chip#33639)

chip-tool has one, and this will make it easier to use in YAMLs that run in
both.
  • Loading branch information
bzbarsky-apple authored and kiel-apple committed Jun 3, 2024
1 parent da0fe5e commit fa0a3d7
Showing 1 changed file with 17 additions and 1 deletion.
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

0 comments on commit fa0a3d7

Please sign in to comment.