Skip to content

Commit

Permalink
Set response timeout value during echo SendMessage (project-chip#9096)
Browse files Browse the repository at this point in the history
  • Loading branch information
yufengwangca authored Aug 18, 2021
1 parent 1ec6161 commit 98e5494
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/protocols/echo/EchoClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ namespace chip {
namespace Protocols {
namespace Echo {

// The Echo message timeout value in milliseconds.
constexpr uint32_t kEchoMessageTimeoutMsec = 800;

CHIP_ERROR EchoClient::Init(Messaging::ExchangeManager * exchangeMgr, SecureSessionHandle session)
{
// Error if already initialized.
Expand Down Expand Up @@ -74,6 +77,8 @@ CHIP_ERROR EchoClient::SendEchoRequest(System::PacketBufferHandle && payload, Me
return CHIP_ERROR_NO_MEMORY;
}

mExchangeCtx->SetResponseTimeout(kEchoMessageTimeoutMsec);

// Send an Echo Request message. Discard the exchange context if the send fails.
err = mExchangeCtx->SendMessage(MsgType::EchoRequest, std::move(payload),
sendFlags.Set(Messaging::SendMessageFlags::kExpectResponse));
Expand Down Expand Up @@ -114,6 +119,7 @@ CHIP_ERROR EchoClient::OnMessageReceived(Messaging::ExchangeContext * ec, const

void EchoClient::OnResponseTimeout(Messaging::ExchangeContext * ec)
{
mExchangeCtx = nullptr;
ChipLogProgress(Echo, "Time out! failed to receive echo response from Exchange: %p", ec);
}

Expand Down

0 comments on commit 98e5494

Please sign in to comment.