Skip to content

Commit

Permalink
[OTA] Kick off the initial periodic query timer (#15830)
Browse files Browse the repository at this point in the history
  • Loading branch information
carol-apple authored and pull[bot] committed Jan 31, 2024
1 parent 21a20f3 commit 1460860
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion examples/ota-requestor-app/linux/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 4 additions & 1 deletion src/app/clusters/ota-requestor/OTARequestor.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<intptr_t>(this));
}
Expand Down Expand Up @@ -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<bool> mRequestorCanConsent;
ProviderLocationList mDefaultOtaProviderList;
Expand Down

0 comments on commit 1460860

Please sign in to comment.