Skip to content

Commit

Permalink
fix exchange context closing
Browse files Browse the repository at this point in the history
  • Loading branch information
holbrookt committed Dec 3, 2021
1 parent 793213e commit c6ba4e4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ CHIP_ERROR LinuxOTAImageProcessor::Abort()

CHIP_ERROR LinuxOTAImageProcessor::ProcessBlock(ByteSpan & block)
{
ChipLogDetail(BDX, "TREVOR %s", __FUNCTION__);
if (!mOfs.is_open() || !mOfs.good())
{
return CHIP_ERROR_INTERNAL;
Expand Down
9 changes: 8 additions & 1 deletion src/app/clusters/ota-requestor/BDXDownloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <lib/core/CHIPError.h>
#include <lib/support/CodeUtils.h>
#include <protocols/bdx/BdxMessages.h>

using chip::OTADownloader;
using chip::bdx::TransferSession;
Expand Down Expand Up @@ -130,17 +131,23 @@ CHIP_ERROR BDXDownloader::HandleBdxEvent(const chip::bdx::TransferSession::Outpu
case TransferSession::OutputEventType::kMsgToSend: {
VerifyOrReturnError(mMsgDelegate != nullptr, CHIP_ERROR_INCORRECT_STATE);
ReturnErrorOnFailure(mMsgDelegate->SendMessage(outEvent));
if (outEvent.msgTypeData.HasMessageType(chip::bdx::MessageType::BlockAckEOF))
{
mState = State::kComplete;
}
break;
}
case TransferSession::OutputEventType::kBlockReceived: {
chip::ByteSpan blockData(outEvent.blockdata.Data, outEvent.blockdata.Length);
ReturnErrorOnFailure(mImageProcessor->ProcessBlock(blockData));

// TODO: could calling Finalize immediately after ProcessBlock cause issues?
// TODO: this will cause problems if Finalize() is not guaranteed to do its work after ProcessBlock().
if (outEvent.blockdata.IsEof)
{
mBdxTransfer.PrepareBlockAck();
ReturnErrorOnFailure(mImageProcessor->Finalize());
}

break;
}
case TransferSession::OutputEventType::kStatusReceived:
Expand Down
7 changes: 6 additions & 1 deletion src/app/clusters/ota-requestor/OTARequestor.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,13 @@ class OTARequestor : public OTARequestorInterface
else
{
mDownloader->OnMessageReceived(payloadHeader, payload.Retain());
return CHIP_NO_ERROR;
}

if (!payloadHeader.HasMessageType(chip::Protocols::SecureChannel::MsgType::StatusReport))
{
ec->WillSendMessage();
}
return CHIP_NO_ERROR;
}

void OnResponseTimeout(chip::Messaging::ExchangeContext * ec) override
Expand Down

0 comments on commit c6ba4e4

Please sign in to comment.