Skip to content

Commit

Permalink
Updated the rvc-app's RvcOperationalStateDelegate to allow setting of…
Browse files Browse the repository at this point in the history
… a callback furtion for when the GoHome commond in received.
  • Loading branch information
hicklin committed Feb 2, 2024
1 parent 6fc3f54 commit 1068800
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ class RvcOperationalStateDelegate : public RvcOperationalState::Delegate
HandleOpStateCommand mPauseCallback;
RvcDevice * mResumeRvcDeviceInstance;
HandleOpStateCommand mResumeCallback;
RvcDevice * mGoHomeRvcDeviceInstance;
HandleOpStateCommand mGoHomeCallback;

public:
/**
Expand Down Expand Up @@ -99,6 +101,12 @@ class RvcOperationalStateDelegate : public RvcOperationalState::Delegate
*/
void HandleResumeStateCallback(Clusters::OperationalState::GenericOperationalError & err) override;

/**
* Handle Command Callback in application: GoHome
* @param[out] get operational error after callback.
*/
void HandleGoHomeCommandCallback(Clusters::OperationalState::GenericOperationalError & err) override;

/**
* Handle Command Callback in application: Start
* @param[out] get operational error after callback.
Expand Down Expand Up @@ -126,6 +134,12 @@ class RvcOperationalStateDelegate : public RvcOperationalState::Delegate
mResumeCallback = aCallback;
mResumeRvcDeviceInstance = aInstance;
};

void SetGoHomeCallback(HandleOpStateCommand aCallback, RvcDevice * aInstance)
{
mGoHomeCallback = aCallback;
mGoHomeRvcDeviceInstance = aInstance;
};
};

void Shutdown();
Expand Down
2 changes: 1 addition & 1 deletion examples/rvc-app/rvc-common/src/rvc-device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ void RvcDevice::HandleOpStateResumeCallback(Clusters::OperationalState::GenericO
break;
default:
// This method is only called if the device is in a resume-compatible state, i.e. `Charging`, `Docked` or
// `Paused`. Therefor, we do not expect to ever enter this branch.
// `Paused`. Therefore, we do not expect to ever enter this branch.
err.Set(to_underlying(OperationalState::ErrorStateEnum::kCommandInvalidInState));
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,8 @@ void RvcOperationalStateDelegate::HandleResumeStateCallback(OperationalState::Ge
{
(mResumeRvcDeviceInstance->*mResumeCallback)(err);
}

void RvcOperationalStateDelegate::HandleGoHomeCommandCallback(OperationalState::GenericOperationalError & err)
{
(mGoHomeRvcDeviceInstance->*mGoHomeCallback)(err);
}

0 comments on commit 1068800

Please sign in to comment.