Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OTA] Shutdown server and stop event loop directly from OTA Image Processor #16698

Merged
merged 1 commit into from
Mar 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions src/app/clusters/ota-requestor/OTARequestor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,11 +286,6 @@ void OTARequestor::Reset()
StoreCurrentUpdateInfo();
}

void OTARequestor::Shutdown(void)
{
mServer->DispatchShutDownAndStopEventLoop();
}

EmberAfStatus OTARequestor::HandleAnnounceOTAProvider(app::CommandHandler * commandObj,
const app::ConcreteCommandPath & commandPath,
const AnnounceOtaProvider::DecodableType & commandData)
Expand Down
1 change: 0 additions & 1 deletion src/app/clusters/ota-requestor/OTARequestor.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ class OTARequestor : public OTARequestorInterface, public BDXDownloader::StateDe

//////////// OTARequestorInterface Implementation ///////////////
void Reset(void) override;
void Shutdown(void) override;

EmberAfStatus HandleAnnounceOTAProvider(
app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath,
Expand Down
3 changes: 0 additions & 3 deletions src/app/clusters/ota-requestor/OTARequestorInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,6 @@ class OTARequestorInterface
// Reset any relevant states
virtual void Reset(void) = 0;

// Perform any clean up necessary
virtual void Shutdown(void) = 0;

// Handler for the AnnounceOTAProvider command
virtual EmberAfStatus HandleAnnounceOTAProvider(
chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath,
Expand Down
10 changes: 7 additions & 3 deletions src/platform/Linux/OTAImageProcessorImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,12 @@ CHIP_ERROR OTAImageProcessorImpl::ConfirmCurrentImage()
}

uint32_t currentVersion;
uint32_t targetVersion = requestor->GetTargetVersion();
ReturnErrorOnFailure(DeviceLayer::ConfigurationMgr().GetSoftwareVersion(currentVersion));
if (currentVersion != requestor->GetTargetVersion())
if (currentVersion != targetVersion)
{
ChipLogError(SoftwareUpdate, "Current software version = %" PRIu32 ", expected software version = %" PRIu32, currentVersion,
targetVersion);
return CHIP_ERROR_INCORRECT_STATE;
}

Expand Down Expand Up @@ -167,8 +170,9 @@ void OTAImageProcessorImpl::HandleApply(intptr_t context)
rename(imageProcessor->mImageFile, kImageExecPath);
chmod(kImageExecPath, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);

// Shutdown the stack and expect to boot into the new image once shutdown is complete
requestor->Shutdown();
// Shutdown the stack and expect to boot into the new image once the event loop is stopped
DeviceLayer::PlatformMgr().ScheduleWork([](intptr_t) { DeviceLayer::PlatformMgr().HandleServerShuttingDown(); });
DeviceLayer::PlatformMgr().ScheduleWork([](intptr_t) { DeviceLayer::PlatformMgr().StopEventLoopTask(); });
}

void OTAImageProcessorImpl::HandleAbort(intptr_t context)
Expand Down