Skip to content

Commit

Permalink
Address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
tehampson committed Jun 10, 2024
1 parent 3080f08 commit 7e5bbb3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 18 deletions.
6 changes: 3 additions & 3 deletions src/app/CommandSender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
25 changes: 10 additions & 15 deletions src/app/CommandSender.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -420,7 +416,8 @@ class CommandSender final : public Messaging::ExchangeDelegate
CHIP_ERROR_INVALID_ARGUMENT);

DataModel::EncodableType<CommandDataT> encoder(aData);
return AddRequestDataInternal(aCommandPath, encoder, aAddRequestDataParams);
DataModel::EncodableToTLV & encodable = encoder;
return AddRequestData(aCommandPath, encodable, aAddRequestDataParams);
}

template <typename CommandDataT>
Expand Down Expand Up @@ -450,7 +447,8 @@ class CommandSender final : public Messaging::ExchangeDelegate
AddRequestDataParameters & aAddRequestDataParams)
{
DataModel::EncodableType<CommandDataT> encoder(aData);
return AddRequestDataInternal(aCommandPath, encoder, aAddRequestDataParams);
DataModel::EncodableToTLV & encodable = encoder;
return AddRequestData(aCommandPath, encodable, aAddRequestDataParams);
}

CHIP_ERROR TestOnlyFinishCommand(FinishCommandParameters & aFinishCommandParams)
Expand All @@ -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:
Expand Down

0 comments on commit 7e5bbb3

Please sign in to comment.