From 51e4846460a6760800fc53206dadda26a255f932 Mon Sep 17 00:00:00 2001 From: Pradip De Date: Fri, 14 Jun 2024 15:54:05 -0700 Subject: [PATCH] Add option to ChipTool to allow session setup for large payloads. 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 --- examples/chip-tool/commands/clusters/ModelCommand.cpp | 10 +++++++++- examples/chip-tool/commands/clusters/ModelCommand.h | 6 ++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/examples/chip-tool/commands/clusters/ModelCommand.cpp b/examples/chip-tool/commands/clusters/ModelCommand.cpp index b2e3b5616703a4..03a54c59891aba 100644 --- a/examples/chip-tool/commands/clusters/ModelCommand.cpp +++ b/examples/chip-tool/commands/clusters/ModelCommand.cpp @@ -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, @@ -134,3 +137,8 @@ bool ModelCommand::IsPeerLIT() CheckPeerICDType(); return mIsPeerLIT.ValueOr(false); } + +bool ModelCommand::AllowLargePayload() +{ + return mAllowLargePayload.ValueOr(false); +} diff --git a/examples/chip-tool/commands/clusters/ModelCommand.h b/examples/chip-tool/commands/clusters/ModelCommand.h index 635c03a2ebdf7c..f9ae83aed79f0a 100644 --- a/examples/chip-tool/commands/clusters/ModelCommand.h +++ b/examples/chip-tool/commands/clusters/ModelCommand.h @@ -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 ///////// @@ -82,9 +85,12 @@ class ModelCommand : public CHIPCommand chip::NodeId mDestinationId; std::vector mEndPointId; chip::Optional mIsPeerLIT; + chip::Optional 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);