Skip to content

Commit

Permalink
scripts/helpers/restyle-diff.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
isiu-apple committed Mar 24, 2022
1 parent 19363b4 commit ed10ed6
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 46 deletions.
79 changes: 39 additions & 40 deletions src/app/clusters/ota-requestor/GenericOTARequestorDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -395,36 +395,35 @@ void GenericOTARequestorDriver::WatchdogTimerHandler(System::Layer * systemLayer
ChipLogProgress(SoftwareUpdate, "Watchdog timer handler is invoked");

OTAUpdateStateEnum currentState = mRequestor->GetCurrentUpdateState();
switch(currentState)

switch (currentState)
{
case OTAUpdateStateEnum::kIdle:
case OTAUpdateStateEnum::kUnknown:
// OTA Requestor is not stuck in non-idle state. Restart watchdog timer.
StartWatchdogTimer();
break;
case OTAUpdateStateEnum::kQuerying:
case OTAUpdateStateEnum::kDelayedOnQuery:
case OTAUpdateStateEnum::kDownloading:
case OTAUpdateStateEnum::kApplying:
case OTAUpdateStateEnum::kDelayedOnApply:
UpdateDiscontinued();
mRequestor->CancelImageUpdate();
mRequestor->Reset();
StartPeriodicQueryTimer();
break;
case OTAUpdateStateEnum::kRollingBack:
case OTAUpdateStateEnum::kDelayedOnUserConsent:
mRequestor->Reset();
StartPeriodicQueryTimer();
break;
case OTAUpdateStateEnum::kIdle:
case OTAUpdateStateEnum::kUnknown:
// OTA Requestor is not stuck in non-idle state. Restart watchdog timer.
StartWatchdogTimer();
break;
case OTAUpdateStateEnum::kQuerying:
case OTAUpdateStateEnum::kDelayedOnQuery:
case OTAUpdateStateEnum::kDownloading:
case OTAUpdateStateEnum::kApplying:
case OTAUpdateStateEnum::kDelayedOnApply:
UpdateDiscontinued();
mRequestor->CancelImageUpdate();
mRequestor->Reset();
StartPeriodicQueryTimer();
break;
case OTAUpdateStateEnum::kRollingBack:
case OTAUpdateStateEnum::kDelayedOnUserConsent:
mRequestor->Reset();
StartPeriodicQueryTimer();
break;
}
}

void GenericOTARequestorDriver::StartWatchdogTimer()
{
ChipLogProgress(SoftwareUpdate, "Starting the watchdog timer, timeout: %u seconds",
(unsigned int) mWatchdogTimeInterval);
ChipLogProgress(SoftwareUpdate, "Starting the watchdog timer, timeout: %u seconds", (unsigned int) mWatchdogTimeInterval);
ScheduleDelayedAction(
System::Clock::Seconds32(mWatchdogTimeInterval),
[](System::Layer *, void * context) {
Expand All @@ -447,29 +446,29 @@ void GenericOTARequestorDriver::StartSelectedTimer(SelectedTimer timer)
{
switch (timer)
{
case SelectedTimer::kPeriodicQueryTimer:
StopWatchdogTimer();
StartPeriodicQueryTimer();
break;
case SelectedTimer::kWatchdogTimer:
StopPeriodicQueryTimer();
StartWatchdogTimer();
break;
case SelectedTimer::kPeriodicQueryTimer:
StopWatchdogTimer();
StartPeriodicQueryTimer();
break;
case SelectedTimer::kWatchdogTimer:
StopPeriodicQueryTimer();
StartWatchdogTimer();
break;
}
}

void GenericOTARequestorDriver::StopSelectedTimer(SelectedTimer timer)
{
switch (timer)
{
case SelectedTimer::kPeriodicQueryTimer:
StopPeriodicQueryTimer();
StartWatchdogTimer();
break;
case SelectedTimer::kWatchdogTimer:
StopWatchdogTimer();
StartPeriodicQueryTimer();
break;
case SelectedTimer::kPeriodicQueryTimer:
StopPeriodicQueryTimer();
StartWatchdogTimer();
break;
case SelectedTimer::kWatchdogTimer:
StopWatchdogTimer();
StartPeriodicQueryTimer();
break;
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/app/clusters/ota-requestor/OTARequestor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -663,12 +663,12 @@ void OTARequestor::RecordNewUpdateState(OTAUpdateStateEnum newState, OTAChangeRe
IdleStateReason idleStateReason = MapErrorToIdleStateReason(error);

// Inform the driver that the OTARequestor has entered the Idle state
mOtaRequestorDriver->HandleIdleState(idleStateReason);
mOtaRequestorDriver->HandleIdleState(idleStateReason);
}
else if(((mCurrentUpdateState == OTAUpdateStateEnum::kIdle) || (mCurrentUpdateState == OTAUpdateStateEnum::kUnknown)) &&
(newState != OTAUpdateStateEnum::kIdle))
else if (((mCurrentUpdateState == OTAUpdateStateEnum::kIdle) || (mCurrentUpdateState == OTAUpdateStateEnum::kUnknown)) &&
(newState != OTAUpdateStateEnum::kIdle))
{
mOtaRequestorDriver->HandleIdleStateExit();
mOtaRequestorDriver->HandleIdleStateExit();
}

mCurrentUpdateState = newState;
Expand Down
2 changes: 1 addition & 1 deletion src/app/clusters/ota-requestor/OTARequestor.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ class OTARequestor : public OTARequestorInterface, public BDXDownloader::StateDe
* Callback to initialize states and server attributes in the CHIP context
*/
static void InitState(intptr_t context);

/**
* Map a CHIP_ERROR to an IdleStateReason enum type
*/
Expand Down
2 changes: 1 addition & 1 deletion src/app/clusters/ota-requestor/OTARequestorDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ enum class SelectedTimer
class OTARequestorDriver
{
public:
using OTAUpdateStateEnum = app::Clusters::OtaSoftwareUpdateRequestor::OTAUpdateStateEnum;
using OTAUpdateStateEnum = app::Clusters::OtaSoftwareUpdateRequestor::OTAUpdateStateEnum;
using OTAChangeReasonEnum = app::Clusters::OtaSoftwareUpdateRequestor::OTAChangeReasonEnum;

using ProviderLocationType = app::Clusters::OtaSoftwareUpdateRequestor::Structs::ProviderLocation::Type;
Expand Down

0 comments on commit ed10ed6

Please sign in to comment.