Skip to content

Commit

Permalink
In the BdxOtaSender::TransferFacilitator.cpp there is no way currentl… (
Browse files Browse the repository at this point in the history
#20192)

* In the BdxOtaSender::TransferFacilitator.cpp there is no way currently to cancel the PollTimerHandler, as needed, when receiving an kAckEOFReceived . The problem is that calling chip::DeviceLayer::SystemLayer().CancelTimer(PollTimerHandler, this); upon receiving kAckEOFReceived, it does not cancel the PollTimerHandler, as TransferFacilitator::PollForOutput() re-registers it.

Proposed Solution

While the BdxOtaSender was provided as en example, that terminates when upon completing the Bdx transfer, the TransferFacilitator.cpp needs to allow cancelling the PollTimerHandler.

To accomplish it, adding a mStopPolling flag in TransferFacilitator::PollForOutput() allowed for cancelling the PollTimerHandler.

* Update src/protocols/bdx/TransferFacilitator.cpp

Make clear that that a transfer facilitator cannot be reused.

Co-authored-by: Tennessee Carmel-Veilleux <tennessee.carmelveilleux@gmail.com>

Co-authored-by: Tennessee Carmel-Veilleux <tennessee.carmelveilleux@gmail.com>
  • Loading branch information
2 people authored and pull[bot] committed Oct 27, 2023
1 parent 66ac1ee commit 1229470
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ void BdxOtaSender::HandleTransferSessionOutput(TransferSession::OutputEvent & ev
break;
case TransferSession::OutputEventType::kAckEOFReceived:
ChipLogDetail(BDX, "Transfer completed, got AckEOF");
mStopPolling = true;
Reset();
break;
case TransferSession::OutputEventType::kStatusReceived:
Expand Down
10 changes: 9 additions & 1 deletion src/protocols/bdx/TransferFacilitator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,15 @@ void TransferFacilitator::PollForOutput()
HandleTransferSessionOutput(outEvent);

VerifyOrReturn(mSystemLayer != nullptr, ChipLogError(BDX, "%s mSystemLayer is null", __FUNCTION__));
mSystemLayer->StartTimer(mPollFreq, PollTimerHandler, this);
if (!mStopPolling)
{
mSystemLayer->StartTimer(mPollFreq, PollTimerHandler, this);
}
else
{
mSystemLayer->CancelTimer(PollTimerHandler, this);
mStopPolling = false;
}
}

void TransferFacilitator::ScheduleImmediatePoll()
Expand Down
1 change: 1 addition & 0 deletions src/protocols/bdx/TransferFacilitator.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ class TransferFacilitator : public Messaging::ExchangeDelegate, public Messaging
System::Clock::Timeout mPollFreq;
static constexpr System::Clock::Timeout kDefaultPollFreq = System::Clock::Milliseconds32(500);
static constexpr System::Clock::Timeout kImmediatePollDelay = System::Clock::Milliseconds32(1);
bool mStopPolling = false;
};

/**
Expand Down

0 comments on commit 1229470

Please sign in to comment.