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

Set OnOff StartUpOff attribute as nullable #16377

Merged
merged 5 commits into from
Mar 21, 2022
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -2274,7 +2274,7 @@ server cluster OnOff = 6 {
readonly attribute boolean globalSceneControl = 16384;
attribute int16u onTime = 16385;
attribute int16u offWaitTime = 16386;
attribute enum8 startUpOnOff = 16387;
attribute nullable enum8 startUpOnOff = 16387;
readonly global attribute bitmap32 featureMap = 65532;
readonly global attribute int16u clusterRevision = 65533;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1096,7 +1096,7 @@ client cluster OnOff = 6 {
readonly attribute boolean globalSceneControl = 16384;
attribute int16u onTime = 16385;
attribute int16u offWaitTime = 16386;
attribute enum8 startUpOnOff = 16387;
attribute nullable enum8 startUpOnOff = 16387;
readonly global attribute attrib_id attributeList[] = 65531;
readonly global attribute bitmap32 featureMap = 65532;
readonly global attribute int16u clusterRevision = 65533;
Expand Down
2 changes: 1 addition & 1 deletion examples/lighting-app/lighting-common/lighting-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -1174,7 +1174,7 @@ server cluster OnOff = 6 {
readonly attribute boolean globalSceneControl = 16384;
attribute int16u onTime = 16385;
attribute int16u offWaitTime = 16386;
attribute enum8 startUpOnOff = 16387;
attribute nullable enum8 startUpOnOff = 16387;
readonly global attribute bitmap32 featureMap = 65532;
readonly global attribute int16u clusterRevision = 65533;

Expand Down
2 changes: 1 addition & 1 deletion examples/lock-app/lock-common/lock-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ server cluster OnOff = 6 {
readonly attribute boolean globalSceneControl = 16384;
attribute int16u onTime = 16385;
attribute int16u offWaitTime = 16386;
attribute enum8 startUpOnOff = 16387;
attribute nullable enum8 startUpOnOff = 16387;
readonly global attribute bitmap32 featureMap = 65532;
readonly global attribute int16u clusterRevision = 65533;

Expand Down
4 changes: 2 additions & 2 deletions examples/placeholder/linux/apps/app1/config.matter
Original file line number Diff line number Diff line change
Expand Up @@ -1162,7 +1162,7 @@ client cluster OnOff = 6 {
readonly attribute boolean globalSceneControl = 16384;
attribute int16u onTime = 16385;
attribute int16u offWaitTime = 16386;
attribute enum8 startUpOnOff = 16387;
attribute nullable enum8 startUpOnOff = 16387;
readonly global attribute bitmap32 featureMap = 65532;
readonly global attribute int16u clusterRevision = 65533;

Expand Down Expand Up @@ -1213,7 +1213,7 @@ server cluster OnOff = 6 {
readonly attribute boolean globalSceneControl = 16384;
attribute int16u onTime = 16385;
attribute int16u offWaitTime = 16386;
attribute enum8 startUpOnOff = 16387;
attribute nullable enum8 startUpOnOff = 16387;
readonly global attribute bitmap32 featureMap = 65532;
readonly global attribute int16u clusterRevision = 65533;

Expand Down
2 changes: 1 addition & 1 deletion examples/placeholder/linux/apps/app2/config.matter
Original file line number Diff line number Diff line change
Expand Up @@ -1150,7 +1150,7 @@ server cluster OnOff = 6 {
readonly attribute boolean globalSceneControl = 16384;
attribute int16u onTime = 16385;
attribute int16u offWaitTime = 16386;
attribute enum8 startUpOnOff = 16387;
attribute nullable enum8 startUpOnOff = 16387;
readonly global attribute bitmap32 featureMap = 65532;
readonly global attribute int16u clusterRevision = 65533;

Expand Down
2 changes: 1 addition & 1 deletion examples/pump-app/pump-common/pump-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,7 @@ server cluster OnOff = 6 {
readonly attribute boolean globalSceneControl = 16384;
attribute int16u onTime = 16385;
attribute int16u offWaitTime = 16386;
attribute enum8 startUpOnOff = 16387;
attribute nullable enum8 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 @@ -1448,7 +1448,7 @@ client cluster OnOff = 6 {
readonly attribute boolean globalSceneControl = 16384;
attribute int16u onTime = 16385;
attribute int16u offWaitTime = 16386;
attribute enum8 startUpOnOff = 16387;
attribute nullable enum8 startUpOnOff = 16387;
readonly global attribute bitmap32 featureMap = 65532;
readonly global attribute int16u clusterRevision = 65533;

Expand Down Expand Up @@ -1485,7 +1485,7 @@ server cluster OnOff = 6 {
readonly attribute boolean globalSceneControl = 16384;
attribute int16u onTime = 16385;
attribute int16u offWaitTime = 16386;
attribute enum8 startUpOnOff = 16387;
attribute nullable enum8 startUpOnOff = 16387;
readonly global attribute bitmap32 featureMap = 65532;
readonly global attribute int16u clusterRevision = 65533;

Expand Down
39 changes: 20 additions & 19 deletions src/app/clusters/on-off-server/on-off-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,35 +229,36 @@ void OnOffServer::initOnOffServer(chip::EndpointId endpoint)
// set the OnOff attribute to 1.If the previous value of the OnOff
// attribute is equal to 1, set the OnOff attribute to 0 (toggle).
// 0x03-0xfe These values are reserved. No action.
// 0xff Set the OnOff attribute to its previous value.
// 0xff This value cannot happen.
// null Set the OnOff attribute to its previous value.

// Initialize startUpOnOff to No action value 0xFE
uint8_t startUpOnOff = 0xFE;
EmberAfStatus status = Attributes::StartUpOnOff::Get(endpoint, &startUpOnOff);
app::DataModel::Nullable<uint8_t> startUpOnOff;
EmberAfStatus status = Attributes::StartUpOnOff::Get(endpoint, startUpOnOff);
if (status == EMBER_ZCL_STATUS_SUCCESS)
{
// Initialise updated value to 0
bool updatedOnOff = 0;
status = Attributes::OnOff::Get(endpoint, &updatedOnOff);
if (status == EMBER_ZCL_STATUS_SUCCESS)
{
switch (startUpOnOff)
if (!startUpOnOff.IsNull())
{
case EMBER_ZCL_START_UP_ON_OFF_VALUE_SET_TO_OFF:
updatedOnOff = 0; // Off
break;
case EMBER_ZCL_START_UP_ON_OFF_VALUE_SET_TO_ON:
updatedOnOff = 1; // On
break;
case EMBER_ZCL_START_UP_ON_OFF_VALUE_SET_TO_TOGGLE:
updatedOnOff = !updatedOnOff;
break;
case EMBER_ZCL_START_UP_ON_OFF_VALUE_SET_TO_PREVIOUS:
jmartinez-silabs marked this conversation as resolved.
Show resolved Hide resolved
default:
// All other values 0x03- 0xFE are reserved - no action.
// When value is 0xFF - update with last value - that is as good as
// no action.
break;
switch (startUpOnOff.Value())
{
case EMBER_ZCL_START_UP_ON_OFF_VALUE_SET_TO_OFF:
updatedOnOff = 0; // Off
break;
case EMBER_ZCL_START_UP_ON_OFF_VALUE_SET_TO_ON:
updatedOnOff = 1; // On
break;
case EMBER_ZCL_START_UP_ON_OFF_VALUE_SET_TO_TOGGLE:
updatedOnOff = !updatedOnOff;
break;
default:
// All other values 0x03- 0xFE are reserved - no action.
break;
}
}
status = Attributes::OnOff::Set(endpoint, updatedOnOff);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,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" writable="true" optional="true">StartUpOnOff</attribute>
<attribute side="server" code="0x4003" define="START_UP_ON_OFF" type="enum8" default="0" writable="true" isNullable="true" optional="true">StartUpOnOff</attribute>
jmartinez-silabs marked this conversation as resolved.
Show resolved Hide resolved

<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
1 change: 0 additions & 1 deletion src/app/zap-templates/zcl/data-model/silabs/types.xml
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,6 @@ limitations under the License.
<item name="SetToOn" value="0x01"/>
<item name="SetToToggle" value="0x02"/>
<!-- 0x03-0xFF reserved -->
<item name="SetToPrevious" value="0xFF"/>
</enum>
<enum name="LevelControlOptions" type="BITMAP8">
<item name="ExecuteIfOff" value="0x1"/>
Expand Down
2 changes: 1 addition & 1 deletion src/controller/data_model/controller-clusters.matter
Original file line number Diff line number Diff line change
Expand Up @@ -2690,7 +2690,7 @@ client cluster OnOff = 6 {
readonly attribute boolean globalSceneControl = 16384;
attribute int16u onTime = 16385;
attribute int16u offWaitTime = 16386;
attribute enum8 startUpOnOff = 16387;
attribute nullable enum8 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
15 changes: 11 additions & 4 deletions src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp

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

12 changes: 10 additions & 2 deletions src/controller/java/zap-generated/CHIPClustersWrite-JNI.cpp

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

64 changes: 64 additions & 0 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.

29 changes: 29 additions & 0 deletions src/controller/java/zap-generated/CHIPReadCallbacks.h

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

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

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

Loading