diff --git a/src/messaging/ReliableMessageMgr.cpp b/src/messaging/ReliableMessageMgr.cpp index 4168909f692a2c..f2727d321a7e16 100644 --- a/src/messaging/ReliableMessageMgr.cpp +++ b/src/messaging/ReliableMessageMgr.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #if CHIP_CONFIG_ENABLE_ICD_SERVER #include // nogncheck @@ -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 @@ -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)); @@ -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); diff --git a/src/protocols/secure_channel/CASESession.cpp b/src/protocols/secure_channel/CASESession.cpp index 0454bd2237a5ce..ed56f869eb4046 100644 --- a/src/protocols/secure_channel/CASESession.cpp +++ b/src/protocols/secure_channel/CASESession.cpp @@ -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.