diff --git a/src/app/CommandSender.cpp b/src/app/CommandSender.cpp index 3782be62081997..8182bedeba09b8 100644 --- a/src/app/CommandSender.cpp +++ b/src/app/CommandSender.cpp @@ -537,9 +537,9 @@ CHIP_ERROR CommandSender::FinishCommand(FinishCommandParameters & aFinishCommand return FinishCommandInternal(aFinishCommandParams); } -CHIP_ERROR CommandSender::AddRequestDataInternal(const CommandPathParams & aCommandPath, - const DataModel::EncodableToTLV & aEncodable, - AddRequestDataParameters & aAddRequestDataParams) +CHIP_ERROR CommandSender::AddRequestData(const CommandPathParams & aCommandPath, + const DataModel::EncodableToTLV & aEncodable, + AddRequestDataParameters & aAddRequestDataParams) { PrepareCommandParameters prepareCommandParams(aAddRequestDataParams); ReturnErrorOnFailure(PrepareCommand(aCommandPath, prepareCommandParams)); diff --git a/src/app/CommandSender.h b/src/app/CommandSender.h index 56e4a246ff5f18..4d3dca12cb1ab3 100644 --- a/src/app/CommandSender.h +++ b/src/app/CommandSender.h @@ -377,24 +377,20 @@ class CommandSender final : public Messaging::ExchangeDelegate TLV::TLVWriter * GetCommandDataIBTLVWriter(); /** - * API for adding request data. The `aEncodable` is generally expected to encode - * a ClusterName::Commands::CommandName::Type struct, however any object should work. + * API for adding request data using DataModel::EncodableToTLV. * * @param [in] aCommandPath The path of the command being requested. * @param [in] aEncodable - an encodable that places the command data structure - * for `aResponseCommandId` into a TLV Writer. + * for `aAddRequestDataParams` into a TLV Writer. * @param [in] aAddRequestDataParams parameters associated with building the * InvokeRequestMessage that are associated with this request. * - * This API does not validate if the command provided requires interaction use a timed - * invoke interaction. If the caller wants that certainty they should call the templated - * version of AddRequestData. + * This API will not fail if this is an untimed invoke but the command provided requires a timed + * invoke interaction. If the caller wants that to fail before sending the command, they should call + * the templated version of AddRequestData. */ CHIP_ERROR AddRequestData(const CommandPathParams & aCommandPath, const DataModel::EncodableToTLV & aEncodable, - AddRequestDataParameters & aAddRequestDataParams) - { - return AddRequestDataInternal(aCommandPath, aEncodable, aAddRequestDataParams); - } + AddRequestDataParameters & aAddRequestDataParams); /** * API for adding a data request. The template parameter T is generally @@ -420,7 +416,8 @@ class CommandSender final : public Messaging::ExchangeDelegate CHIP_ERROR_INVALID_ARGUMENT); DataModel::EncodableType encoder(aData); - return AddRequestDataInternal(aCommandPath, encoder, aAddRequestDataParams); + DataModel::EncodableToTLV & encodable = encoder; + return AddRequestData(aCommandPath, encodable, aAddRequestDataParams); } template @@ -450,7 +447,8 @@ class CommandSender final : public Messaging::ExchangeDelegate AddRequestDataParameters & aAddRequestDataParams) { DataModel::EncodableType encoder(aData); - return AddRequestDataInternal(aCommandPath, encoder, aAddRequestDataParams); + DataModel::EncodableToTLV & encodable = encoder; + return AddRequestData(aCommandPath, encodable, aAddRequestDataParams); } CHIP_ERROR TestOnlyFinishCommand(FinishCommandParameters & aFinishCommandParams) @@ -472,9 +470,6 @@ class CommandSender final : public Messaging::ExchangeDelegate #endif // CONFIG_BUILD_FOR_HOST_UNIT_TEST private: - CHIP_ERROR AddRequestDataInternal(const CommandPathParams & aCommandPath, const DataModel::EncodableToTLV & aEncodable, - AddRequestDataParameters & aAddRequestDataParams); - CHIP_ERROR FinishCommandInternal(FinishCommandParameters & aFinishCommandParams); public: