Skip to content

Commit 794e163

Browse files
nivi-applebzbarsky-applecarol-apple
authored andcommitted
Do not reset state if query image is not available (either not availa… (#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]>
1 parent e94a319 commit 794e163

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

src/darwin/Framework/CHIP/MTROTAProviderDelegateBridge.mm

+15-3
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,13 @@
4949
// we just double the timeout to give enough time for the BDX init to come in a reasonable amount of time.
5050
constexpr System::Clock::Timeout kBdxInitReceivedTimeout = System::Clock::Seconds16(10 * 60);
5151

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

5560
constexpr System::Clock::Timeout kBdxTimeout = System::Clock::Seconds16(5 * 60); // OTA Spec mandates >= 5 minutes
5661
constexpr System::Clock::Timeout kBdxPollIntervalMs = System::Clock::Milliseconds32(50);
@@ -132,6 +137,14 @@ void SetDelegate(id<MTROTAProviderDelegate> delegate, dispatch_queue_t delegateN
132137
void ResetState()
133138
{
134139
assertChipStackLockedByCurrentThread();
140+
if (mNodeId.HasValue() && mFabricIndex.HasValue()) {
141+
ChipLogProgress(Controller,
142+
"Resetting state for OTA Provider; no longer providing an update for node id 0x" ChipLogFormatX64
143+
", fabric index %u",
144+
ChipLogValueX64(mNodeId.Value()), mFabricIndex.Value());
145+
} else {
146+
ChipLogProgress(Controller, "Resetting state for OTA Provider");
147+
}
135148
if (mSystemLayer) {
136149
mSystemLayer->CancelTimer(HandleBdxInitReceivedTimeoutExpired, this);
137150
}
@@ -678,7 +691,6 @@ bool GetPeerNodeInfo(CommandHandler * commandHandler, const ConcreteCommandPath
678691
handler->AddResponse(cachedCommandPath, protocolNotSupportedResponse);
679692
}
680693
handle.Release();
681-
gOtaSender.ResetState();
682694
}
683695

684696
errorHandler:^(NSError *) {

src/protocols/bdx/TransferFacilitator.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -102,17 +102,19 @@ CHIP_ERROR Responder::PrepareForTransfer(System::Layer * layer, TransferRole rol
102102

103103
mPollFreq = pollFreq;
104104
mSystemLayer = layer;
105-
mStopPolling = false;
106105

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

108+
ChipLogProgress(BDX, "Start polling for messages");
109+
mStopPolling = false;
109110
mSystemLayer->StartTimer(mPollFreq, PollTimerHandler, this);
110111
return CHIP_NO_ERROR;
111112
}
112113

113114
void Responder::ResetTransfer()
114115
{
115116
mTransfer.Reset();
117+
ChipLogProgress(BDX, "Stop polling for messages");
116118
mStopPolling = true;
117119
}
118120

0 commit comments

Comments
 (0)