@@ -55,18 +55,19 @@ CHIP_ERROR GetRef(ParserT aParser, Optional<uint16_t> & aRef, bool commandRefReq
55
55
} // namespace
56
56
57
57
CommandSender::CommandSender (Callback * apCallback, Messaging::ExchangeManager * apExchangeMgr, bool aIsTimedRequest,
58
- bool aSuppressResponse) :
58
+ bool aSuppressResponse, bool aAllowLargePayload ) :
59
59
mExchangeCtx (*this ),
60
- mCallbackHandle (apCallback), mpExchangeMgr(apExchangeMgr), mSuppressResponse (aSuppressResponse), mTimedRequest (aIsTimedRequest)
60
+ mCallbackHandle (apCallback), mpExchangeMgr(apExchangeMgr), mSuppressResponse (aSuppressResponse), mTimedRequest (aIsTimedRequest),
61
+ mAllowLargePayload (aAllowLargePayload)
61
62
{
62
63
assertChipStackLockedByCurrentThread ();
63
64
}
64
65
65
66
CommandSender::CommandSender (ExtendableCallback * apExtendableCallback, Messaging::ExchangeManager * apExchangeMgr,
66
- bool aIsTimedRequest, bool aSuppressResponse) :
67
+ bool aIsTimedRequest, bool aSuppressResponse, bool aAllowLargePayload ) :
67
68
mExchangeCtx (*this ),
68
69
mCallbackHandle (apExtendableCallback), mpExchangeMgr(apExchangeMgr), mSuppressResponse (aSuppressResponse),
69
- mTimedRequest (aIsTimedRequest), mUseExtendableCallback (true )
70
+ mTimedRequest (aIsTimedRequest), mUseExtendableCallback (true ), mAllowLargePayload (aAllowLargePayload)
70
71
{
71
72
assertChipStackLockedByCurrentThread ();
72
73
#if CHIP_CONFIG_COMMAND_SENDER_BUILTIN_SUPPORT_FOR_BATCHED_COMMANDS
@@ -85,7 +86,15 @@ CHIP_ERROR CommandSender::AllocateBuffer()
85
86
{
86
87
mCommandMessageWriter .Reset ();
87
88
88
- System::PacketBufferHandle commandPacket = System::PacketBufferHandle::New (chip::app::kMaxSecureSduLengthBytes );
89
+ System::PacketBufferHandle commandPacket;
90
+ if (mAllowLargePayload )
91
+ {
92
+ commandPacket = System::PacketBufferHandle::New (kMaxLargeSecureSduLengthBytes );
93
+ }
94
+ else
95
+ {
96
+ commandPacket = System::PacketBufferHandle::New (kMaxSecureSduLengthBytes );
97
+ }
89
98
VerifyOrReturnError (!commandPacket.IsNull (), CHIP_ERROR_NO_MEMORY);
90
99
91
100
mCommandMessageWriter .Init (std::move (commandPacket));
@@ -139,6 +148,12 @@ CHIP_ERROR CommandSender::TestOnlyCommandSenderTimedRequestFlagWithNoTimedInvoke
139
148
140
149
CHIP_ERROR CommandSender::SendCommandRequest (const SessionHandle & session, Optional<System::Clock::Timeout> timeout)
141
150
{
151
+ // If the command is expected to be large, ensure that the underlying
152
+ // session supports it.
153
+ if (mAllowLargePayload )
154
+ {
155
+ VerifyOrReturnError (session->AllowsLargePayload (), CHIP_ERROR_INCORRECT_STATE);
156
+ }
142
157
143
158
if (mTimedRequest != mTimedInvokeTimeoutMs .HasValue ())
144
159
{
0 commit comments