Skip to content

Commit

Permalink
Fixed opstate app
Browse files Browse the repository at this point in the history
  • Loading branch information
beckerzito committed Feb 12, 2024
1 parent 2e85db4 commit b76fbfe
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11249,7 +11249,7 @@
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "1",
"defaultValue": "2",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ CHIP_ERROR GenericOperationalStateDelegateImpl::GetOperationalPhaseAtIndex(size_

void GenericOperationalStateDelegateImpl::HandlePauseStateCallback(GenericOperationalError & err)
{
OperationalState::OperationalStateEnum state = static_cast<OperationalState::OperationalStateEnum>(GetInstance()->GetCurrentOperationalState());

if(state == OperationalState::OperationalStateEnum::kStopped || state == OperationalState::OperationalStateEnum::kError)
{
err.Set(to_underlying(OperationalState::ErrorStateEnum::kCommandInvalidInState));
return;
}

// placeholder implementation
auto error = GetInstance()->SetOperationalState(to_underlying(OperationalState::OperationalStateEnum::kPaused));
if (error == CHIP_NO_ERROR)
Expand All @@ -58,6 +66,14 @@ void GenericOperationalStateDelegateImpl::HandlePauseStateCallback(GenericOperat

void GenericOperationalStateDelegateImpl::HandleResumeStateCallback(GenericOperationalError & err)
{
OperationalState::OperationalStateEnum state = static_cast<OperationalState::OperationalStateEnum>(GetInstance()->GetCurrentOperationalState());

if(state == OperationalState::OperationalStateEnum::kStopped || state == OperationalState::OperationalStateEnum::kError)
{
err.Set(to_underlying(OperationalState::ErrorStateEnum::kCommandInvalidInState));
return;
}

// placeholder implementation
auto error = GetInstance()->SetOperationalState(to_underlying(OperationalStateEnum::kRunning));
if (error == CHIP_NO_ERROR)
Expand All @@ -72,6 +88,15 @@ void GenericOperationalStateDelegateImpl::HandleResumeStateCallback(GenericOpera

void GenericOperationalStateDelegateImpl::HandleStartStateCallback(GenericOperationalError & err)
{
OperationalState::GenericOperationalError current_err(to_underlying(OperationalState::ErrorStateEnum::kNoError));
GetInstance()->GetCurrentOperationalError(current_err);

if(current_err.errorStateID != to_underlying(OperationalState::ErrorStateEnum::kNoError))
{
err.Set(to_underlying(OperationalState::ErrorStateEnum::kUnableToStartOrResume));
return;
}

// placeholder implementation
auto error = GetInstance()->SetOperationalState(to_underlying(OperationalStateEnum::kRunning));
if (error == CHIP_NO_ERROR)
Expand Down

0 comments on commit b76fbfe

Please sign in to comment.