Skip to content

Commit

Permalink
[Scenes] Enabling the scene-cluster (#26186)
Browse files Browse the repository at this point in the history
* Merge for rebase onto master

* Restyled by whitespace

* fixed shadowing in InvokeCommand, modified scenes to scenes-server in CMakeList.txt

* Regenerated zap files and .matter files for lighting app with Scenes

* Modified CMakeList for lighting app to include scene src files

* Apply suggestions from code review, swapped checks on groupId != 0, replaced static_cast with to underlying, used StatusIB to convert CHIP_ERROR to status, refactored names of callbacks called from other clusters, got rid of unused functions, fixed integer promotion truncation, remove un-neccessary copies, added checks on sceneHandler failures and assertion on size for static casts.
Co-authored-by: Boris Zbarsky <[email protected]>

* Removed scenes-tokens.h

* removed scenes-token.h for test's BUID.gn

* Regenerated zap files

* Rework of endpoint scope in progress

* Completed refactor of SceneTable to have per endpoint flash storage, adapted test to function with it, needs to add multi-endpoints tests

* WIP for Attributes handling, needs to add checks on status for Sets and Gets

* Refactored the scenes table and scenes server to be endpoint scoped and removed attribute interface override

* Fix multi-endpoint on scenes-server cluster, updated attribute access override, added function to add status to response and response to handler in the event of failure to shortent code

* Restyled by whitespace

* Restyled by clang-format

* Applied changes to build after rebase and regenerated zap files

* Restyled by shfmt

* Fixed uint16 to uint8 conversion issues in SceneTableImpl

* Apply suggestions from code review

Co-authored-by: Boris Zbarsky <[email protected]>

* Update src/app/clusters/groups-server/groups-server.cpp

Co-authored-by: Boris Zbarsky <[email protected]>

* Apply suggestions from code review

Co-authored-by: Boris Zbarsky <[email protected]>

* Removed un-necessary attribute assignation, added attribute dirtying instead. Created method to avoid code dupplication on LastConfiguredId update, addressed low hanging fruits in code style and missing checks

* Added missing description for scene storage key allocators and removed un necessary config for max transition time

* Restyled by clang-format

* Restyled by prettier-json

* Shadowing fix

* Update src/lib/support/DefaultStorageKeyAllocator.h

Co-authored-by: Boris Zbarsky <[email protected]>

* Update src/app/clusters/scenes-server/SceneTableImpl.cpp

Co-authored-by: Boris Zbarsky <[email protected]>

* Add comment on Storage Keys, removed unused variables in comments and moved transition time add to response to after success

* Restyled by clang-format

* Apply suggestions from code review

Co-authored-by: Boris Zbarsky <[email protected]>

* Removed un-necessary check on transition time

* Restyled by whitespace

* Restyled by clang-format

* Added missing uint16_t in loop to mMaxScenesPerFabric

* Added check on nullptr in TestSceneTable

* Moved init to MatterScenesPluginServerInitCallback to allow all-cluster-app to initialize for tests

* Update src/app/clusters/scenes-server/scenes-server.cpp

Co-authored-by: Boris Zbarsky <[email protected]>

* Update src/app/clusters/scenes-server/scenes-server.cpp

Co-authored-by: Boris Zbarsky <[email protected]>

* Added using for ScenesServer in Matter init callback

---------

Co-authored-by: Restyled.io <[email protected]>
Co-authored-by: Boris Zbarsky <[email protected]>
  • Loading branch information
3 people authored and pull[bot] committed Jul 11, 2023
1 parent 26e8c58 commit 2197017
Show file tree
Hide file tree
Showing 53 changed files with 2,710 additions and 2,114 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5072,14 +5072,14 @@ endpoint 1 {
}

server cluster Scenes {
ram attribute sceneCount default = 0x00;
callback attribute sceneCount default = 0x00;
ram attribute currentScene default = 0x00;
ram attribute currentGroup default = 0x0000;
ram attribute sceneValid default = 0x00;
ram attribute nameSupport;
ram attribute lastConfiguredBy;
ram attribute sceneTableSize;
ram attribute remainingCapacity;
callback attribute remainingCapacity;
ram attribute featureMap default = 0;
ram attribute clusterRevision default = 4;
}
Expand Down
2 changes: 1 addition & 1 deletion examples/all-clusters-app/esp32/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ set(SRC_DIRS_LIST
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/thermostat-user-interface-configuration-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/thread-network-diagnostics-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/channel-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/scenes"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/scenes-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/software-diagnostics-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/switch-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/general-diagnostics-server"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4181,14 +4181,14 @@ endpoint 1 {
}

server cluster Scenes {
ram attribute sceneCount default = 0x00;
callback attribute sceneCount default = 0x00;
ram attribute currentScene default = 0x00;
ram attribute currentGroup default = 0x0000;
ram attribute sceneValid default = 0x00;
ram attribute nameSupport;
ram attribute lastConfiguredBy;
ram attribute sceneTableSize;
ram attribute remainingCapacity;
callback attribute remainingCapacity;
ram attribute featureMap default = 0;
ram attribute clusterRevision default = 4;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ set(SRC_DIRS_LIST
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/thermostat-user-interface-configuration-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/thread-network-diagnostics-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/channel-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/scenes"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/scenes-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/software-diagnostics-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/switch-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/general-diagnostics-server"
Expand Down
1 change: 1 addition & 0 deletions examples/lighting-app/esp32/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ set(SRC_DIRS_LIST
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/ota-requestor"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/groups-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/group-key-mgmt-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/scenes-server"
)

set(PRIV_REQUIRES_LIST chip QRCode bt led_strip app_update openthread driver nvs_flash spi_flash)
Expand Down
161 changes: 161 additions & 0 deletions examples/lighting-app/lighting-common/lighting-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,150 @@ server cluster Groups = 4 {
fabric command access(invoke: manage) AddGroupIfIdentifying(AddGroupIfIdentifyingRequest): DefaultSuccess = 5;
}

/** Attributes and commands for scene configuration and manipulation. */
server cluster Scenes = 5 {
bitmap Feature : BITMAP32 {
kSceneNames = 0x1;
}

bitmap ScenesCopyMode : BITMAP8 {
kCopyAllScenes = 0x1;
}

struct AttributeValuePair {
optional attrib_id attributeID = 0;
int32u attributeValue = 1;
}

struct ExtensionFieldSet {
cluster_id clusterID = 0;
AttributeValuePair attributeValueList[] = 1;
}

readonly attribute int8u sceneCount = 0;
readonly attribute int8u currentScene = 1;
readonly attribute group_id currentGroup = 2;
readonly attribute boolean sceneValid = 3;
readonly attribute bitmap8 nameSupport = 4;
readonly attribute nullable node_id lastConfiguredBy = 5;
readonly attribute int16u sceneTableSize = 6;
readonly attribute int8u remainingCapacity = 7;
readonly attribute command_id generatedCommandList[] = 65528;
readonly attribute command_id acceptedCommandList[] = 65529;
readonly attribute event_id eventList[] = 65530;
readonly attribute attrib_id attributeList[] = 65531;
readonly attribute bitmap32 featureMap = 65532;
readonly attribute int16u clusterRevision = 65533;

request struct AddSceneRequest {
group_id groupID = 0;
INT8U sceneID = 1;
INT16U transitionTime = 2;
CHAR_STRING sceneName = 3;
ExtensionFieldSet extensionFieldSets[] = 4;
}

request struct ViewSceneRequest {
group_id groupID = 0;
INT8U sceneID = 1;
}

request struct RemoveSceneRequest {
group_id groupID = 0;
INT8U sceneID = 1;
}

request struct RemoveAllScenesRequest {
group_id groupID = 0;
}

request struct StoreSceneRequest {
group_id groupID = 0;
INT8U sceneID = 1;
}

request struct RecallSceneRequest {
group_id groupID = 0;
INT8U sceneID = 1;
optional nullable INT16U transitionTime = 2;
}

request struct GetSceneMembershipRequest {
group_id groupID = 0;
}

request struct EnhancedAddSceneRequest {
group_id groupID = 0;
INT8U sceneID = 1;
INT16U transitionTime = 2;
CHAR_STRING sceneName = 3;
ExtensionFieldSet extensionFieldSets[] = 4;
}

request struct EnhancedViewSceneRequest {
group_id groupID = 0;
INT8U sceneID = 1;
}

request struct CopySceneRequest {
ScenesCopyMode mode = 0;
group_id groupIdentifierFrom = 1;
INT8U sceneIdentifierFrom = 2;
group_id groupIdentifierTo = 3;
INT8U sceneIdentifierTo = 4;
}

response struct AddSceneResponse = 0 {
status status = 0;
group_id groupID = 1;
INT8U sceneID = 2;
}

response struct ViewSceneResponse = 1 {
status status = 0;
group_id groupID = 1;
INT8U sceneID = 2;
optional INT16U transitionTime = 3;
optional CHAR_STRING sceneName = 4;
optional ExtensionFieldSet extensionFieldSets[] = 5;
}

response struct RemoveSceneResponse = 2 {
status status = 0;
group_id groupID = 1;
INT8U sceneID = 2;
}

response struct RemoveAllScenesResponse = 3 {
status status = 0;
group_id groupID = 1;
}

response struct StoreSceneResponse = 4 {
status status = 0;
group_id groupID = 1;
INT8U sceneID = 2;
}

response struct GetSceneMembershipResponse = 6 {
status status = 0;
nullable INT8U capacity = 1;
group_id groupID = 2;
optional INT8U sceneList[] = 3;
}

fabric command access(invoke: manage) AddScene(AddSceneRequest): AddSceneResponse = 0;
fabric command ViewScene(ViewSceneRequest): ViewSceneResponse = 1;
fabric command access(invoke: manage) RemoveScene(RemoveSceneRequest): RemoveSceneResponse = 2;
fabric command access(invoke: manage) RemoveAllScenes(RemoveAllScenesRequest): RemoveAllScenesResponse = 3;
fabric command access(invoke: manage) StoreScene(StoreSceneRequest): StoreSceneResponse = 4;
fabric command RecallScene(RecallSceneRequest): DefaultSuccess = 5;
fabric command GetSceneMembership(GetSceneMembershipRequest): GetSceneMembershipResponse = 6;
fabric command EnhancedAddScene(EnhancedAddSceneRequest): EnhancedAddSceneResponse = 64;
fabric command EnhancedViewScene(EnhancedViewSceneRequest): EnhancedViewSceneResponse = 65;
fabric command CopyScene(CopySceneRequest): CopySceneResponse = 66;
}

/** Attributes and commands for switching devices between 'On' and 'Off' states. */
server cluster OnOff = 6 {
enum OnOffDelayedAllOffEffectVariant : ENUM8 {
Expand Down Expand Up @@ -2252,6 +2396,23 @@ endpoint 1 {
ram attribute clusterRevision default = 4;
}

server cluster Scenes {
callback attribute sceneCount default = 0x00;
ram attribute currentScene default = 0x00;
ram attribute currentGroup default = 0x0000;
ram attribute sceneValid default = 0x00;
ram attribute nameSupport default = 0x80;
ram attribute lastConfiguredBy;
ram attribute sceneTableSize;
callback attribute remainingCapacity;
callback attribute generatedCommandList;
callback attribute acceptedCommandList;
callback attribute eventList;
callback attribute attributeList;
ram attribute featureMap default = 1;
ram attribute clusterRevision default = 4;
}

server cluster OnOff {
persist attribute onOff default = 0x00;
ram attribute globalSceneControl default = 0x01;
Expand Down
132 changes: 130 additions & 2 deletions examples/lighting-app/lighting-common/lighting-app.zap
Original file line number Diff line number Diff line change
Expand Up @@ -5843,7 +5843,7 @@
"mfgCode": null,
"define": "SCENES_CLUSTER",
"side": "server",
"enabled": 0,
"enabled": 1,
"commands": [
{
"name": "AddSceneResponse",
Expand Down Expand Up @@ -5969,12 +5969,140 @@
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"defaultValue": "0x80",
"reportable": 1,
"minInterval": 0,
"maxInterval": 65344,
"reportableChange": 0
},
{
"name": "LastConfiguredBy",
"code": 5,
"mfgCode": null,
"side": "server",
"type": "node_id",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "SceneTableSize",
"code": 6,
"mfgCode": null,
"side": "server",
"type": "int16u",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "RemainingCapacity",
"code": 7,
"mfgCode": null,
"side": "server",
"type": "int8u",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "GeneratedCommandList",
"code": 65528,
"mfgCode": null,
"side": "server",
"type": "array",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "AcceptedCommandList",
"code": 65529,
"mfgCode": null,
"side": "server",
"type": "array",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "EventList",
"code": 65530,
"mfgCode": null,
"side": "server",
"type": "array",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "AttributeList",
"code": 65531,
"mfgCode": null,
"side": "server",
"type": "array",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "FeatureMap",
"code": 65532,
"mfgCode": null,
"side": "server",
"type": "bitmap32",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "1",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "ClusterRevision",
"code": 65533,
Expand Down
Loading

0 comments on commit 2197017

Please sign in to comment.