Skip to content

Commit

Permalink
Do not reset state if query image is not available (either not availa… (
Browse files Browse the repository at this point in the history
#25068)

* Do not reset state if query image is not available (either not available, or protocol not supported or if delegate returns busy)

* Update src/darwin/Framework/CHIP/MTROTAProviderDelegateBridge.mm

Co-authored-by: Boris Zbarsky <[email protected]>

* Addressed review comments

* Update src/darwin/Framework/CHIP/MTROTAProviderDelegateBridge.mm

Co-authored-by: Boris Zbarsky <[email protected]>

* fix format specifier for nodeid and fabric index in the logs

* Update src/darwin/Framework/CHIP/MTROTAProviderDelegateBridge.mm

Co-authored-by: Carol Yang <[email protected]>

* Fix style and bump up the default retry delay we communicate.

---------

Co-authored-by: Boris Zbarsky <[email protected]>
Co-authored-by: Carol Yang <[email protected]>
  • Loading branch information
3 people authored and pull[bot] committed Mar 15, 2023
1 parent f872387 commit 2923761
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
18 changes: 15 additions & 3 deletions src/darwin/Framework/CHIP/MTROTAProviderDelegateBridge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,13 @@
// we just double the timeout to give enough time for the BDX init to come in a reasonable amount of time.
constexpr System::Clock::Timeout kBdxInitReceivedTimeout = System::Clock::Seconds16(10 * 60);

// Time in seconds after which the requestor should retry calling query image if busy status is receieved
constexpr uint32_t kDelayedActionTimeSeconds = 120;
// Time in seconds after which the requestor should retry calling query image if
// busy status is receieved. The spec minimum is 2 minutes, but in practice OTA
// generally takes a lot longer than that and devices only retry a few times
// before giving up. Default to 10 minutes for now, until we have a better
// system of computing an expected completion time for the currently-running
// OTA.
constexpr uint32_t kDelayedActionTimeSeconds = 600;

constexpr System::Clock::Timeout kBdxTimeout = System::Clock::Seconds16(5 * 60); // OTA Spec mandates >= 5 minutes
constexpr System::Clock::Timeout kBdxPollIntervalMs = System::Clock::Milliseconds32(50);
Expand Down Expand Up @@ -132,6 +137,14 @@ void SetDelegate(id<MTROTAProviderDelegate> delegate, dispatch_queue_t delegateN
void ResetState()
{
assertChipStackLockedByCurrentThread();
if (mNodeId.HasValue() && mFabricIndex.HasValue()) {
ChipLogProgress(Controller,
"Resetting state for OTA Provider; no longer providing an update for node id 0x" ChipLogFormatX64
", fabric index %u",
ChipLogValueX64(mNodeId.Value()), mFabricIndex.Value());
} else {
ChipLogProgress(Controller, "Resetting state for OTA Provider");
}
if (mSystemLayer) {
mSystemLayer->CancelTimer(HandleBdxInitReceivedTimeoutExpired, this);
}
Expand Down Expand Up @@ -678,7 +691,6 @@ bool GetPeerNodeInfo(CommandHandler * commandHandler, const ConcreteCommandPath
handler->AddResponse(cachedCommandPath, protocolNotSupportedResponse);
}
handle.Release();
gOtaSender.ResetState();
}

errorHandler:^(NSError *) {
Expand Down
4 changes: 3 additions & 1 deletion src/protocols/bdx/TransferFacilitator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,19 @@ CHIP_ERROR Responder::PrepareForTransfer(System::Layer * layer, TransferRole rol

mPollFreq = pollFreq;
mSystemLayer = layer;
mStopPolling = false;

ReturnErrorOnFailure(mTransfer.WaitForTransfer(role, xferControlOpts, maxBlockSize, timeout));

ChipLogProgress(BDX, "Start polling for messages");
mStopPolling = false;
mSystemLayer->StartTimer(mPollFreq, PollTimerHandler, this);
return CHIP_NO_ERROR;
}

void Responder::ResetTransfer()
{
mTransfer.Reset();
ChipLogProgress(BDX, "Stop polling for messages");
mStopPolling = true;
}

Expand Down

0 comments on commit 2923761

Please sign in to comment.