Skip to content

Commit

Permalink
[nrfconnect] Include GenericSwitch in light-switch example (#19848)
Browse files Browse the repository at this point in the history
* [nrfconnect] Include GenericSwitch in light-switch example

In matter there are 2 types of light switch device types:

- On/Off Light Switch, Dimmer Switch, Color Dimmer Switch, Control Bridge
- Generic Switch

Up to now only the first type was shown in the light-switch example. This commit adds GenericSwitch for the nrfconnect light-switch sample.

The GenericSwitch has been added on EP 2 and uses button 3.

Testing using chip-tool and DK:

        chip-tool interactive start

Subscribe to the initial-press and short-release

        >>> switch subscribe-event initial-press 1 20 <node_id> 2 --is-urgent true
        >>> switch subscribe-event initial-press 1 20 <node_id> 2 --is-urgent true

The code implements a momentary switch with features MS and MSR.

* Restyled by whitespace

* Restyled by clang-format

* Restyled by prettier-markdown

* Add missed generated file.

* Restyled by prettier-markdown

* Adress review comments

* Directly calling GenericSwitchInitialPress/GenericSwitchReleasePress without Timer
* Rename newPosition/previousPosition

* Update zap

* Remove Switch cluster on EP0
* Disabled Groups, Scenes, Binding on EP2
* Named EP2

* Correct previousPosition and newPosition.

* Apply suggestions from code review

Thanks @greg-fer.

Co-authored-by: Grzegorz Ferenc <[email protected]>

* Restyled by clang-format

* Restyled by prettier-markdown

* Correct second subscription command in README

* Remove leading >>> in commands

* Use backticks for commands

Co-authored-by: Restyled.io <[email protected]>
Co-authored-by: Grzegorz Ferenc <[email protected]>
  • Loading branch information
3 people authored and pull[bot] committed Jun 24, 2022
1 parent 7f8540a commit 1275833
Show file tree
Hide file tree
Showing 11 changed files with 1,582 additions and 85 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ client cluster Identify = 3 {

attribute int16u identifyTime = 0;
readonly attribute enum8 identifyType = 1;
readonly attribute command_id generatedCommandList[] = 65528;
readonly attribute command_id acceptedCommandList[] = 65529;
readonly attribute attrib_id attributeList[] = 65531;
readonly attribute bitmap32 featureMap = 65532;
readonly attribute int16u clusterRevision = 65533;
Expand Down Expand Up @@ -61,6 +63,8 @@ server cluster Identify = 3 {

attribute int16u identifyTime = 0;
readonly attribute enum8 identifyType = 1;
readonly attribute command_id generatedCommandList[] = 65528;
readonly attribute command_id acceptedCommandList[] = 65529;
readonly attribute attrib_id attributeList[] = 65531;
readonly attribute bitmap32 featureMap = 65532;
readonly attribute int16u clusterRevision = 65533;
Expand Down Expand Up @@ -300,6 +304,8 @@ server cluster Descriptor = 29 {
readonly attribute CLUSTER_ID serverList[] = 1;
readonly attribute CLUSTER_ID clientList[] = 2;
readonly attribute ENDPOINT_NO partsList[] = 3;
readonly attribute command_id generatedCommandList[] = 65528;
readonly attribute command_id acceptedCommandList[] = 65529;
readonly attribute attrib_id attributeList[] = 65531;
readonly attribute bitmap32 featureMap = 65532;
readonly attribute int16u clusterRevision = 65533;
Expand Down Expand Up @@ -1229,6 +1235,11 @@ server cluster Switch = 59 {
INT8U totalNumberOfPressesCounted = 1;
}

readonly attribute int8u numberOfPositions = 0;
readonly attribute int8u currentPosition = 1;
readonly attribute command_id generatedCommandList[] = 65528;
readonly attribute command_id acceptedCommandList[] = 65529;
readonly attribute attrib_id attributeList[] = 65531;
readonly attribute bitmap32 featureMap = 65532;
readonly attribute int16u clusterRevision = 65533;
}
Expand Down Expand Up @@ -1920,11 +1931,6 @@ endpoint 0 {
ram attribute clusterRevision default = 1;
}

server cluster Switch {
ram attribute featureMap;
ram attribute clusterRevision default = 1;
}

server cluster AdministratorCommissioning {
callback attribute windowStatus;
callback attribute adminFabricIndex default = 1;
Expand Down Expand Up @@ -2002,5 +2008,40 @@ endpoint 1 {
ram attribute clusterRevision default = 1;
}
}
endpoint 2 {
device type genericswitch = 15;

server cluster Identify {
ram attribute identifyTime;
ram attribute identifyType;
callback attribute generatedCommandList;
callback attribute acceptedCommandList;
callback attribute attributeList;
ram attribute featureMap;
ram attribute clusterRevision default = 2;
}

server cluster Descriptor {
callback attribute deviceList;
callback attribute serverList;
callback attribute clientList;
callback attribute partsList;
callback attribute generatedCommandList;
callback attribute acceptedCommandList;
callback attribute attributeList;
ram attribute featureMap;
ram attribute clusterRevision default = 1;
}

server cluster Switch {
ram attribute numberOfPositions default = 2;
ram attribute currentPosition;
callback attribute generatedCommandList;
callback attribute acceptedCommandList;
callback attribute attributeList;
ram attribute featureMap default = 2;
ram attribute clusterRevision default = 1;
}
}


Loading

0 comments on commit 1275833

Please sign in to comment.