diff --git a/examples/chip-tool/commands/clusters/ModelCommand.h b/examples/chip-tool/commands/clusters/ModelCommand.h index 25ff96ab870e91..1a29d48fab6a9f 100644 --- a/examples/chip-tool/commands/clusters/ModelCommand.h +++ b/examples/chip-tool/commands/clusters/ModelCommand.h @@ -36,11 +36,12 @@ class ModelCommand : public CHIPCommand { AddArgument("node-id/group-id", 0, UINT64_MAX, &mNodeId); AddArgument("endpoint-id-ignored-for-group-commands", 0, UINT16_MAX, &mEndPointId); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); } /////////// CHIPCommand Interface ///////// CHIP_ERROR RunCommand() override; - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(10); } + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(10)); } virtual CHIP_ERROR SendCommand(ChipDevice * device, std::vector endPointIds) = 0; @@ -55,6 +56,9 @@ class ModelCommand : public CHIPCommand mOnDeviceConnectionFailureCallback.Cancel(); } +protected: + chip::Optional mTimeout; + private: chip::NodeId mNodeId; std::vector mEndPointId; diff --git a/examples/chip-tool/commands/clusters/ReportCommand.h b/examples/chip-tool/commands/clusters/ReportCommand.h index 160370f3634874..124034c07b426a 100644 --- a/examples/chip-tool/commands/clusters/ReportCommand.h +++ b/examples/chip-tool/commands/clusters/ReportCommand.h @@ -303,6 +303,13 @@ class ReportCommand : public ModelCommand, public chip::app::ReadClient::Callbac return mReadClient->SendRequest(params); } + // Use a 3x-longer-than-default timeout because wildcard reads can take a + // while. + chip::System::Clock::Timeout GetWaitDuration() const override + { + return mTimeout.HasValue() ? chip::System::Clock::Seconds16(mTimeout.Value()) : (ModelCommand::GetWaitDuration() * 3); + } + std::unique_ptr mReadClient; chip::app::BufferedReadCallback mBufferedReadAdapter; @@ -411,7 +418,7 @@ class SubscribeAttribute : public ReportCommand chip::System::Clock::Timeout GetWaitDuration() const override { - return chip::System::Clock::Seconds16(mWait ? UINT16_MAX : 10); + return mWait ? chip::System::Clock::Seconds16(UINT16_MAX) : ReportCommand::GetWaitDuration(); } void OnAttributeSubscription() override @@ -525,7 +532,7 @@ class SubscribeEvent : public ReportCommand chip::System::Clock::Timeout GetWaitDuration() const override { - return chip::System::Clock::Seconds16(mWait ? UINT16_MAX : 10); + return mWait ? chip::System::Clock::Seconds16(UINT16_MAX) : ReportCommand::GetWaitDuration(); } void OnEventSubscription() override