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

[OPSTATE] Fix: change in type for OperationalState attribute #27958

Merged
Merged
Show file tree
Hide file tree
Changes from 6 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
Original file line number Diff line number Diff line change
Expand Up @@ -2692,7 +2692,7 @@ server cluster OperationalState = 96 {
readonly attribute nullable int8u currentPhase = 1;
readonly attribute nullable elapsed_s countdownTime = 2;
readonly attribute OperationalStateStruct operationalStateList[] = 3;
readonly attribute OperationalStateStruct operationalState = 4;
readonly attribute enum8 operationalState = 4;
readonly attribute ErrorStateStruct operationalError = 5;
readonly attribute command_id generatedCommandList[] = 65528;
readonly attribute command_id acceptedCommandList[] = 65529;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ class OperationalStateDelegate : public Delegate
public:
/**
* Get current operational state.
* @param op The GenericOperationalState to fill with the current operational state value.
* @param op The uint8_t to fill with the current operational state value.
* @return void.
*/
void GetCurrentOperationalState(GenericOperationalState & op) override;
void GetCurrentOperationalState(uint8_t & op) override;

/**
* Get the list of supported operational states.
Expand Down Expand Up @@ -86,7 +86,7 @@ class OperationalStateDelegate : public Delegate
* Set current operational state.
* @param opState The operational state that should now be the current one.
*/
CHIP_ERROR SetOperationalState(const GenericOperationalState & opState) override;
CHIP_ERROR SetOperationalState(const uint8_t & opState) override;

/**
* Set operational phase.
Expand Down Expand Up @@ -125,7 +125,7 @@ class OperationalStateDelegate : public Delegate
*/
void HandleStopStateCallback(GenericOperationalError & err) override;

OperationalStateDelegate(GenericOperationalState aOperationalState, GenericOperationalError aOperationalError,
OperationalStateDelegate(uint8_t aOperationalState, GenericOperationalError aOperationalError,
Span<const GenericOperationalState> aOperationalStateList,
Span<const GenericOperationalPhase> aOperationalPhaseList,
app::DataModel::Nullable<uint8_t> aPhase = DataModel::Nullable<uint8_t>(),
Expand All @@ -137,7 +137,7 @@ class OperationalStateDelegate : public Delegate
~OperationalStateDelegate() = default;

private:
GenericOperationalState mOperationalState;
uint8_t mOperationalState;
GenericOperationalError mOperationalError;
app::DataModel::List<const GenericOperationalState> mOperationalStateList;
Span<const GenericOperationalPhase> mOperationalPhaseList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace OperationalState {

using chip::Protocols::InteractionModel::Status;

CHIP_ERROR OperationalStateDelegate::SetOperationalState(const GenericOperationalState & opState)
CHIP_ERROR OperationalStateDelegate::SetOperationalState(const uint8_t & opState)
{
mOperationalState = opState;
return CHIP_NO_ERROR;
Expand All @@ -42,7 +42,7 @@ CHIP_ERROR OperationalStateDelegate::SetCountdownTime(const app::DataModel::Null
return CHIP_NO_ERROR;
}

void OperationalStateDelegate::GetCurrentOperationalState(GenericOperationalState & op)
void OperationalStateDelegate::GetCurrentOperationalState(uint8_t & op)
{
op = mOperationalState;
}
Expand Down Expand Up @@ -91,28 +91,28 @@ CHIP_ERROR OperationalStateDelegate::GetOperationalPhaseAtIndex(size_t index, Ge
void OperationalStateDelegate::HandlePauseStateCallback(GenericOperationalError & err)
{
// placeholder implementation
mOperationalState.Set(to_underlying(OperationalStateEnum::kPaused));
mOperationalState = to_underlying(OperationalStateEnum::kPaused);
err.Set(to_underlying(ErrorStateEnum::kNoError));
}

void OperationalStateDelegate::HandleResumeStateCallback(GenericOperationalError & err)
{
// placeholder implementation
mOperationalState.Set(to_underlying(OperationalStateEnum::kRunning));
mOperationalState = to_underlying(OperationalStateEnum::kRunning);
err.Set(to_underlying(ErrorStateEnum::kNoError));
}

void OperationalStateDelegate::HandleStartStateCallback(GenericOperationalError & err)
{
// placeholder implementation
mOperationalState.Set(to_underlying(OperationalStateEnum::kRunning));
mOperationalState = to_underlying(OperationalStateEnum::kRunning);
err.Set(to_underlying(ErrorStateEnum::kNoError));
}

void OperationalStateDelegate::HandleStopStateCallback(GenericOperationalError & err)
{
// placeholder implementation
mOperationalState.Set(to_underlying(OperationalStateEnum::kStopped));
mOperationalState = to_underlying(OperationalStateEnum::kStopped);
err.Set(to_underlying(ErrorStateEnum::kNoError));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ static const GenericOperationalPhase opPhaseList[] = {
* Operational State Delegate
* Note: User Define
*/
static OperationalStateDelegate opStateDelegate(GenericOperationalState(to_underlying(OperationalStateEnum::kStopped)),
static OperationalStateDelegate opStateDelegate(to_underlying(OperationalStateEnum::kStopped),
GenericOperationalError(to_underlying(ErrorStateEnum::kNoError)),
Span<const GenericOperationalState>(opStateList),
Span<const GenericOperationalPhase>(opPhaseList));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,10 @@ class Delegate
public:
/**
* Get the current operational state.
* @param op The GenericOperationalState to fill with the current operational state value.
* @param op The uint8_t to fill with the current operational state value.
* @return void.
*/
virtual void GetCurrentOperationalState(GenericOperationalState & op) = 0;
virtual void GetCurrentOperationalState(uint8_t & op) = 0;
mideayanghui marked this conversation as resolved.
Show resolved Hide resolved

/**
* Get the list of supported operational states.
Expand Down Expand Up @@ -258,7 +258,7 @@ class Delegate
* Set current operational state.
* @param opState The operational state that should now be the current one.
*/
virtual CHIP_ERROR SetOperationalState(const GenericOperationalState & opState) = 0;
virtual CHIP_ERROR SetOperationalState(const uint8_t & opState) = 0;
mideayanghui marked this conversation as resolved.
Show resolved Hide resolved

/**
* Set operational error.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,12 @@ void OperationalStateServer::HandlePauseState(HandlerContext & ctx, const Comman
Commands::OperationalCommandResponse::Type response;
Delegate * delegate = OperationalState::GetOperationalStateDelegate(mEndpointId, mClusterId);
GenericOperationalError err(to_underlying(ErrorStateEnum::kNoError));
GenericOperationalState opState;
uint8_t opState;
mideayanghui marked this conversation as resolved.
Show resolved Hide resolved

VerifyOrReturn(delegate != nullptr, ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::Failure));
delegate->GetCurrentOperationalState(opState);

if (opState.operationalStateID != to_underlying(OperationalStateEnum::kPaused))
if (opState != to_underlying(OperationalStateEnum::kPaused))
{
delegate->HandlePauseStateCallback(err);
}
Expand All @@ -126,18 +126,17 @@ void OperationalStateServer::HandleResumeState(HandlerContext & ctx, const Comma
Commands::OperationalCommandResponse::Type response;
Delegate * delegate = OperationalState::GetOperationalStateDelegate(mEndpointId, mClusterId);
GenericOperationalError err(to_underlying(ErrorStateEnum::kNoError));
GenericOperationalState opState;
uint8_t opState;

VerifyOrReturn(delegate != nullptr, ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::Failure));

delegate->GetCurrentOperationalState(opState);

if (opState.operationalStateID != to_underlying(OperationalStateEnum::kPaused) &&
opState.operationalStateID != to_underlying(OperationalStateEnum::kRunning))
if (opState != to_underlying(OperationalStateEnum::kPaused) && opState != to_underlying(OperationalStateEnum::kRunning))
{
err.Set(to_underlying(ErrorStateEnum::kCommandInvalidInState));
}
else if (opState.operationalStateID == to_underlying(OperationalStateEnum::kPaused))
else if (opState == to_underlying(OperationalStateEnum::kPaused))
{
delegate->HandleResumeStateCallback(err);
}
Expand All @@ -152,13 +151,13 @@ void OperationalStateServer::HandleStartState(HandlerContext & ctx, const Comman
Commands::OperationalCommandResponse::Type response;
Delegate * delegate = OperationalState::GetOperationalStateDelegate(mEndpointId, mClusterId);
GenericOperationalError err(to_underlying(ErrorStateEnum::kNoError));
GenericOperationalState opState;
uint8_t opState;

VerifyOrReturn(delegate != nullptr, ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::Failure));

delegate->GetCurrentOperationalState(opState);

if (opState.operationalStateID != to_underlying(OperationalStateEnum::kRunning))
if (opState != to_underlying(OperationalStateEnum::kRunning))
{
delegate->HandleStartStateCallback(err);
}
Expand All @@ -173,13 +172,13 @@ void OperationalStateServer::HandleStopState(HandlerContext & ctx, const Command
Commands::OperationalCommandResponse::Type response;
Delegate * delegate = OperationalState::GetOperationalStateDelegate(mEndpointId, mClusterId);
GenericOperationalError err(to_underlying(ErrorStateEnum::kNoError));
GenericOperationalState opState;
uint8_t opState;

VerifyOrReturn(delegate != nullptr, ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::Failure));

delegate->GetCurrentOperationalState(opState);

if (opState.operationalStateID != to_underlying(OperationalStateEnum::kStopped))
if (opState != to_underlying(OperationalStateEnum::kStopped))
{
delegate->HandleStopStateCallback(err);
}
Expand Down Expand Up @@ -243,7 +242,7 @@ CHIP_ERROR OperationalStateServer::Read(const ConcreteReadAttributePath & aPath,
case OperationalState::Attributes::OperationalState::Id: {

Delegate * delegate = OperationalState::GetOperationalStateDelegate(mEndpointId, mClusterId);
GenericOperationalState opState;
uint8_t opState;
VerifyOrReturnError(delegate != nullptr, CHIP_ERROR_INCORRECT_STATE, ChipLogError(Zcl, "Delegate is nullptr"));
delegate->GetCurrentOperationalState(opState);
return aEncoder.Encode(opState);
Expand Down
10 changes: 5 additions & 5 deletions src/app/tests/suites/TestOperationalState.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ tests:
command: "readAttribute"
attribute: "OperationalState"
response:
value: { OperationalStateID: 0 }
value: 0

- label: "Start Command"
command: "Start"
Expand All @@ -81,7 +81,7 @@ tests:
command: "readAttribute"
attribute: "OperationalState"
response:
value: { OperationalStateID: 1 }
value: 1

- label: "Pause Command"
command: "Pause"
Expand All @@ -94,7 +94,7 @@ tests:
command: "readAttribute"
attribute: "OperationalState"
response:
value: { OperationalStateID: 2 }
value: 2

- label: "Resume Command"
command: "Resume"
Expand All @@ -107,7 +107,7 @@ tests:
command: "readAttribute"
attribute: "OperationalState"
response:
value: { OperationalStateID: 1 }
value: 1

- label: "Stop Command"
command: "Stop"
Expand All @@ -120,4 +120,4 @@ tests:
command: "readAttribute"
attribute: "OperationalState"
response:
value: { OperationalStateID: 0 }
value: 0
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ limitations under the License.
<attribute side="server" code="0x0001" define="CURRENT_PHASE" type="INT8U" min="0x00" max="0x1F" writable="false" isNullable="true" optional="false">CurrentPhase</attribute>
<attribute side="server" code="0x0002" define="COUNTDOWN_TIME" type="elapsed_s" min="0x00" max="259200" writable="false" isNullable="true" optional="true">CountdownTime</attribute>
<attribute side="server" code="0x0003" define="OPERATIONAL_STATE_LIST" type="ARRAY" entryType="OperationalStateStruct" writable="false" optional="false">OperationalStateList</attribute>
<attribute side="server" code="0x0004" define="OPERATIONAL_STATE" type="OperationalStateStruct" writable="false" optional="false">OperationalState</attribute>
<attribute side="server" code="0x0004" define="OPERATIONAL_STATE" type="ENUM8" writable="false" optional="false">OperationalState</attribute>
mideayanghui marked this conversation as resolved.
Show resolved Hide resolved
<attribute side="server" code="0x0005" define="OPERATIONAL_ERROR" type="ErrorStateStruct" writable="false" optional="false">OperationalError</attribute>

<command source="client" code="0x00" name="Pause" response="OperationalCommandResponse" optional="true">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ limitations under the License.
<attribute side="server" code="0x0001" define="CURRENT_PHASE" type="INT8U" min="0x00" max="0x1F" writable="false" isNullable="true" optional="false">CurrentPhase</attribute>
<attribute side="server" code="0x0002" define="COUNTDOWN_TIME" type="elapsed_s" min="0" max="259200" writable="false" isNullable="true" optional="true">CountdownTime</attribute>
<attribute side="server" code="0x0003" define="OPERATIONAL_STATE_LIST" type="ARRAY" entryType="OperationalStateStruct" writable="false" optional="false">OperationalStateList</attribute>
<attribute side="server" code="0x0004" define="OPERATIONAL_STATE" type="OperationalStateStruct" writable="false" optional="false">OperationalState</attribute>
<attribute side="server" code="0x0004" define="OPERATIONAL_STATE" type="ENUM8" writable="false" optional="false">OperationalState</attribute>
mideayanghui marked this conversation as resolved.
Show resolved Hide resolved
<attribute side="server" code="0x0005" define="OPERATIONAL_ERROR" type="ErrorStateStruct" writable="false" optional="false">OperationalError</attribute>

<command source="client" code="0x00" name="Pause" response="OperationalCommandResponse" optional="true">
Expand Down
4 changes: 2 additions & 2 deletions src/controller/data_model/controller-clusters.matter
Original file line number Diff line number Diff line change
Expand Up @@ -3354,7 +3354,7 @@ client cluster OperationalState = 96 {
readonly attribute nullable int8u currentPhase = 1;
readonly attribute optional nullable elapsed_s countdownTime = 2;
readonly attribute OperationalStateStruct operationalStateList[] = 3;
readonly attribute OperationalStateStruct operationalState = 4;
readonly attribute enum8 operationalState = 4;
readonly attribute ErrorStateStruct operationalError = 5;
readonly attribute command_id generatedCommandList[] = 65528;
readonly attribute command_id acceptedCommandList[] = 65529;
Expand Down Expand Up @@ -3421,7 +3421,7 @@ client cluster RvcOperationalState = 97 {
readonly attribute nullable int8u currentPhase = 1;
readonly attribute optional nullable elapsed_s countdownTime = 2;
readonly attribute OperationalStateStruct operationalStateList[] = 3;
readonly attribute OperationalStateStruct operationalState = 4;
readonly attribute enum8 operationalState = 4;
readonly attribute ErrorStateStruct operationalError = 5;
readonly attribute command_id generatedCommandList[] = 65528;
readonly attribute command_id acceptedCommandList[] = 65529;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7432,6 +7432,17 @@ private static Map<String, InteractionInfo> readOperationalStateInteractionInfo(
readOperationalStateOperationalStateListCommandParams
);
result.put("readOperationalStateListAttribute", readOperationalStateOperationalStateListAttributeInteractionInfo);
Map<String, CommandParameterInfo> readOperationalStateOperationalStateCommandParams = new LinkedHashMap<String, CommandParameterInfo>();
InteractionInfo readOperationalStateOperationalStateAttributeInteractionInfo = new InteractionInfo(
(cluster, callback, commandArguments) -> {
((ChipClusters.OperationalStateCluster) cluster).readOperationalStateAttribute(
(ChipClusters.IntegerAttributeCallback) callback
);
},
() -> new ClusterInfoMapping.DelegatedIntegerAttributeCallback(),
readOperationalStateOperationalStateCommandParams
);
result.put("readOperationalStateAttribute", readOperationalStateOperationalStateAttributeInteractionInfo);
Map<String, CommandParameterInfo> readOperationalStateGeneratedCommandListCommandParams = new LinkedHashMap<String, CommandParameterInfo>();
InteractionInfo readOperationalStateGeneratedCommandListAttributeInteractionInfo = new InteractionInfo(
(cluster, callback, commandArguments) -> {
Expand Down Expand Up @@ -7546,6 +7557,17 @@ private static Map<String, InteractionInfo> readRvcOperationalStateInteractionIn
readRvcOperationalStateOperationalStateListCommandParams
);
result.put("readOperationalStateListAttribute", readRvcOperationalStateOperationalStateListAttributeInteractionInfo);
Map<String, CommandParameterInfo> readRvcOperationalStateOperationalStateCommandParams = new LinkedHashMap<String, CommandParameterInfo>();
InteractionInfo readRvcOperationalStateOperationalStateAttributeInteractionInfo = new InteractionInfo(
(cluster, callback, commandArguments) -> {
((ChipClusters.RvcOperationalStateCluster) cluster).readOperationalStateAttribute(
(ChipClusters.IntegerAttributeCallback) callback
);
},
() -> new ClusterInfoMapping.DelegatedIntegerAttributeCallback(),
readRvcOperationalStateOperationalStateCommandParams
);
result.put("readOperationalStateAttribute", readRvcOperationalStateOperationalStateAttributeInteractionInfo);
Map<String, CommandParameterInfo> readRvcOperationalStateGeneratedCommandListCommandParams = new LinkedHashMap<String, CommandParameterInfo>();
InteractionInfo readRvcOperationalStateGeneratedCommandListAttributeInteractionInfo = new InteractionInfo(
(cluster, callback, commandArguments) -> {
Expand Down
Loading