Skip to content

Commit

Permalink
ota-requestor: Handle QueryImageResponse status and ApplyUpdateRespon…
Browse files Browse the repository at this point in the history
…se status (#13770)

* ota-requestor: Align delayedActionTime with Spec in response

- Schedule next QueryImage as per delay specified in Specification
- Schedule next ApplyUpdateRequest as per delay specified in
  Specification

* Defined a constant for default delayedActionTime
  • Loading branch information
shubhamdp authored Jan 22, 2022
1 parent d6b2a6b commit cc6bd90
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/platform/GenericOTARequestorDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ GenericOTARequestorDriver * ToDriver(void * context)
return static_cast<GenericOTARequestorDriver *>(context);
}

constexpr System::Clock::Seconds32 kDefaultDelayedActionTime = System::Clock::Seconds32(120);

} // namespace

bool GenericOTARequestorDriver::CanConsent()
Expand All @@ -58,7 +60,15 @@ void GenericOTARequestorDriver::UpdateAvailable(const UpdateDescription & update

void GenericOTARequestorDriver::UpdateNotFound(UpdateNotFoundReason reason, System::Clock::Seconds32 delay)
{
// TODO: Schedule the next QueryImage
VerifyOrDie(mRequestor != nullptr);

if (delay < kDefaultDelayedActionTime)
{
delay = kDefaultDelayedActionTime;
}

ScheduleDelayedAction(UpdateFailureState::kQuerying, delay,
[](System::Layer *, void * context) { ToDriver(context)->mRequestor->TriggerImmediateQuery(); });
}

void GenericOTARequestorDriver::UpdateDownloaded()
Expand All @@ -77,6 +87,12 @@ void GenericOTARequestorDriver::UpdateConfirmed(System::Clock::Seconds32 delay)
void GenericOTARequestorDriver::UpdateSuspended(System::Clock::Seconds32 delay)
{
VerifyOrDie(mRequestor != nullptr);

if (delay < kDefaultDelayedActionTime)
{
delay = kDefaultDelayedActionTime;
}

ScheduleDelayedAction(UpdateFailureState::kAwaitingNextAction, delay,
[](System::Layer *, void * context) { ToDriver(context)->mRequestor->ApplyUpdate(); });
}
Expand Down

0 comments on commit cc6bd90

Please sign in to comment.