@@ -113,7 +113,7 @@ CHIP_ERROR ExchangeContext::SendMessage(Protocols::Id protocolId, uint8_t msgTyp
113
113
// If session requires MRP, NoAutoRequestAck send flag is not specified and is not a group exchange context, request reliable
114
114
// transmission.
115
115
bool reliableTransmissionRequested =
116
- GetSessionHandle ()->RequireMRP () && !sendFlags.Has (SendMessageFlags::kNoAutoRequestAck ) && !IsGroupExchangeContext ();
116
+ GetSessionHandle ()->AllowsMRP () && !sendFlags.Has (SendMessageFlags::kNoAutoRequestAck ) && !IsGroupExchangeContext ();
117
117
118
118
bool currentMessageExpectResponse = false ;
119
119
// If a response message is expected...
@@ -322,8 +322,8 @@ ExchangeContext::ExchangeContext(ExchangeManager * em, uint16_t ExchangeId, cons
322
322
323
323
SetAckPending (false );
324
324
325
- // Do not request Ack for multicast
326
- SetAutoRequestAck (! session->IsGroupSession ());
325
+ // Try to use MRP by default, if it is allowed.
326
+ SetAutoRequestAck (session->AllowsMRP ());
327
327
328
328
#if CHIP_CONFIG_ENABLE_ICD_SERVER
329
329
app::ICDNotifier::GetInstance ().BroadcastActiveRequestNotification (app::ICDListener::KeepActiveFlag::kExchangeContextOpen );
@@ -531,58 +531,64 @@ CHIP_ERROR ExchangeContext::HandleMessage(uint32_t messageCounter, const Payload
531
531
MessageHandled ();
532
532
});
533
533
534
- if (mDispatch . IsReliableTransmissionAllowed () && ! IsGroupExchangeContext ())
534
+ if (mSession -> AllowsMRP ())
535
535
{
536
- if (!msgFlags.Has (MessageFlagValues::kDuplicateMessage ) && payloadHeader.IsAckMsg () &&
537
- payloadHeader.GetAckMessageCounter ().HasValue ())
536
+ if (mDispatch .IsReliableTransmissionAllowed ())
538
537
{
539
- HandleRcvdAck (payloadHeader.GetAckMessageCounter ().Value ());
538
+ if (!msgFlags.Has (MessageFlagValues::kDuplicateMessage ) && payloadHeader.IsAckMsg () &&
539
+ payloadHeader.GetAckMessageCounter ().HasValue ())
540
+ {
541
+ HandleRcvdAck (payloadHeader.GetAckMessageCounter ().Value ());
542
+ }
543
+
544
+ if (payloadHeader.NeedsAck ())
545
+ {
546
+ // An acknowledgment needs to be sent back to the peer for this message on this exchange,
547
+ HandleNeedsAck (messageCounter, msgFlags);
548
+ }
540
549
}
541
550
542
- if (payloadHeader. NeedsAck () )
551
+ if (IsAckPending () && ! mDelegate )
543
552
{
544
- // An acknowledgment needs to be sent back to the peer for this message on this exchange,
545
- HandleNeedsAck (messageCounter, msgFlags);
553
+ // The incoming message wants an ack, but we have no delegate, so
554
+ // there's not going to be a response to piggyback on. Just flush the
555
+ // ack out right now.
556
+ ReturnErrorOnFailure (FlushAcks ());
546
557
}
547
- }
548
558
549
- if (IsAckPending () && !mDelegate )
550
- {
551
- // The incoming message wants an ack, but we have no delegate, so
552
- // there's not going to be a response to piggyback on. Just flush the
553
- // ack out right now.
554
- ReturnErrorOnFailure (FlushAcks ());
555
- }
556
-
557
- // The SecureChannel::StandaloneAck message type is only used for MRP; do not pass such messages to the application layer.
558
- if (isStandaloneAck)
559
- {
560
- return CHIP_NO_ERROR;
561
- }
559
+ // The SecureChannel::StandaloneAck message type is only used for MRP; do not pass such messages to the application layer.
560
+ if (isStandaloneAck)
561
+ {
562
+ return CHIP_NO_ERROR;
563
+ }
564
+ } // AllowsMRP
562
565
563
566
// Since the message is duplicate, let's not forward it up the stack
564
567
if (isDuplicate)
565
568
{
566
569
return CHIP_NO_ERROR;
567
570
}
568
571
569
- if (IsEphemeralExchange ())
572
+ if (mSession -> AllowsMRP ())
570
573
{
571
- // The EphemeralExchange has done its job, since StandaloneAck is sent in previous FlushAcks() call.
572
- return CHIP_NO_ERROR;
573
- }
574
+ if (IsEphemeralExchange ())
575
+ {
576
+ // The EphemeralExchange has done its job, since StandaloneAck is sent in previous FlushAcks() call.
577
+ return CHIP_NO_ERROR;
578
+ }
574
579
575
- if (IsWaitingForAck ())
576
- {
577
- // The only way we can get here is a spec violation on the other side:
578
- // we sent a message that needs an ack, and the other side responded
579
- // with a message that does not contain an ack for the message we sent.
580
- // Just drop this message; if we delivered it to our delegate it might
581
- // try to send another message-needing-an-ack in response, which would
582
- // violate our internal invariants.
583
- ChipLogError (ExchangeManager, " Dropping message without piggyback ack when we are waiting for an ack." );
584
- return CHIP_ERROR_INCORRECT_STATE;
585
- }
580
+ if (IsWaitingForAck ())
581
+ {
582
+ // The only way we can get here is a spec violation on the other side:
583
+ // we sent a message that needs an ack, and the other side responded
584
+ // with a message that does not contain an ack for the message we sent.
585
+ // Just drop this message; if we delivered it to our delegate it might
586
+ // try to send another message-needing-an-ack in response, which would
587
+ // violate our internal invariants.
588
+ ChipLogError (ExchangeManager, " Dropping message without piggyback ack when we are waiting for an ack." );
589
+ return CHIP_ERROR_INCORRECT_STATE;
590
+ }
591
+ } // AllowsMRP
586
592
587
593
#if CHIP_CONFIG_ENABLE_ICD_SERVER
588
594
// message received
0 commit comments