From b36b8eb250853511212f5e719039eced2ed58434 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Sat, 21 May 2022 16:38:21 -0400 Subject: [PATCH] Document the timedInteractionTimeoutMs argument in chip-tool. (#18703) Refactors some of the relevant code slightly to reduce the amount of copy/paste. --- .../commands/clusters/ClusterCommandBridge.h | 33 ++++++++-------- .../clusters/WriteAttributeCommandBridge.h | 27 +++++++------ .../commands/clusters/ClusterCommand.h | 38 +++++++++---------- .../commands/clusters/WriteAttributeCommand.h | 34 +++++++++-------- 4 files changed, 70 insertions(+), 62 deletions(-) diff --git a/examples/chip-tool-darwin/commands/clusters/ClusterCommandBridge.h b/examples/chip-tool-darwin/commands/clusters/ClusterCommandBridge.h index 0d65a4c7729282..4eac3990aba8c4 100644 --- a/examples/chip-tool-darwin/commands/clusters/ClusterCommandBridge.h +++ b/examples/chip-tool-darwin/commands/clusters/ClusterCommandBridge.h @@ -32,10 +32,7 @@ class ClusterCommand : public ModelCommand { AddArgument("cluster-id", 0, UINT32_MAX, &mClusterId); AddArgument("command-id", 0, UINT32_MAX, &mCommandId); AddArgument("payload", &mPayload); - AddArgument("timedInteractionTimeoutMs", 0, UINT16_MAX, &mTimedInteractionTimeoutMs); - AddArgument("repeat-count", 1, UINT16_MAX, &mRepeatCount); - AddArgument("repeat-delay-ms", 0, UINT16_MAX, &mRepeatDelayInMs); - ModelCommand::AddArguments(); + AddArguments(); } ClusterCommand(chip::ClusterId clusterId) @@ -44,18 +41,7 @@ class ClusterCommand : public ModelCommand { { AddArgument("command-id", 0, UINT32_MAX, &mCommandId); AddArgument("payload", &mPayload); - AddArgument("timedInteractionTimeoutMs", 0, UINT16_MAX, &mTimedInteractionTimeoutMs); - AddArgument("repeat-count", 1, UINT16_MAX, &mRepeatCount); - AddArgument("repeat-delay-ms", 0, UINT16_MAX, &mRepeatDelayInMs); - ModelCommand::AddArguments(); - } - - ClusterCommand(const char * _Nonnull commandName) - : ModelCommand(commandName) - { - AddArgument("timedInteractionTimeoutMs", 0, UINT16_MAX, &mTimedInteractionTimeoutMs); - AddArgument("repeat-count", 1, UINT16_MAX, &mRepeatCount); - AddArgument("repeat-delay-ms", 0, UINT16_MAX, &mRepeatDelayInMs); + AddArguments(); } ~ClusterCommand() {} @@ -117,6 +103,21 @@ class ClusterCommand : public ModelCommand { } protected: + ClusterCommand(const char * _Nonnull commandName) + : ModelCommand(commandName) + { + // Subclasses are responsible for calling AddArguments. + } + + void AddArguments() + { + AddArgument("timedInteractionTimeoutMs", 0, UINT16_MAX, &mTimedInteractionTimeoutMs, + "If provided, do a timed invoke with the given timed interaction timeout."); + AddArgument("repeat-count", 1, UINT16_MAX, &mRepeatCount); + AddArgument("repeat-delay-ms", 0, UINT16_MAX, &mRepeatDelayInMs); + ModelCommand::AddArguments(); + } + chip::Optional mTimedInteractionTimeoutMs; chip::Optional mRepeatCount; chip::Optional mRepeatDelayInMs; diff --git a/examples/chip-tool-darwin/commands/clusters/WriteAttributeCommandBridge.h b/examples/chip-tool-darwin/commands/clusters/WriteAttributeCommandBridge.h index ee52a2c2925650..69c52aa21797ac 100644 --- a/examples/chip-tool-darwin/commands/clusters/WriteAttributeCommandBridge.h +++ b/examples/chip-tool-darwin/commands/clusters/WriteAttributeCommandBridge.h @@ -30,8 +30,7 @@ class WriteAttribute : public ModelCommand { AddArgument("cluster-id", 0, UINT32_MAX, &mClusterId); AddArgument("attribute-id", 0, UINT32_MAX, &mAttributeId); AddArgument("attribute-value", &mAttributeValue); - AddArgument("timedInteractionTimeoutMs", 0, UINT16_MAX, &mTimedInteractionTimeoutMs); - ModelCommand::AddArguments(); + AddArguments(); } WriteAttribute(chip::ClusterId clusterId) @@ -40,15 +39,7 @@ class WriteAttribute : public ModelCommand { { AddArgument("attribute-id", 0, UINT32_MAX, &mAttributeId); AddArgument("attribute-value", &mAttributeValue); - AddArgument("timedInteractionTimeoutMs", 0, UINT16_MAX, &mTimedInteractionTimeoutMs); - ModelCommand::AddArguments(); - } - - WriteAttribute(const char * _Nonnull attributeName) - : ModelCommand("write") - { - AddArgument("data-version", 0, UINT32_MAX, &mDataVersion); - AddArgument("timedInteractionTimeoutMs", 0, UINT16_MAX, &mTimedInteractionTimeoutMs); + AddArguments(); } ~WriteAttribute() {} @@ -103,6 +94,20 @@ class WriteAttribute : public ModelCommand { } protected: + WriteAttribute(const char * _Nonnull attributeName) + : ModelCommand("write") + { + AddArgument("data-version", 0, UINT32_MAX, &mDataVersion); + // Subclasses are responsible for calling AddArguments. + } + + void AddArguments() + { + AddArgument("timedInteractionTimeoutMs", 0, UINT16_MAX, &mTimedInteractionTimeoutMs, + "If provided, do a timed write with the given timed interaction timeout."); + ModelCommand::AddArguments(); + } + chip::Optional mTimedInteractionTimeoutMs; chip::Optional mDataVersion; diff --git a/examples/chip-tool/commands/clusters/ClusterCommand.h b/examples/chip-tool/commands/clusters/ClusterCommand.h index 55b40084a349af..81386cddd195aa 100644 --- a/examples/chip-tool/commands/clusters/ClusterCommand.h +++ b/examples/chip-tool/commands/clusters/ClusterCommand.h @@ -32,11 +32,7 @@ class ClusterCommand : public InteractionModelCommands, public ModelCommand, pub AddArgument("cluster-id", 0, UINT32_MAX, &mClusterId); AddArgument("command-id", 0, UINT32_MAX, &mCommandId); AddArgument("payload", &mPayload); - AddArgument("timedInteractionTimeoutMs", 0, UINT16_MAX, &mTimedInteractionTimeoutMs); - AddArgument("suppressResponse", 0, 1, &mSuppressResponse); - AddArgument("repeat-count", 1, UINT16_MAX, &mRepeatCount); - AddArgument("repeat-delay-ms", 0, UINT16_MAX, &mRepeatDelayInMs); - ModelCommand::AddArguments(); + AddArguments(); } ClusterCommand(chip::ClusterId clusterId, CredentialIssuerCommands * credsIssuerConfig) : @@ -44,20 +40,7 @@ class ClusterCommand : public InteractionModelCommands, public ModelCommand, pub { AddArgument("command-id", 0, UINT32_MAX, &mCommandId); AddArgument("payload", &mPayload); - AddArgument("timedInteractionTimeoutMs", 0, UINT16_MAX, &mTimedInteractionTimeoutMs); - AddArgument("suppressResponse", 0, 1, &mSuppressResponse); - AddArgument("repeat-count", 1, UINT16_MAX, &mRepeatCount); - AddArgument("repeat-delay-ms", 0, UINT16_MAX, &mRepeatDelayInMs); - ModelCommand::AddArguments(); - } - - ClusterCommand(const char * commandName, CredentialIssuerCommands * credsIssuerConfig) : - InteractionModelCommands(this), ModelCommand(commandName, credsIssuerConfig) - { - AddArgument("timedInteractionTimeoutMs", 0, UINT16_MAX, &mTimedInteractionTimeoutMs); - AddArgument("suppressResponse", 0, 1, &mSuppressResponse); - AddArgument("repeat-count", 1, UINT16_MAX, &mRepeatCount); - AddArgument("repeat-delay-ms", 0, UINT16_MAX, &mRepeatDelayInMs); + AddArguments(); } ~ClusterCommand() {} @@ -141,6 +124,23 @@ class ClusterCommand : public InteractionModelCommands, public ModelCommand, pub } } +protected: + ClusterCommand(const char * commandName, CredentialIssuerCommands * credsIssuerConfig) : + InteractionModelCommands(this), ModelCommand(commandName, credsIssuerConfig) + { + // Subclasses are responsible for calling AddArguments. + } + + void AddArguments() + { + AddArgument("timedInteractionTimeoutMs", 0, UINT16_MAX, &mTimedInteractionTimeoutMs, + "If provided, do a timed invoke with the given timed interaction timeout."); + AddArgument("suppressResponse", 0, 1, &mSuppressResponse); + AddArgument("repeat-count", 1, UINT16_MAX, &mRepeatCount); + AddArgument("repeat-delay-ms", 0, UINT16_MAX, &mRepeatDelayInMs); + ModelCommand::AddArguments(); + } + private: chip::ClusterId mClusterId; chip::CommandId mCommandId; diff --git a/examples/chip-tool/commands/clusters/WriteAttributeCommand.h b/examples/chip-tool/commands/clusters/WriteAttributeCommand.h index 8d2e8797c8b40a..231526453775ed 100644 --- a/examples/chip-tool/commands/clusters/WriteAttributeCommand.h +++ b/examples/chip-tool/commands/clusters/WriteAttributeCommand.h @@ -32,10 +32,7 @@ class WriteAttribute : public InteractionModelWriter, public ModelCommand, publi AddArgument("cluster-id", 0, UINT32_MAX, &mClusterId); AddArgument("attribute-id", 0, UINT32_MAX, &mAttributeId); AddArgument("attribute-value", &mAttributeValue); - AddArgument("timedInteractionTimeoutMs", 0, UINT16_MAX, &mTimedInteractionTimeoutMs); - AddArgument("data-version", 0, UINT32_MAX, &mDataVersion); - AddArgument("suppressResponse", 0, 1, &mSuppressResponse); - ModelCommand::AddArguments(); + AddArguments(); } WriteAttribute(chip::ClusterId clusterId, CredentialIssuerCommands * credsIssuerConfig) : @@ -43,18 +40,7 @@ class WriteAttribute : public InteractionModelWriter, public ModelCommand, publi { AddArgument("attribute-id", 0, UINT32_MAX, &mAttributeId); AddArgument("attribute-value", &mAttributeValue); - AddArgument("timedInteractionTimeoutMs", 0, UINT16_MAX, &mTimedInteractionTimeoutMs); - AddArgument("data-version", 0, UINT32_MAX, &mDataVersion); - AddArgument("suppressResponse", 0, 1, &mSuppressResponse); - ModelCommand::AddArguments(); - } - - WriteAttribute(const char * attributeName, CredentialIssuerCommands * credsIssuerConfig) : - InteractionModelWriter(this), ModelCommand("write", credsIssuerConfig) - { - AddArgument("timedInteractionTimeoutMs", 0, UINT16_MAX, &mTimedInteractionTimeoutMs); - AddArgument("data-version", 0, UINT32_MAX, &mDataVersion); - AddArgument("suppressResponse", 0, 1, &mSuppressResponse); + AddArguments(); } ~WriteAttribute() {} @@ -112,6 +98,22 @@ class WriteAttribute : public InteractionModelWriter, public ModelCommand, publi return InteractionModelWriter::WriteGroupAttribute(groupId, fabricIndex, clusterId, attributeId, value, mDataVersion); } +protected: + WriteAttribute(const char * attributeName, CredentialIssuerCommands * credsIssuerConfig) : + InteractionModelWriter(this), ModelCommand("write", credsIssuerConfig) + { + // Subclasses are responsible for calling AddArguments. + } + + void AddArguments() + { + AddArgument("timedInteractionTimeoutMs", 0, UINT16_MAX, &mTimedInteractionTimeoutMs, + "If provided, do a timed write with the given timed interaction timeout."); + AddArgument("data-version", 0, UINT32_MAX, &mDataVersion); + AddArgument("suppressResponse", 0, 1, &mSuppressResponse); + ModelCommand::AddArguments(); + } + private: chip::ClusterId mClusterId; chip::AttributeId mAttributeId;