Skip to content

Commit

Permalink
Implemented fix for Issue project-chip#18824.
Browse files Browse the repository at this point in the history
  • Loading branch information
isiu-apple committed May 27, 2022
1 parent dbc91b7 commit f7a7e57
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions examples/ota-requestor-app/linux/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ bool CustomOTARequestorDriver::CanConsent()

void CustomOTARequestorDriver::UpdateDownloaded()
{
ChipLogError(SoftwareUpdate, "//is: CustomOTARequestorDriver::UpdateDownloaded");

// Download complete so reset provider retry counter
mProviderRetryCount = 0;

if (gAutoApplyImage)
{
// Let the default driver take further action to apply the image
Expand Down
4 changes: 4 additions & 0 deletions src/app/clusters/ota-requestor/DefaultOTARequestor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -609,14 +609,18 @@ CHIP_ERROR DefaultOTARequestor::AddDefaultOtaProvider(const ProviderLocationType

void DefaultOTARequestor::OnDownloadStateChanged(OTADownloader::State state, OTAChangeReasonEnum reason)
{
ChipLogError(SoftwareUpdate, "//is: DefaultOTARequestor::OnDownloadStateChanged");

VerifyOrDie(mOtaRequestorDriver != nullptr);

switch (state)
{
case OTADownloader::State::kComplete:
ChipLogError(SoftwareUpdate, "//is: DefaultOTARequestor::OnDownloadStateChanged - kComplete");
mOtaRequestorDriver->UpdateDownloaded();
break;
case OTADownloader::State::kIdle:
ChipLogError(SoftwareUpdate, "//is: DefaultOTARequestor::OnDownloadStateChanged - kIdle");
if (reason != OTAChangeReasonEnum::kSuccess)
{
RecordErrorUpdateState(CHIP_ERROR_CONNECTION_ABORTED, reason);
Expand Down
11 changes: 11 additions & 0 deletions src/app/clusters/ota-requestor/DefaultOTARequestorDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ void DefaultOTARequestorDriver::HandleIdleStateEnter(IdleStateReason reason)
StartSelectedTimer(SelectedTimer::kPeriodicQueryTimer);
break;
case IdleStateReason::kInvalidSession:
ChipLogProgress(SoftwareUpdate, "//is: DefaultOTARequestorDriver::HandleIdleStateEnter mInvalidSessionRetryCount=%u, mProviderRetryCount=%u",
mInvalidSessionRetryCount, mProviderRetryCount);
if (mInvalidSessionRetryCount < kMaxInvalidSessionRetries)
{
// An invalid session is detected which may be temporary (such as provider being restarted)
Expand Down Expand Up @@ -224,12 +226,19 @@ CHIP_ERROR DefaultOTARequestorDriver::UpdateNotFound(UpdateNotFoundReason reason

void DefaultOTARequestorDriver::UpdateDownloaded()
{
ChipLogError(SoftwareUpdate, "//is: DefaultOTARequestorDriver::UpdateDownloaded");

// Download complete so reset provider retry counter
mProviderRetryCount = 0;

VerifyOrDie(mRequestor != nullptr);
mRequestor->ApplyUpdate();
}

void DefaultOTARequestorDriver::UpdateConfirmed(System::Clock::Seconds32 delay)
{
ChipLogError(SoftwareUpdate, "//is: DefaultOTARequestorDriver::UpdateConfirmed");

VerifyOrDie(mImageProcessor != nullptr);
ScheduleDelayedAction(delay, ApplyTimerHandler, this);
}
Expand Down Expand Up @@ -472,6 +481,8 @@ CHIP_ERROR DefaultOTARequestorDriver::ScheduleQueryRetry(bool trySameProvider, S
{
CHIP_ERROR status = CHIP_NO_ERROR;

ChipLogProgress(SoftwareUpdate, "//is: DefaultOTARequestorDriver::ScheduleQueryRetry mProviderRetryCount=%u", mProviderRetryCount);

if (trySameProvider == false)
{
VerifyOrDie(mRequestor != nullptr);
Expand Down

0 comments on commit f7a7e57

Please sign in to comment.