diff --git a/examples/ota-requestor-app/linux/main.cpp b/examples/ota-requestor-app/linux/main.cpp index 08957422a2a15f..640a36d7062979 100644 --- a/examples/ota-requestor-app/linux/main.cpp +++ b/examples/ota-requestor-app/linux/main.cpp @@ -87,9 +87,11 @@ static void InitOTARequestor(void) // Set the global instance of the OTA requestor core component SetRequestorInstance(&gRequestorCore); + // Periodic query timeout must be set prior to requestor being initialized + gRequestorUser.SetPeriodicQueryTimeout(gPeriodicQueryTimeoutSec); + gRequestorCore.Init(&(chip::Server::GetInstance()), &gRequestorUser, &gDownloader); gRequestorUser.Init(&gRequestorCore, &gImageProcessor); - gRequestorUser.SetPeriodicQueryTimeout(gPeriodicQueryTimeoutSec); // WARNING: this is probably not realistic to know such details of the image or to even have an OTADownloader instantiated at // the beginning of program execution. We're using hardcoded values here for now since this is a reference application. diff --git a/src/app/clusters/ota-requestor/OTARequestor.h b/src/app/clusters/ota-requestor/OTARequestor.h index 71a410e6a8b567..599a6b0c2a5ea0 100644 --- a/src/app/clusters/ota-requestor/OTARequestor.h +++ b/src/app/clusters/ota-requestor/OTARequestor.h @@ -119,6 +119,9 @@ class OTARequestor : public OTARequestorInterface, public BDXDownloader::StateDe percent.SetNull(); OtaRequestorServerSetUpdateStateProgress(percent); + // This results in the initial periodic timer kicking off + RecordNewUpdateState(OTAUpdateStateEnum::kIdle, OTAChangeReasonEnum::kSuccess); + return chip::DeviceLayer::PlatformMgrImpl().AddEventHandler(OnCommissioningCompleteRequestor, reinterpret_cast(this)); } @@ -299,7 +302,7 @@ class OTARequestor : public OTARequestorInterface, public BDXDownloader::StateDe uint32_t mTargetVersion = 0; char mFileDesignatorBuffer[bdx::kMaxFileDesignatorLen]; CharSpan mFileDesignator; - OTAUpdateStateEnum mCurrentUpdateState = OTAUpdateStateEnum::kIdle; + OTAUpdateStateEnum mCurrentUpdateState = OTAUpdateStateEnum::kUnknown; Server * mServer = nullptr; chip::Optional mRequestorCanConsent; ProviderLocationList mDefaultOtaProviderList;