Skip to content

Commit

Permalink
[OTA] Shutdown server and stop event loop directly from OTA Image Pro…
Browse files Browse the repository at this point in the history
…cessor (project-chip#16698)
  • Loading branch information
carol-apple authored and chencheung committed Apr 6, 2022
1 parent 50908b4 commit 248c2e1
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 12 deletions.
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

0 comments on commit 248c2e1

Please sign in to comment.