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 1, 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 1

Fixes project-chip#29697
  • Loading branch information
pidarped committed Jun 14, 2024
1 parent 60ae46d commit 78d5856
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
18 changes: 17 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,12 @@ CHIP_ERROR ModelCommand::RunCommand()
return SendCommand(commissioneeDeviceProxy, mEndPointId);
}

// Check if 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 +138,15 @@ bool ModelCommand::IsPeerLIT()
CheckPeerICDType();
return mIsPeerLIT.ValueOr(false);
}

bool ModelCommand::AllowLargePayload()
{
if (mAllowLargePayload.HasValue())
{
return (mAllowLargePayload.Value());
}
else
{
return false;
}
}
5 changes: 5 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,8 @@ 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,
"Indicates if the session should allow large application payloads. When true, the controller tries to establish a secure session over TCP. Otherwise session is established over MRP. Assumed to be false when not specified.");
}

/////////// CHIPCommand Interface /////////
Expand All @@ -82,9 +84,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 78d5856

Please sign in to comment.