21
21
#include " ../common/CHIPCommandBridge.h"
22
22
#include < lib/core/CHIPEncoding.h>
23
23
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
+
24
28
class ModelCommand : public CHIPCommandBridge
25
29
{
26
30
public:
@@ -30,6 +34,10 @@ class ModelCommand : public CHIPCommandBridge
30
34
{
31
35
AddArgument (" node-id" , 0 , UINT64_MAX, &mNodeId );
32
36
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." );
33
41
}
34
42
35
43
void Shutdown () override ;
@@ -38,11 +46,19 @@ class ModelCommand : public CHIPCommandBridge
38
46
39
47
// ///////// CHIPCommand Interface /////////
40
48
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
+ }
42
53
43
54
virtual CHIP_ERROR SendCommand (MTRBaseDevice * _Nonnull device, chip::EndpointId endPointId) = 0;
44
55
45
56
private:
46
57
chip::NodeId mNodeId ;
47
58
chip::EndpointId mEndPointId ;
59
+ chip::Optional<uint16_t > mTimeout ;
48
60
};
61
+
62
+ #undef DFT_STRINGIFY
63
+ #undef DFT_STRINGIFY_HELPER
64
+ #undef DFT_MODEL_COMMAND_DEFAULT_TIMEOUT
0 commit comments