diff --git a/src/app/clusters/ota-requestor/DefaultOTARequestor.cpp b/src/app/clusters/ota-requestor/DefaultOTARequestor.cpp index 7f951503043d5d..d1a86a678636d8 100644 --- a/src/app/clusters/ota-requestor/DefaultOTARequestor.cpp +++ b/src/app/clusters/ota-requestor/DefaultOTARequestor.cpp @@ -648,9 +648,6 @@ IdleStateReason DefaultOTARequestor::MapErrorToIdleStateReason(CHIP_ERROR error) void DefaultOTARequestor::RecordNewUpdateState(OTAUpdateStateEnum newState, OTAChangeReasonEnum reason, CHIP_ERROR error) { - ChipLogProgress(SoftwareUpdate, "//is: DefaultOTARequestorDriver::HandleIdleStateEnter newState %hhu, reason %hhu", newState, reason); - ChipLogProgress(SoftwareUpdate, "//is: DefaultOTARequestorDriver::HandleIdleStateEnter error %" CHIP_ERROR_FORMAT, error.Format()); - bool handleIdleStateEnter = true; IdleStateReason idleStateReason = IdleStateReason::kUnknown; diff --git a/src/app/clusters/ota-requestor/DefaultOTARequestorDriver.cpp b/src/app/clusters/ota-requestor/DefaultOTARequestorDriver.cpp index 612bc6a7c789d4..71e26ad63f3da3 100644 --- a/src/app/clusters/ota-requestor/DefaultOTARequestorDriver.cpp +++ b/src/app/clusters/ota-requestor/DefaultOTARequestorDriver.cpp @@ -45,6 +45,7 @@ namespace { using namespace app::Clusters::OtaSoftwareUpdateRequestor; using namespace app::Clusters::OtaSoftwareUpdateRequestor::Structs; +constexpr uint8_t kMaxInvalidSessionRetries = 3; // Max # of query image retries to perform on invalid session error constexpr uint32_t kDelayQueryUponCommissioningSec = 30; // Delay before sending the initial image query after commissioning constexpr uint32_t kImmediateStartDelaySec = 1; // Delay before sending a query in response to UrgentUpdateAvailable constexpr System::Clock::Seconds32 kDefaultDelayedActionTime = System::Clock::Seconds32(120); @@ -61,6 +62,7 @@ void DefaultOTARequestorDriver::Init(OTARequestorInterface * requestor, OTAImage mRequestor = requestor; mImageProcessor = processor; mProviderRetryCount = 0; + mInvalidSessionRetryCount = 0; if (mImageProcessor->IsFirstImageRun()) { @@ -127,21 +129,30 @@ void DefaultOTARequestorDriver::HandleIdleStateExit() void DefaultOTARequestorDriver::HandleIdleStateEnter(IdleStateReason reason) { - ChipLogProgress(SoftwareUpdate, "//is: DefaultOTARequestorDriver::HandleIdleStateEnter IdleStateReason %d", reason); - switch (reason) { case IdleStateReason::kUnknown: + mInvalidSessionRetryCount = 0; ChipLogProgress(SoftwareUpdate, "Unknown idle state reason so set the periodic timer for a next attempt"); StartSelectedTimer(SelectedTimer::kPeriodicQueryTimer); break; case IdleStateReason::kIdle: + mInvalidSessionRetryCount = 0; // There is no current OTA update in progress so start the periodic query timer StartSelectedTimer(SelectedTimer::kPeriodicQueryTimer); break; case IdleStateReason::kInvalidSession: - // An invalid session is detected which may be temporary so try to query the same provider again - SendQueryImage(); + if(mInvalidSessionRetryCount < kMaxInvalidSessionRetries) + { + // An invalid session is detected which may be temporary so try to query the same provider again + SendQueryImage(); + mInvalidSessionRetryCount++; + } + else + { + mInvalidSessionRetryCount = 0; + StartSelectedTimer(SelectedTimer::kPeriodicQueryTimer); + } break; } } @@ -308,8 +319,6 @@ void DefaultOTARequestorDriver::ProcessAnnounceOTAProviders( void DefaultOTARequestorDriver::SendQueryImage() { - ChipLogProgress(SoftwareUpdate, "//is: DefaultOTARequestorDriver::SendQueryImage"); - OTAUpdateStateEnum currentUpdateState; Optional lastUsedProvider; mRequestor->GetProviderLocation(lastUsedProvider); diff --git a/src/app/clusters/ota-requestor/DefaultOTARequestorDriver.h b/src/app/clusters/ota-requestor/DefaultOTARequestorDriver.h index 2ff7e5d3526f26..c085c57128a0ca 100644 --- a/src/app/clusters/ota-requestor/DefaultOTARequestorDriver.h +++ b/src/app/clusters/ota-requestor/DefaultOTARequestorDriver.h @@ -109,7 +109,10 @@ class DefaultOTARequestorDriver : public OTARequestorDriver uint16_t maxDownloadBlockSize = 1024; // Maximum number of times to retry a BUSY OTA provider before moving to the next available one static constexpr uint8_t kMaxBusyProviderRetryCount = 3; - uint8_t mProviderRetryCount; // Track retry count for the current provider + // Track retry count for the current provider + uint8_t mProviderRetryCount; + // Track query image retry count on invalid session error + uint8_t mInvalidSessionRetryCount; }; } // namespace DeviceLayer