Skip to content

Commit 2528441

Browse files
lpbeliveau-silabsrestyled-commitsbzbarsky-apple
authored andcommitted
[Scenes] Enabling the scene-cluster (#26186)
* 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 <bzbarsky@apple.com> * 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 <bzbarsky@apple.com> * Update src/app/clusters/groups-server/groups-server.cpp Co-authored-by: Boris Zbarsky <bzbarsky@apple.com> * Apply suggestions from code review Co-authored-by: Boris Zbarsky <bzbarsky@apple.com> * 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 <bzbarsky@apple.com> * Update src/app/clusters/scenes-server/SceneTableImpl.cpp Co-authored-by: Boris Zbarsky <bzbarsky@apple.com> * 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 <bzbarsky@apple.com> * 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 <bzbarsky@apple.com> * Update src/app/clusters/scenes-server/scenes-server.cpp Co-authored-by: Boris Zbarsky <bzbarsky@apple.com> * Added using for ScenesServer in Matter init callback --------- Co-authored-by: Restyled.io <commits@restyled.io> Co-authored-by: Boris Zbarsky <bzbarsky@apple.com>
1 parent 437ebb2 commit 2528441

File tree

53 files changed

+2710
-2114
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+2710
-2114
lines changed

examples/all-clusters-app/all-clusters-common/all-clusters-app.matter

+2-2
Original file line numberDiff line numberDiff line change
@@ -5072,14 +5072,14 @@ endpoint 1 {
50725072
}
50735073

50745074
server cluster Scenes {
5075-
ram attribute sceneCount default = 0x00;
5075+
callback attribute sceneCount default = 0x00;
50765076
ram attribute currentScene default = 0x00;
50775077
ram attribute currentGroup default = 0x0000;
50785078
ram attribute sceneValid default = 0x00;
50795079
ram attribute nameSupport;
50805080
ram attribute lastConfiguredBy;
50815081
ram attribute sceneTableSize;
5082-
ram attribute remainingCapacity;
5082+
callback attribute remainingCapacity;
50835083
ram attribute featureMap default = 0;
50845084
ram attribute clusterRevision default = 4;
50855085
}

examples/all-clusters-app/esp32/main/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ set(SRC_DIRS_LIST
7070
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/thermostat-user-interface-configuration-server"
7171
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/thread-network-diagnostics-server"
7272
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/channel-server"
73-
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/scenes"
73+
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/scenes-server"
7474
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/software-diagnostics-server"
7575
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/switch-server"
7676
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/general-diagnostics-server"

examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter

+2-2
Original file line numberDiff line numberDiff line change
@@ -4181,14 +4181,14 @@ endpoint 1 {
41814181
}
41824182

41834183
server cluster Scenes {
4184-
ram attribute sceneCount default = 0x00;
4184+
callback attribute sceneCount default = 0x00;
41854185
ram attribute currentScene default = 0x00;
41864186
ram attribute currentGroup default = 0x0000;
41874187
ram attribute sceneValid default = 0x00;
41884188
ram attribute nameSupport;
41894189
ram attribute lastConfiguredBy;
41904190
ram attribute sceneTableSize;
4191-
ram attribute remainingCapacity;
4191+
callback attribute remainingCapacity;
41924192
ram attribute featureMap default = 0;
41934193
ram attribute clusterRevision default = 4;
41944194
}

examples/all-clusters-minimal-app/esp32/main/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ set(SRC_DIRS_LIST
6767
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/thermostat-user-interface-configuration-server"
6868
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/thread-network-diagnostics-server"
6969
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/channel-server"
70-
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/scenes"
70+
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/scenes-server"
7171
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/software-diagnostics-server"
7272
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/switch-server"
7373
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/general-diagnostics-server"

examples/lighting-app/esp32/main/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ set(SRC_DIRS_LIST
6464
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/ota-requestor"
6565
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/groups-server"
6666
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/group-key-mgmt-server"
67+
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/scenes-server"
6768
)
6869

6970
set(PRIV_REQUIRES_LIST chip QRCode bt led_strip app_update openthread driver nvs_flash spi_flash)

examples/lighting-app/lighting-common/lighting-app.matter

+161
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,150 @@ server cluster Groups = 4 {
126126
fabric command access(invoke: manage) AddGroupIfIdentifying(AddGroupIfIdentifyingRequest): DefaultSuccess = 5;
127127
}
128128

129+
/** Attributes and commands for scene configuration and manipulation. */
130+
server cluster Scenes = 5 {
131+
bitmap Feature : BITMAP32 {
132+
kSceneNames = 0x1;
133+
}
134+
135+
bitmap ScenesCopyMode : BITMAP8 {
136+
kCopyAllScenes = 0x1;
137+
}
138+
139+
struct AttributeValuePair {
140+
optional attrib_id attributeID = 0;
141+
int32u attributeValue = 1;
142+
}
143+
144+
struct ExtensionFieldSet {
145+
cluster_id clusterID = 0;
146+
AttributeValuePair attributeValueList[] = 1;
147+
}
148+
149+
readonly attribute int8u sceneCount = 0;
150+
readonly attribute int8u currentScene = 1;
151+
readonly attribute group_id currentGroup = 2;
152+
readonly attribute boolean sceneValid = 3;
153+
readonly attribute bitmap8 nameSupport = 4;
154+
readonly attribute nullable node_id lastConfiguredBy = 5;
155+
readonly attribute int16u sceneTableSize = 6;
156+
readonly attribute int8u remainingCapacity = 7;
157+
readonly attribute command_id generatedCommandList[] = 65528;
158+
readonly attribute command_id acceptedCommandList[] = 65529;
159+
readonly attribute event_id eventList[] = 65530;
160+
readonly attribute attrib_id attributeList[] = 65531;
161+
readonly attribute bitmap32 featureMap = 65532;
162+
readonly attribute int16u clusterRevision = 65533;
163+
164+
request struct AddSceneRequest {
165+
group_id groupID = 0;
166+
INT8U sceneID = 1;
167+
INT16U transitionTime = 2;
168+
CHAR_STRING sceneName = 3;
169+
ExtensionFieldSet extensionFieldSets[] = 4;
170+
}
171+
172+
request struct ViewSceneRequest {
173+
group_id groupID = 0;
174+
INT8U sceneID = 1;
175+
}
176+
177+
request struct RemoveSceneRequest {
178+
group_id groupID = 0;
179+
INT8U sceneID = 1;
180+
}
181+
182+
request struct RemoveAllScenesRequest {
183+
group_id groupID = 0;
184+
}
185+
186+
request struct StoreSceneRequest {
187+
group_id groupID = 0;
188+
INT8U sceneID = 1;
189+
}
190+
191+
request struct RecallSceneRequest {
192+
group_id groupID = 0;
193+
INT8U sceneID = 1;
194+
optional nullable INT16U transitionTime = 2;
195+
}
196+
197+
request struct GetSceneMembershipRequest {
198+
group_id groupID = 0;
199+
}
200+
201+
request struct EnhancedAddSceneRequest {
202+
group_id groupID = 0;
203+
INT8U sceneID = 1;
204+
INT16U transitionTime = 2;
205+
CHAR_STRING sceneName = 3;
206+
ExtensionFieldSet extensionFieldSets[] = 4;
207+
}
208+
209+
request struct EnhancedViewSceneRequest {
210+
group_id groupID = 0;
211+
INT8U sceneID = 1;
212+
}
213+
214+
request struct CopySceneRequest {
215+
ScenesCopyMode mode = 0;
216+
group_id groupIdentifierFrom = 1;
217+
INT8U sceneIdentifierFrom = 2;
218+
group_id groupIdentifierTo = 3;
219+
INT8U sceneIdentifierTo = 4;
220+
}
221+
222+
response struct AddSceneResponse = 0 {
223+
status status = 0;
224+
group_id groupID = 1;
225+
INT8U sceneID = 2;
226+
}
227+
228+
response struct ViewSceneResponse = 1 {
229+
status status = 0;
230+
group_id groupID = 1;
231+
INT8U sceneID = 2;
232+
optional INT16U transitionTime = 3;
233+
optional CHAR_STRING sceneName = 4;
234+
optional ExtensionFieldSet extensionFieldSets[] = 5;
235+
}
236+
237+
response struct RemoveSceneResponse = 2 {
238+
status status = 0;
239+
group_id groupID = 1;
240+
INT8U sceneID = 2;
241+
}
242+
243+
response struct RemoveAllScenesResponse = 3 {
244+
status status = 0;
245+
group_id groupID = 1;
246+
}
247+
248+
response struct StoreSceneResponse = 4 {
249+
status status = 0;
250+
group_id groupID = 1;
251+
INT8U sceneID = 2;
252+
}
253+
254+
response struct GetSceneMembershipResponse = 6 {
255+
status status = 0;
256+
nullable INT8U capacity = 1;
257+
group_id groupID = 2;
258+
optional INT8U sceneList[] = 3;
259+
}
260+
261+
fabric command access(invoke: manage) AddScene(AddSceneRequest): AddSceneResponse = 0;
262+
fabric command ViewScene(ViewSceneRequest): ViewSceneResponse = 1;
263+
fabric command access(invoke: manage) RemoveScene(RemoveSceneRequest): RemoveSceneResponse = 2;
264+
fabric command access(invoke: manage) RemoveAllScenes(RemoveAllScenesRequest): RemoveAllScenesResponse = 3;
265+
fabric command access(invoke: manage) StoreScene(StoreSceneRequest): StoreSceneResponse = 4;
266+
fabric command RecallScene(RecallSceneRequest): DefaultSuccess = 5;
267+
fabric command GetSceneMembership(GetSceneMembershipRequest): GetSceneMembershipResponse = 6;
268+
fabric command EnhancedAddScene(EnhancedAddSceneRequest): EnhancedAddSceneResponse = 64;
269+
fabric command EnhancedViewScene(EnhancedViewSceneRequest): EnhancedViewSceneResponse = 65;
270+
fabric command CopyScene(CopySceneRequest): CopySceneResponse = 66;
271+
}
272+
129273
/** Attributes and commands for switching devices between 'On' and 'Off' states. */
130274
server cluster OnOff = 6 {
131275
enum OnOffDelayedAllOffEffectVariant : ENUM8 {
@@ -2252,6 +2396,23 @@ endpoint 1 {
22522396
ram attribute clusterRevision default = 4;
22532397
}
22542398

2399+
server cluster Scenes {
2400+
callback attribute sceneCount default = 0x00;
2401+
ram attribute currentScene default = 0x00;
2402+
ram attribute currentGroup default = 0x0000;
2403+
ram attribute sceneValid default = 0x00;
2404+
ram attribute nameSupport default = 0x80;
2405+
ram attribute lastConfiguredBy;
2406+
ram attribute sceneTableSize;
2407+
callback attribute remainingCapacity;
2408+
callback attribute generatedCommandList;
2409+
callback attribute acceptedCommandList;
2410+
callback attribute eventList;
2411+
callback attribute attributeList;
2412+
ram attribute featureMap default = 1;
2413+
ram attribute clusterRevision default = 4;
2414+
}
2415+
22552416
server cluster OnOff {
22562417
persist attribute onOff default = 0x00;
22572418
ram attribute globalSceneControl default = 0x01;

examples/lighting-app/lighting-common/lighting-app.zap

+130-2
Original file line numberDiff line numberDiff line change
@@ -5843,7 +5843,7 @@
58435843
"mfgCode": null,
58445844
"define": "SCENES_CLUSTER",
58455845
"side": "server",
5846-
"enabled": 0,
5846+
"enabled": 1,
58475847
"commands": [
58485848
{
58495849
"name": "AddSceneResponse",
@@ -5969,12 +5969,140 @@
59695969
"storageOption": "RAM",
59705970
"singleton": 0,
59715971
"bounded": 0,
5972-
"defaultValue": "",
5972+
"defaultValue": "0x80",
59735973
"reportable": 1,
59745974
"minInterval": 0,
59755975
"maxInterval": 65344,
59765976
"reportableChange": 0
59775977
},
5978+
{
5979+
"name": "LastConfiguredBy",
5980+
"code": 5,
5981+
"mfgCode": null,
5982+
"side": "server",
5983+
"type": "node_id",
5984+
"included": 1,
5985+
"storageOption": "RAM",
5986+
"singleton": 0,
5987+
"bounded": 0,
5988+
"defaultValue": "",
5989+
"reportable": 1,
5990+
"minInterval": 1,
5991+
"maxInterval": 65534,
5992+
"reportableChange": 0
5993+
},
5994+
{
5995+
"name": "SceneTableSize",
5996+
"code": 6,
5997+
"mfgCode": null,
5998+
"side": "server",
5999+
"type": "int16u",
6000+
"included": 1,
6001+
"storageOption": "RAM",
6002+
"singleton": 0,
6003+
"bounded": 0,
6004+
"defaultValue": "",
6005+
"reportable": 1,
6006+
"minInterval": 1,
6007+
"maxInterval": 65534,
6008+
"reportableChange": 0
6009+
},
6010+
{
6011+
"name": "RemainingCapacity",
6012+
"code": 7,
6013+
"mfgCode": null,
6014+
"side": "server",
6015+
"type": "int8u",
6016+
"included": 1,
6017+
"storageOption": "RAM",
6018+
"singleton": 0,
6019+
"bounded": 0,
6020+
"defaultValue": "",
6021+
"reportable": 1,
6022+
"minInterval": 1,
6023+
"maxInterval": 65534,
6024+
"reportableChange": 0
6025+
},
6026+
{
6027+
"name": "GeneratedCommandList",
6028+
"code": 65528,
6029+
"mfgCode": null,
6030+
"side": "server",
6031+
"type": "array",
6032+
"included": 1,
6033+
"storageOption": "External",
6034+
"singleton": 0,
6035+
"bounded": 0,
6036+
"defaultValue": "",
6037+
"reportable": 1,
6038+
"minInterval": 1,
6039+
"maxInterval": 65534,
6040+
"reportableChange": 0
6041+
},
6042+
{
6043+
"name": "AcceptedCommandList",
6044+
"code": 65529,
6045+
"mfgCode": null,
6046+
"side": "server",
6047+
"type": "array",
6048+
"included": 1,
6049+
"storageOption": "External",
6050+
"singleton": 0,
6051+
"bounded": 0,
6052+
"defaultValue": "",
6053+
"reportable": 1,
6054+
"minInterval": 1,
6055+
"maxInterval": 65534,
6056+
"reportableChange": 0
6057+
},
6058+
{
6059+
"name": "EventList",
6060+
"code": 65530,
6061+
"mfgCode": null,
6062+
"side": "server",
6063+
"type": "array",
6064+
"included": 1,
6065+
"storageOption": "External",
6066+
"singleton": 0,
6067+
"bounded": 0,
6068+
"defaultValue": "",
6069+
"reportable": 1,
6070+
"minInterval": 1,
6071+
"maxInterval": 65534,
6072+
"reportableChange": 0
6073+
},
6074+
{
6075+
"name": "AttributeList",
6076+
"code": 65531,
6077+
"mfgCode": null,
6078+
"side": "server",
6079+
"type": "array",
6080+
"included": 1,
6081+
"storageOption": "External",
6082+
"singleton": 0,
6083+
"bounded": 0,
6084+
"defaultValue": "",
6085+
"reportable": 1,
6086+
"minInterval": 1,
6087+
"maxInterval": 65534,
6088+
"reportableChange": 0
6089+
},
6090+
{
6091+
"name": "FeatureMap",
6092+
"code": 65532,
6093+
"mfgCode": null,
6094+
"side": "server",
6095+
"type": "bitmap32",
6096+
"included": 1,
6097+
"storageOption": "RAM",
6098+
"singleton": 0,
6099+
"bounded": 0,
6100+
"defaultValue": "1",
6101+
"reportable": 1,
6102+
"minInterval": 1,
6103+
"maxInterval": 65534,
6104+
"reportableChange": 0
6105+
},
59786106
{
59796107
"name": "ClusterRevision",
59806108
"code": 65533,

0 commit comments

Comments
 (0)