Skip to content

Commit 3c47f80

Browse files
Add a timeout argument to darwin-framework-tool data model commands. (#33639)
chip-tool has one, and this will make it easier to use in YAMLs that run in both.
1 parent 47ab39e commit 3c47f80

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

examples/darwin-framework-tool/commands/clusters/ModelCommandBridge.h

+17-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
#include "../common/CHIPCommandBridge.h"
2222
#include <lib/core/CHIPEncoding.h>
2323

24+
#define DFT_MODEL_COMMAND_DEFAULT_TIMEOUT 20
25+
#define DFT_STRINGIFY_HELPER(arg) #arg
26+
#define DFT_STRINGIFY(arg) DFT_STRINGIFY_HELPER(arg)
27+
2428
class ModelCommand : public CHIPCommandBridge
2529
{
2630
public:
@@ -30,6 +34,10 @@ class ModelCommand : public CHIPCommandBridge
3034
{
3135
AddArgument("node-id", 0, UINT64_MAX, &mNodeId);
3236
AddArgument("endpoint-id", 0, UINT16_MAX, &mEndPointId);
37+
AddArgument(
38+
"timeout", 0, UINT16_MAX, &mTimeout,
39+
"Amount of time to allow the command to run for before considering it to have timed out. Defaults to " DFT_STRINGIFY(
40+
DFT_MODEL_COMMAND_DEFAULT_TIMEOUT) " seconds.");
3341
}
3442

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

3947
/////////// CHIPCommand Interface /////////
4048
CHIP_ERROR RunCommand() override;
41-
chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(20); }
49+
chip::System::Clock::Timeout GetWaitDuration() const override
50+
{
51+
return chip::System::Clock::Seconds16(mTimeout.ValueOr(DFT_MODEL_COMMAND_DEFAULT_TIMEOUT));
52+
}
4253

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

4556
private:
4657
chip::NodeId mNodeId;
4758
chip::EndpointId mEndPointId;
59+
chip::Optional<uint16_t> mTimeout;
4860
};
61+
62+
#undef DFT_STRINGIFY
63+
#undef DFT_STRINGIFY_HELPER
64+
#undef DFT_MODEL_COMMAND_DEFAULT_TIMEOUT

0 commit comments

Comments
 (0)