@@ -492,10 +492,11 @@ CHIP_ERROR Engine::BuildAndSendSingleReportData(ReadHandler * apReadHandler)
492
492
CHIP_ERROR err = CHIP_NO_ERROR;
493
493
chip::System::PacketBufferTLVWriter reportDataWriter;
494
494
ReportDataMessage::Builder reportDataBuilder;
495
- chip::System::PacketBufferHandle bufHandle = System::PacketBufferHandle::New (chip::app::kMaxSecureSduLengthBytes );
496
- uint16_t reservedSize = 0 ;
497
- bool hasMoreChunks = false ;
498
- bool needCloseReadHandler = false ;
495
+ size_t maxSduSize = chip::app::kMaxSecureSduLengthBytes ;
496
+ chip::System::PacketBufferHandle bufHandle = nullptr ;
497
+ uint16_t reservedSize = 0 ;
498
+ bool hasMoreChunks = false ;
499
+ bool needCloseReadHandler = false ;
499
500
500
501
// Reserved size for the MoreChunks boolean flag, which takes up 1 byte for the control tag and 1 byte for the context tag.
501
502
const uint32_t kReservedSizeForMoreChunksFlag = 1 + 1 ;
@@ -512,11 +513,18 @@ CHIP_ERROR Engine::BuildAndSendSingleReportData(ReadHandler * apReadHandler)
512
513
513
514
VerifyOrExit (apReadHandler != nullptr , err = CHIP_ERROR_INVALID_ARGUMENT);
514
515
VerifyOrExit (apReadHandler->GetSession () != nullptr , err = CHIP_ERROR_INCORRECT_STATE);
516
+
517
+ if (apReadHandler->ShouldUseLargePayloadBuffer ())
518
+ {
519
+ maxSduSize = chip::app::kMaxLargeSecureSduLengthBytes ;
520
+ }
521
+
522
+ bufHandle = System::PacketBufferHandle::New (maxSduSize);
515
523
VerifyOrExit (!bufHandle.IsNull (), err = CHIP_ERROR_NO_MEMORY);
516
524
517
- if (bufHandle->AvailableDataLength () > kMaxSecureSduLengthBytes )
525
+ if (bufHandle->AvailableDataLength () > maxSduSize )
518
526
{
519
- reservedSize = static_cast <uint16_t >(bufHandle->AvailableDataLength () - kMaxSecureSduLengthBytes );
527
+ reservedSize = static_cast <uint16_t >(bufHandle->AvailableDataLength () - maxSduSize );
520
528
}
521
529
522
530
reportDataWriter.Init (std::move (bufHandle));
0 commit comments