Skip to content

Commit

Permalink
Updated the onoff-cluster.xml to use the specifications type definiti…
Browse files Browse the repository at this point in the history
…ons, instead of using the enum* directly. See issue project-chip#15528.
  • Loading branch information
Eugen Feraru authored and mrjerryjohns committed Mar 23, 2022
1 parent c7b4913 commit 3545ae1
Show file tree
Hide file tree
Showing 37 changed files with 434 additions and 172 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2271,6 +2271,12 @@ server cluster OnOff = 6 {
kDyingLight = 1;
}

enum OnOffStartUpOnOff : ENUM8 {
kOff = 0;
kOn = 1;
kTogglePreviousOnOff = 2;
}

bitmap OnOffControl : BITMAP8 {
kAcceptOnlyWhenOn = 0x1;
}
Expand All @@ -2283,7 +2289,7 @@ server cluster OnOff = 6 {
readonly attribute boolean globalSceneControl = 16384;
attribute int16u onTime = 16385;
attribute int16u offWaitTime = 16386;
attribute nullable enum8 startUpOnOff = 16387;
attribute nullable OnOffStartUpOnOff startUpOnOff = 16387;
readonly global attribute bitmap32 featureMap = 65532;
readonly global attribute int16u clusterRevision = 65533;

Expand Down
6 changes: 6 additions & 0 deletions examples/bridge-app/bridge-common/bridge-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,12 @@ server cluster OnOff = 6 {
kDyingLight = 1;
}

enum OnOffStartUpOnOff : ENUM8 {
kOff = 0;
kOn = 1;
kTogglePreviousOnOff = 2;
}

bitmap OnOffControl : BITMAP8 {
kAcceptOnlyWhenOn = 0x1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1084,6 +1084,12 @@ client cluster OnOff = 6 {
kDyingLight = 1;
}

enum OnOffStartUpOnOff : ENUM8 {
kOff = 0;
kOn = 1;
kTogglePreviousOnOff = 2;
}

bitmap OnOffControl : BITMAP8 {
kAcceptOnlyWhenOn = 0x1;
}
Expand All @@ -1096,7 +1102,7 @@ client cluster OnOff = 6 {
readonly attribute boolean globalSceneControl = 16384;
attribute int16u onTime = 16385;
attribute int16u offWaitTime = 16386;
attribute nullable enum8 startUpOnOff = 16387;
attribute nullable OnOffStartUpOnOff startUpOnOff = 16387;
readonly global attribute attrib_id attributeList[] = 65531;
readonly global attribute bitmap32 featureMap = 65532;
readonly global attribute int16u clusterRevision = 65533;
Expand Down
8 changes: 7 additions & 1 deletion examples/lighting-app/lighting-common/lighting-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -1162,6 +1162,12 @@ server cluster OnOff = 6 {
kDyingLight = 1;
}

enum OnOffStartUpOnOff : ENUM8 {
kOff = 0;
kOn = 1;
kTogglePreviousOnOff = 2;
}

bitmap OnOffControl : BITMAP8 {
kAcceptOnlyWhenOn = 0x1;
}
Expand All @@ -1174,7 +1180,7 @@ server cluster OnOff = 6 {
readonly attribute boolean globalSceneControl = 16384;
attribute int16u onTime = 16385;
attribute int16u offWaitTime = 16386;
attribute nullable enum8 startUpOnOff = 16387;
attribute nullable OnOffStartUpOnOff startUpOnOff = 16387;
readonly global attribute bitmap32 featureMap = 65532;
readonly global attribute int16u clusterRevision = 65533;

Expand Down
8 changes: 7 additions & 1 deletion examples/lock-app/lock-common/lock-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,12 @@ server cluster OnOff = 6 {
kDyingLight = 1;
}

enum OnOffStartUpOnOff : ENUM8 {
kOff = 0;
kOn = 1;
kTogglePreviousOnOff = 2;
}

bitmap OnOffControl : BITMAP8 {
kAcceptOnlyWhenOn = 0x1;
}
Expand All @@ -660,7 +666,7 @@ server cluster OnOff = 6 {
readonly attribute boolean globalSceneControl = 16384;
attribute int16u onTime = 16385;
attribute int16u offWaitTime = 16386;
attribute nullable enum8 startUpOnOff = 16387;
attribute nullable OnOffStartUpOnOff startUpOnOff = 16387;
readonly global attribute bitmap32 featureMap = 65532;
readonly global attribute int16u clusterRevision = 65533;

Expand Down
16 changes: 14 additions & 2 deletions examples/placeholder/linux/apps/app1/config.matter
Original file line number Diff line number Diff line change
Expand Up @@ -1208,6 +1208,12 @@ client cluster OnOff = 6 {
kDyingLight = 1;
}

enum OnOffStartUpOnOff : ENUM8 {
kOff = 0;
kOn = 1;
kTogglePreviousOnOff = 2;
}

bitmap OnOffControl : BITMAP8 {
kAcceptOnlyWhenOn = 0x1;
}
Expand All @@ -1220,7 +1226,7 @@ client cluster OnOff = 6 {
readonly attribute boolean globalSceneControl = 16384;
attribute int16u onTime = 16385;
attribute int16u offWaitTime = 16386;
attribute nullable enum8 startUpOnOff = 16387;
attribute nullable OnOffStartUpOnOff startUpOnOff = 16387;
readonly global attribute bitmap32 featureMap = 65532;
readonly global attribute int16u clusterRevision = 65533;

Expand Down Expand Up @@ -1259,6 +1265,12 @@ server cluster OnOff = 6 {
kDyingLight = 1;
}

enum OnOffStartUpOnOff : ENUM8 {
kOff = 0;
kOn = 1;
kTogglePreviousOnOff = 2;
}

bitmap OnOffControl : BITMAP8 {
kAcceptOnlyWhenOn = 0x1;
}
Expand All @@ -1271,7 +1283,7 @@ server cluster OnOff = 6 {
readonly attribute boolean globalSceneControl = 16384;
attribute int16u onTime = 16385;
attribute int16u offWaitTime = 16386;
attribute nullable enum8 startUpOnOff = 16387;
attribute nullable OnOffStartUpOnOff startUpOnOff = 16387;
readonly global attribute bitmap32 featureMap = 65532;
readonly global attribute int16u clusterRevision = 65533;

Expand Down
16 changes: 14 additions & 2 deletions examples/placeholder/linux/apps/app2/config.matter
Original file line number Diff line number Diff line change
Expand Up @@ -1208,6 +1208,12 @@ client cluster OnOff = 6 {
kDyingLight = 1;
}

enum OnOffStartUpOnOff : ENUM8 {
kOff = 0;
kOn = 1;
kTogglePreviousOnOff = 2;
}

bitmap OnOffControl : BITMAP8 {
kAcceptOnlyWhenOn = 0x1;
}
Expand All @@ -1220,7 +1226,7 @@ client cluster OnOff = 6 {
readonly attribute boolean globalSceneControl = 16384;
attribute int16u onTime = 16385;
attribute int16u offWaitTime = 16386;
attribute nullable enum8 startUpOnOff = 16387;
attribute nullable OnOffStartUpOnOff startUpOnOff = 16387;
readonly global attribute bitmap32 featureMap = 65532;
readonly global attribute int16u clusterRevision = 65533;

Expand Down Expand Up @@ -1259,6 +1265,12 @@ server cluster OnOff = 6 {
kDyingLight = 1;
}

enum OnOffStartUpOnOff : ENUM8 {
kOff = 0;
kOn = 1;
kTogglePreviousOnOff = 2;
}

bitmap OnOffControl : BITMAP8 {
kAcceptOnlyWhenOn = 0x1;
}
Expand All @@ -1271,7 +1283,7 @@ server cluster OnOff = 6 {
readonly attribute boolean globalSceneControl = 16384;
attribute int16u onTime = 16385;
attribute int16u offWaitTime = 16386;
attribute nullable enum8 startUpOnOff = 16387;
attribute nullable OnOffStartUpOnOff startUpOnOff = 16387;
readonly global attribute bitmap32 featureMap = 65532;
readonly global attribute int16u clusterRevision = 65533;

Expand Down
8 changes: 7 additions & 1 deletion examples/pump-app/pump-common/pump-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,12 @@ server cluster OnOff = 6 {
kDyingLight = 1;
}

enum OnOffStartUpOnOff : ENUM8 {
kOff = 0;
kOn = 1;
kTogglePreviousOnOff = 2;
}

bitmap OnOffControl : BITMAP8 {
kAcceptOnlyWhenOn = 0x1;
}
Expand All @@ -902,7 +908,7 @@ server cluster OnOff = 6 {
readonly attribute boolean globalSceneControl = 16384;
attribute int16u onTime = 16385;
attribute int16u offWaitTime = 16386;
attribute nullable enum8 startUpOnOff = 16387;
attribute nullable OnOffStartUpOnOff startUpOnOff = 16387;
readonly global attribute int16u clusterRevision = 65533;

request struct OffWithEffectRequest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,12 @@ client cluster OnOff = 6 {
kDyingLight = 1;
}

enum OnOffStartUpOnOff : ENUM8 {
kOff = 0;
kOn = 1;
kTogglePreviousOnOff = 2;
}

bitmap OnOffControl : BITMAP8 {
kAcceptOnlyWhenOn = 0x1;
}
Expand Down
6 changes: 6 additions & 0 deletions examples/tv-app/tv-common/tv-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -1410,6 +1410,12 @@ server cluster OnOff = 6 {
kDyingLight = 1;
}

enum OnOffStartUpOnOff : ENUM8 {
kOff = 0;
kOn = 1;
kTogglePreviousOnOff = 2;
}

bitmap OnOffControl : BITMAP8 {
kAcceptOnlyWhenOn = 0x1;
}
Expand Down
16 changes: 14 additions & 2 deletions examples/tv-casting-app/tv-casting-common/tv-casting-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -1436,6 +1436,12 @@ client cluster OnOff = 6 {
kDyingLight = 1;
}

enum OnOffStartUpOnOff : ENUM8 {
kOff = 0;
kOn = 1;
kTogglePreviousOnOff = 2;
}

bitmap OnOffControl : BITMAP8 {
kAcceptOnlyWhenOn = 0x1;
}
Expand All @@ -1448,7 +1454,7 @@ client cluster OnOff = 6 {
readonly attribute boolean globalSceneControl = 16384;
attribute int16u onTime = 16385;
attribute int16u offWaitTime = 16386;
attribute nullable enum8 startUpOnOff = 16387;
attribute nullable OnOffStartUpOnOff startUpOnOff = 16387;
readonly global attribute bitmap32 featureMap = 65532;
readonly global attribute int16u clusterRevision = 65533;

Expand All @@ -1473,6 +1479,12 @@ server cluster OnOff = 6 {
kDyingLight = 1;
}

enum OnOffStartUpOnOff : ENUM8 {
kOff = 0;
kOn = 1;
kTogglePreviousOnOff = 2;
}

bitmap OnOffControl : BITMAP8 {
kAcceptOnlyWhenOn = 0x1;
}
Expand All @@ -1485,7 +1497,7 @@ server cluster OnOff = 6 {
readonly attribute boolean globalSceneControl = 16384;
attribute int16u onTime = 16385;
attribute int16u offWaitTime = 16386;
attribute nullable enum8 startUpOnOff = 16387;
attribute nullable OnOffStartUpOnOff startUpOnOff = 16387;
readonly global attribute bitmap32 featureMap = 65532;
readonly global attribute int16u clusterRevision = 65533;

Expand Down
9 changes: 4 additions & 5 deletions src/app/clusters/on-off-server/on-off-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,7 @@ void OnOffServer::initOnOffServer(chip::EndpointId endpoint)
// 0xff This value cannot happen.
// null Set the OnOff attribute to its previous value.

// Initialize startUpOnOff to No action value 0xFE
app::DataModel::Nullable<uint8_t> startUpOnOff;
app::DataModel::Nullable<OnOff::OnOffStartUpOnOff> startUpOnOff;
EmberAfStatus status = Attributes::StartUpOnOff::Get(endpoint, startUpOnOff);
if (status == EMBER_ZCL_STATUS_SUCCESS)
{
Expand All @@ -262,13 +261,13 @@ void OnOffServer::initOnOffServer(chip::EndpointId endpoint)
{
switch (startUpOnOff.Value())
{
case EMBER_ZCL_START_UP_ON_OFF_VALUE_SET_TO_OFF:
case OnOff::OnOffStartUpOnOff::kOff:
updatedOnOff = 0; // Off
break;
case EMBER_ZCL_START_UP_ON_OFF_VALUE_SET_TO_ON:
case OnOff::OnOffStartUpOnOff::kOn:
updatedOnOff = 1; // On
break;
case EMBER_ZCL_START_UP_ON_OFF_VALUE_SET_TO_TOGGLE:
case OnOff::OnOffStartUpOnOff::kTogglePreviousOnOff:
updatedOnOff = !updatedOnOff;
break;
default:
Expand Down
9 changes: 8 additions & 1 deletion src/app/zap-templates/zcl/data-model/chip/onoff-cluster.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ limitations under the License.
<configurator>
<domain name="General"/>

<enum name="OnOffStartUpOnOff" type="ENUM8">
<cluster code="0x0006"/>
<item name="Off" value="0x00"/>
<item name="On" value="0x01"/>
<item name="TogglePreviousOnOff" value="0x02"/>
</enum>

<enum name="OnOffEffectIdentifier" type="enum8">
<cluster code="0x0006"/>
<item name="DelayedAllOff" value="0x00"/>
Expand Down Expand Up @@ -52,7 +59,7 @@ limitations under the License.
<attribute side="server" code="0x4000" define="GLOBAL_SCENE_CONTROL" type="boolean" default="1" optional="true">GlobalSceneControl</attribute>
<attribute side="server" code="0x4001" define="ON_TIME" type="int16u" default="0" writable="true" optional="true">OnTime</attribute>
<attribute side="server" code="0x4002" define="OFF_WAIT_TIME" type="int16u" default="0" writable="true" optional="true">OffWaitTime</attribute>
<attribute side="server" code="0x4003" define="START_UP_ON_OFF" type="enum8" default="0" writable="true" isNullable="true" optional="true">StartUpOnOff</attribute>
<attribute side="server" code="0x4003" define="START_UP_ON_OFF" type="OnOffStartUpOnOff" min="0" max="2" isNullable="true" writable="true" optional="true">StartUpOnOff</attribute>

<command source="client" code="0x00" name="Off" optional="false">
<description>On receipt of this command, a device SHALL enter its ‘Off’ state. This state is device dependent, but it is recommended that it is used for power off or similar functions. On receipt of the Off command, the OnTime attribute SHALL be set to 0.</description>
Expand Down
8 changes: 7 additions & 1 deletion src/controller/data_model/controller-clusters.matter
Original file line number Diff line number Diff line change
Expand Up @@ -2684,6 +2684,12 @@ client cluster OnOff = 6 {
kDyingLight = 1;
}

enum OnOffStartUpOnOff : ENUM8 {
kOff = 0;
kOn = 1;
kTogglePreviousOnOff = 2;
}

bitmap OnOffControl : BITMAP8 {
kAcceptOnlyWhenOn = 0x1;
}
Expand All @@ -2696,7 +2702,7 @@ client cluster OnOff = 6 {
readonly attribute boolean globalSceneControl = 16384;
attribute int16u onTime = 16385;
attribute int16u offWaitTime = 16386;
attribute nullable enum8 startUpOnOff = 16387;
attribute nullable OnOffStartUpOnOff startUpOnOff = 16387;
readonly global attribute command_id generatedCommandList[] = 65528;
readonly global attribute command_id acceptedCommandList[] = 65529;
readonly global attribute attrib_id attributeList[] = 65531;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions src/controller/java/zap-generated/CHIPReadCallbacks.cpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src/controller/java/zap-generated/CHIPReadCallbacks.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 3545ae1

Please sign in to comment.