Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not reset state if query image is not available (either not availa… #25068

Merged
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