Skip to content

Commit

Permalink
Add option to ChipTool to allow session setup for large payloads.
Browse files Browse the repository at this point in the history
By default, assumed false.
When set to true, it will trigger an attempt to set up a session over
TCP to support large payload transfers.
E.g., ./chip-tool onoff read on-off 15 2 --allow-large-payload true

Fixes #29697
  • Loading branch information
pidarped committed Jun 15, 2024
1 parent 667cae8 commit 51e4846
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
10 changes: 9 additions & 1 deletion examples/chip-tool/commands/clusters/ModelCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,11 @@ CHIP_ERROR ModelCommand::RunCommand()
return SendCommand(commissioneeDeviceProxy, mEndPointId);
}

// Check whether the session needs to allow large payload support.
TransportPayloadCapability transportPayloadCapability =
AllowLargePayload() ? TransportPayloadCapability::kLargePayload : TransportPayloadCapability::kMRPPayload;
return CurrentCommissioner().GetConnectedDevice(mDestinationId, &mOnDeviceConnectedCallback,
&mOnDeviceConnectionFailureCallback);
&mOnDeviceConnectionFailureCallback, transportPayloadCapability);
}

void ModelCommand::OnDeviceConnectedFn(void * context, chip::Messaging::ExchangeManager & exchangeMgr,
Expand Down Expand Up @@ -134,3 +137,8 @@ bool ModelCommand::IsPeerLIT()
CheckPeerICDType();
return mIsPeerLIT.ValueOr(false);
}

bool ModelCommand::AllowLargePayload()
{
return mAllowLargePayload.ValueOr(false);
}
6 changes: 6 additions & 0 deletions examples/chip-tool/commands/clusters/ModelCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ class ModelCommand : public CHIPCommand
"Whether to treat the peer as a LIT ICD. false: Always no, true: Always yes, (not set): Yes if the peer is registered "
"to this controller.");
AddArgument("timeout", 0, UINT16_MAX, &mTimeout);
AddArgument("allow-large-payload", 0, 1, &mAllowLargePayload,
"If true, indicates that the session should allow large application payloads (which requires a TCP connection)."
"Defaults to false, which uses a UDP+MRP session.");
}

/////////// CHIPCommand Interface /////////
Expand All @@ -82,9 +85,12 @@ class ModelCommand : public CHIPCommand
chip::NodeId mDestinationId;
std::vector<chip::EndpointId> mEndPointId;
chip::Optional<bool> mIsPeerLIT;
chip::Optional<bool> mAllowLargePayload;

void CheckPeerICDType();

bool AllowLargePayload();

static void OnDeviceConnectedFn(void * context, chip::Messaging::ExchangeManager & exchangeMgr,
const chip::SessionHandle & sessionHandle);
static void OnDeviceConnectionFailureFn(void * context, const chip::ScopedNodeId & peerId, CHIP_ERROR error);
Expand Down

0 comments on commit 51e4846

Please sign in to comment.