Skip to content

Commit

Permalink
Fixing this
Browse files Browse the repository at this point in the history
  • Loading branch information
woody-apple committed Feb 10, 2024
1 parent 5e3b2fa commit f87e100
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 10 deletions.
29 changes: 24 additions & 5 deletions src/messaging/ReliableMessageMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <messaging/ReliableMessageContext.h>
#include <messaging/ReliableMessageMgr.h>
#include <platform/ConnectivityManager.h>
#include <transport/Session.h>

#if CHIP_CONFIG_ENABLE_ICD_SERVER
#include <app/icd/server/ICDConfigurationData.h> // nogncheck
Expand Down Expand Up @@ -125,10 +126,28 @@ void ReliableMessageMgr::ExecuteActions()

VerifyOrDie(!entry->retainedBuf.IsNull());

uint8_t sendCount = entry->sendCount;
SessionHandle session = ec->GetSessionHandle();
NodeId nodeId = session->GetPeerNodeId();
uint8_t sendCount = entry->sendCount;
NodeId nodeId = 0;

#if CHIP_ERROR_LOGGING || CHIP_DETAIL_LOGGING
SessionHandle session = entry->ec->GetSessionHandle();
switch (session->GetSessionType())
{
case Transport::Session::SessionType::kSecure: {
Transport::SecureSession * secureSession = session->AsSecureSession();
nodeId = secureSession->GetPeerNodeId();
break;
}

case Transport::Session::SessionType::kUnauthenticated: {
Transport::UnauthenticatedSession * unsecuredSession = session->AsUnauthenticatedSession();
nodeId = unsecuredSession->GetPeerNodeId();
break;
}
default:
break;
}

uint32_t messageCounter = entry->retainedBuf.GetMessageCounter();
#endif // CHIP_ERROR_LOGGING || CHIP_DETAIL_LOGGING

Expand All @@ -139,7 +158,7 @@ void ReliableMessageMgr::ExecuteActions()

ChipLogError(ExchangeManager,
"Failed to Send CHIP MessageCounter:" ChipLogFormatMessageCounter " on exchange " ChipLogFormatExchange
" sendCount: %u max retries: %d Peer = %02x",
" sendCount: %u max retries: %d Peer = " ChipLogFormatX64,
messageCounter, ChipLogValueExchange(&ec.Get()), sendCount, CHIP_CONFIG_RMP_DEFAULT_MAX_RETRANS,
ChipLogValueX64(nodeId));

Expand Down Expand Up @@ -167,7 +186,7 @@ void ReliableMessageMgr::ExecuteActions()
entry->sendCount++;
ChipLogProgress(ExchangeManager,
"Retransmitting MessageCounter:" ChipLogFormatMessageCounter " on exchange " ChipLogFormatExchange
" Send Cnt %d Peer = %02x",
" Send Cnt %d Peer = " ChipLogFormatX64,
messageCounter, ChipLogValueExchange(&entry->ec.Get()), entry->sendCount, ChipLogValueX64(nodeId));

CalculateNextRetransTime(*entry);
Expand Down
32 changes: 27 additions & 5 deletions src/protocols/secure_channel/CASESession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -550,11 +550,33 @@ void CASESession::OnResponseTimeout(ExchangeContext * ec)
MATTER_TRACE_SCOPE("OnResponseTimeout", "CASESession");
VerifyOrReturn(ec != nullptr, ChipLogError(SecureChannel, "CASESession::OnResponseTimeout was called by null exchange"));
VerifyOrReturn(mExchangeCtxt == ec, ChipLogError(SecureChannel, "CASESession::OnResponseTimeout exchange doesn't match"));
SessionHandle session ec->GetSessionHandle();
NodeId nodeId = session->GetPeerNodeId();
ChipLogError(SecureChannel,
"CASESession timed out while waiting for a response from the peer. Current state was %u Peer = %02x",
to_underlying(mState), ChipLogValueX64(nodeId));
SessionHandle session = ec->GetSessionHandle();
NodeId nodeId = 0;

#if CHIP_ERROR_LOGGING || CHIP_DETAIL_LOGGING
switch (session->GetSessionType())
{
case Transport::Session::SessionType::kSecure: {
Transport::SecureSession * secureSession = session->AsSecureSession();
nodeId = secureSession->GetPeerNodeId();
break;
}

case Transport::Session::SessionType::kUnauthenticated: {
Transport::UnauthenticatedSession * unsecuredSession = session->AsUnauthenticatedSession();
nodeId = unsecuredSession->GetPeerNodeId();
break;
}
default:
break;
}
#endif // CHIP_ERROR_LOGGING || CHIP_DETAIL_LOGGING

ChipLogError(
SecureChannel,
"CASESession timed out while waiting for a response from the peer. Current state was %u Peer = " ChipLogFormatX64,
to_underlying(mState), ChipLogValueX64(nodeId));

MATTER_TRACE_COUNTER("CASETimeout");
// Discard the exchange so that Clear() doesn't try aborting it. The
// exchange will handle that.
Expand Down

0 comments on commit f87e100

Please sign in to comment.