diff --git a/examples/chip-tool/commands/clusters/ClusterCommand.h b/examples/chip-tool/commands/clusters/ClusterCommand.h index 92197e115e9639..96417e19dba849 100644 --- a/examples/chip-tool/commands/clusters/ClusterCommand.h +++ b/examples/chip-tool/commands/clusters/ClusterCommand.h @@ -32,6 +32,7 @@ class ClusterCommand : public ModelCommand, public chip::app::CommandSender::Cal AddArgument("command-id", 0, UINT32_MAX, &mCommandId); AddArgument("payload", &mPayload); AddArgument("timedInteractionTimeoutMs", 0, UINT16_MAX, &mTimedInteractionTimeoutMs); + AddArgument("suppressResponse", 0, 1, &mSuppressResponse); ModelCommand::AddArguments(); } @@ -41,6 +42,7 @@ class ClusterCommand : public ModelCommand, public chip::app::CommandSender::Cal AddArgument("command-id", 0, UINT32_MAX, &mCommandId); AddArgument("payload", &mPayload); AddArgument("timedInteractionTimeoutMs", 0, UINT16_MAX, &mTimedInteractionTimeoutMs); + AddArgument("suppressResponse", 0, 1, &mSuppressResponse); ModelCommand::AddArguments(); } @@ -48,6 +50,7 @@ class ClusterCommand : public ModelCommand, public chip::app::CommandSender::Cal ModelCommand(commandName, credsIssuerConfig) { AddArgument("timedInteractionTimeoutMs", 0, UINT16_MAX, &mTimedInteractionTimeoutMs); + AddArgument("suppressResponse", 0, 1, &mSuppressResponse); } ~ClusterCommand() {} @@ -107,7 +110,8 @@ class ClusterCommand : public ModelCommand, public chip::app::CommandSender::Cal mCommandSender = std::make_unique(this, device->GetExchangeManager(), mTimedInteractionTimeoutMs.HasValue()); VerifyOrReturnError(mCommandSender != nullptr, CHIP_ERROR_NO_MEMORY); - ReturnErrorOnFailure(mCommandSender->AddRequestDataNoTimedCheck(commandPath, value, mTimedInteractionTimeoutMs)); + ReturnErrorOnFailure(mCommandSender->AddRequestDataNoTimedCheck(commandPath, value, mTimedInteractionTimeoutMs, + mSuppressResponse.ValueOr(false))); ReturnErrorOnFailure(mCommandSender->SendCommandRequest(device->GetSecureSession().Value())); return CHIP_NO_ERROR; } @@ -137,6 +141,7 @@ class ClusterCommand : public ModelCommand, public chip::app::CommandSender::Cal chip::ClusterId mClusterId; chip::CommandId mCommandId; chip::Optional mTimedInteractionTimeoutMs; + chip::Optional mSuppressResponse; CHIP_ERROR mError = CHIP_NO_ERROR; CustomArgument mPayload; diff --git a/examples/chip-tool/commands/clusters/WriteAttributeCommand.h b/examples/chip-tool/commands/clusters/WriteAttributeCommand.h index 39016e2e125a22..d7aa1f727a28d7 100644 --- a/examples/chip-tool/commands/clusters/WriteAttributeCommand.h +++ b/examples/chip-tool/commands/clusters/WriteAttributeCommand.h @@ -33,6 +33,7 @@ class WriteAttribute : public ModelCommand, public chip::app::WriteClient::Callb AddArgument("attribute-value", &mAttributeValue); AddArgument("timedInteractionTimeoutMs", 0, UINT16_MAX, &mTimedInteractionTimeoutMs); AddArgument("data-version", 0, UINT32_MAX, &mDataVersion); + AddArgument("suppressResponse", 0, 1, &mSuppressResponse); ModelCommand::AddArguments(); } @@ -43,6 +44,7 @@ class WriteAttribute : public ModelCommand, public chip::app::WriteClient::Callb AddArgument("attribute-value", &mAttributeValue); AddArgument("timedInteractionTimeoutMs", 0, UINT16_MAX, &mTimedInteractionTimeoutMs); AddArgument("data-version", 0, UINT32_MAX, &mDataVersion); + AddArgument("suppressResponse", 0, 1, &mSuppressResponse); ModelCommand::AddArguments(); } @@ -51,6 +53,7 @@ class WriteAttribute : public ModelCommand, public chip::app::WriteClient::Callb { AddArgument("timedInteractionTimeoutMs", 0, UINT16_MAX, &mTimedInteractionTimeoutMs); AddArgument("data-version", 0, UINT32_MAX, &mDataVersion); + AddArgument("suppressResponse", 0, 1, &mSuppressResponse); } ~WriteAttribute() {} @@ -103,7 +106,8 @@ class WriteAttribute : public ModelCommand, public chip::app::WriteClient::Callb attributePathParams.mClusterId = clusterId; attributePathParams.mAttributeId = attributeId; - mWriteClient = std::make_unique(device->GetExchangeManager(), this, mTimedInteractionTimeoutMs); + mWriteClient = std::make_unique(device->GetExchangeManager(), this, mTimedInteractionTimeoutMs, + mSuppressResponse.ValueOr(false)); ReturnErrorOnFailure(mWriteClient->EncodeAttribute(attributePathParams, value, mDataVersion)); @@ -141,6 +145,7 @@ class WriteAttribute : public ModelCommand, public chip::app::WriteClient::Callb CHIP_ERROR mError = CHIP_NO_ERROR; chip::Optional mTimedInteractionTimeoutMs; chip::Optional mDataVersion = chip::NullOptional; + chip::Optional mSuppressResponse; CustomArgument mAttributeValue; std::unique_ptr mWriteClient; }; diff --git a/src/app/CommandSender.h b/src/app/CommandSender.h index c2d4f025dba344..3b103f4c70c5d9 100644 --- a/src/app/CommandSender.h +++ b/src/app/CommandSender.h @@ -179,8 +179,9 @@ class CommandSender final : public Messaging::ExchangeDelegate */ template CHIP_ERROR AddRequestDataNoTimedCheck(const CommandPathParams & aCommandPath, const CommandDataT & aData, - const Optional & aTimedInvokeTimeoutMs) + const Optional & aTimedInvokeTimeoutMs, bool aSuppressResponse = false) { + mSuppressResponse = aSuppressResponse; return AddRequestDataInternal(aCommandPath, aData, aTimedInvokeTimeoutMs); } #endif // CONFIG_IM_BUILD_FOR_UNIT_TEST diff --git a/src/app/WriteClient.cpp b/src/app/WriteClient.cpp index 4dfb8f86e7c6f9..2a162a5291b079 100644 --- a/src/app/WriteClient.cpp +++ b/src/app/WriteClient.cpp @@ -240,6 +240,7 @@ CHIP_ERROR WriteClient::StartNewMessage() ReturnErrorOnFailure(mMessageWriter.ReserveBuffer(reservedSize)); ReturnErrorOnFailure(mWriteRequestBuilder.Init(&mMessageWriter)); + mWriteRequestBuilder.SuppressResponse(mSuppressResponse); mWriteRequestBuilder.TimedRequest(mTimedWriteTimeoutMs.HasValue()); ReturnErrorOnFailure(mWriteRequestBuilder.GetError()); mWriteRequestBuilder.CreateWriteRequests(); diff --git a/src/app/WriteClient.h b/src/app/WriteClient.h index d46ca789bcea8f..92b6e98d7f9793 100644 --- a/src/app/WriteClient.h +++ b/src/app/WriteClient.h @@ -120,11 +120,12 @@ class WriteClient : public Messaging::ExchangeDelegate * @param[in] apExchangeMgr A pointer to the ExchangeManager object. * @param[in] apCallback Callback set by application. * @param[in] aTimedWriteTimeoutMs If provided, do a timed write using this timeout. + * @param[in] aSuppressResponse If provided, set SuppressResponse field to the provided value */ - WriteClient(Messaging::ExchangeManager * apExchangeMgr, Callback * apCallback, - const Optional & aTimedWriteTimeoutMs) : + WriteClient(Messaging::ExchangeManager * apExchangeMgr, Callback * apCallback, const Optional & aTimedWriteTimeoutMs, + bool aSuppressResponse = false) : mpExchangeMgr(apExchangeMgr), - mpCallback(apCallback), mTimedWriteTimeoutMs(aTimedWriteTimeoutMs) + mpCallback(apCallback), mTimedWriteTimeoutMs(aTimedWriteTimeoutMs), mSuppressResponse(aSuppressResponse) {} #if CONFIG_IM_BUILD_FOR_UNIT_TEST @@ -391,6 +392,7 @@ class WriteClient : public Messaging::ExchangeDelegate // If mTimedWriteTimeoutMs has a value, we are expected to do a timed // write. Optional mTimedWriteTimeoutMs; + bool mSuppressResponse = false; // A list of buffers, one buffer for each chunk. System::PacketBufferHandle mChunks; diff --git a/src/app/WriteHandler.cpp b/src/app/WriteHandler.cpp index 76cd8af5bee622..5377b3512ab818 100644 --- a/src/app/WriteHandler.cpp +++ b/src/app/WriteHandler.cpp @@ -46,6 +46,7 @@ CHIP_ERROR WriteHandler::Init() void WriteHandler::Close() { + mSuppressResponse = false; VerifyOrReturn(mState != State::Uninitialized); if (mpExchangeCtx != nullptr) @@ -394,7 +395,6 @@ Status WriteHandler::ProcessWriteRequest(System::PacketBufferHandle && aPayload, WriteRequestMessage::Parser writeRequestParser; AttributeDataIBs::Parser AttributeDataIBsParser; TLV::TLVReader AttributeDataIBsReader; - bool needSuppressResponse = false; // Default to InvalidAction for our status; that's what we want if any of // the parsing of our overall structure or paths fails. Once we have a // successfully parsed path, the only way we will get a failure return is if @@ -413,7 +413,7 @@ Status WriteHandler::ProcessWriteRequest(System::PacketBufferHandle && aPayload, err = writeRequestParser.CheckSchemaValidity(); SuccessOrExit(err); #endif - err = writeRequestParser.GetSuppressResponse(&needSuppressResponse); + err = writeRequestParser.GetSuppressResponse(&mSuppressResponse); if (err == CHIP_END_OF_TLV) { err = CHIP_NO_ERROR; diff --git a/src/app/WriteHandler.h b/src/app/WriteHandler.h index 78d2509e065212..3d18fff00780e3 100644 --- a/src/app/WriteHandler.h +++ b/src/app/WriteHandler.h @@ -148,9 +148,10 @@ class WriteHandler : public Messaging::ExchangeDelegate private: Messaging::ExchangeContext * mpExchangeCtx = nullptr; WriteResponseMessage::Builder mWriteResponseBuilder; - State mState = State::Uninitialized; - bool mIsTimedRequest = false; - bool mHasMoreChunks = false; + State mState = State::Uninitialized; + bool mIsTimedRequest = false; + bool mSuppressResponse = false; + bool mHasMoreChunks = false; Optional mProcessingAttributePath; Optional mACLCheckCache = NullOptional; };