@@ -56,40 +56,52 @@ class SceneHandler
56
56
SceneHandler (){};
57
57
virtual ~SceneHandler () = default ;
58
58
59
+ // / @brief Gets the list of supported clusters for an endpoint
60
+ // / @param endpoint target endpoint
61
+ // / @param clusterBuffer Buffer to hold the supported cluster IDs, cannot hold more than
62
+ // / CHIP_CONFIG_SCENES_MAX_CLUSTERS_PER_SCENES
63
+ virtual void GetSupportedClusters (EndpointId endpoint, Span<ClusterId> & clusterBuffer) = 0;
64
+
65
+ // / @brief Returns whether or not a cluster is supported on an endpoint
66
+ // / @param endpoint Target Endpoint ID
67
+ // / @param cluster Target Cluster ID
68
+ // / @return true if supported, false if not supported
59
69
virtual bool SupportsCluster (EndpointId endpoint, ClusterId cluster) = 0;
60
70
61
71
// / @brief From command AddScene, allows handler to filter through clusters in command to serialize only the supported ones.
62
72
// / @param endpoint Endpoint ID
63
73
// / @param cluster Cluster ID to fetch from command
64
- // / @param serialysedBytes Buffer for ExtensionFieldSet in command
74
+ // / @param serialisedBytes Buffer for ExtensionFieldSet in command
65
75
// / @param extensionFieldSet ExtensionFieldSets provided by the AddScene Command
66
- // / @return
67
- virtual CHIP_ERROR SerializeAdd (EndpointId endpoint, ClusterId & cluster, MutableByteSpan & serialysedBytes ,
76
+ // / @return CHIP_NO_ERROR if successful, CHIP_ERROR value otherwise
77
+ virtual CHIP_ERROR SerializeAdd (EndpointId endpoint, ClusterId & cluster, MutableByteSpan & serialisedBytes ,
68
78
app::Clusters::Scenes::Structs::ExtensionFieldSet::DecodableType & extensionFieldSet) = 0;
69
79
70
- // / @brief From command SaveScene, retrieves ExtensionField from nvm
71
- // / @param endpoint
72
- // / @param cluster
73
- // / @param serialysedBytes
74
- // / @return
75
- virtual CHIP_ERROR SerializeSave (EndpointId endpoint, ClusterId cluster, MutableByteSpan & serialysedBytes) = 0;
80
+ // / @brief From command StoreScene, retrieves ExtensionField from nvm, it is the functions responsability to resize the mutable
81
+ // / span if necessary, a number of byte equal to the span will be stored in memory
82
+ // / @param endpoint Target Endpoint
83
+ // / @param cluster Target Cluster
84
+ // / @param serialisedBytes Output buffer, data needs to be writen in there and size adjusted if smaller than
85
+ // / kMaxFieldsPerCluster
86
+ // / @return CHIP_NO_ERROR if successful, CHIP_ERROR value otherwise
87
+ virtual CHIP_ERROR SerializeSave (EndpointId endpoint, ClusterId cluster, MutableByteSpan & serialisedBytes) = 0;
76
88
77
89
// / @brief From stored scene (e.g. ViewScene), deserialize ExtensionFieldSet into a command object
78
90
// / @param endpoint Endpoint ID
79
- // / @param cluster Cluster ID to set in command
80
- // / @param serialysedBytes ExtensionFieldSet stored in NVM
91
+ // / @param cluster Cluster ID to save
92
+ // / @param serialisedBytes ExtensionFieldSet stored in NVM
81
93
// / @param extensionFieldSet ExtensionFieldSet in command format
82
- // / @return
83
- virtual CHIP_ERROR Deserialize (EndpointId endpoint, ClusterId cluster, ByteSpan & serialysedBytes ,
94
+ // / @return CHIP_NO_ERROR if successful, CHIP_ERROR value otherwise
95
+ virtual CHIP_ERROR Deserialize (EndpointId endpoint, ClusterId cluster, ByteSpan & serialisedBytes ,
84
96
app::Clusters::Scenes::Structs::ExtensionFieldSet::Type & extensionFieldSet) = 0;
85
97
86
98
// / @brief From stored scene (e.g RecallScene), applies EFS values to cluster at transition time
87
99
// / @param endpoint Endpoint ID
88
100
// / @param cluster Cluster ID
89
- // / @param serialysedBytes ExtensionFieldSet stored in NVM
101
+ // / @param serialisedBytes ExtensionFieldSet stored in NVM
90
102
// / @param timeMs Transition time in ms to apply the scene
91
- // / @return
92
- virtual CHIP_ERROR ApplyScene (EndpointId endpoint, ClusterId cluster, ByteSpan & serialysedBytes , TransitionTimeMs timeMs) = 0;
103
+ // / @return CHIP_NO_ERROR if successful, CHIP_ERROR value otherwise
104
+ virtual CHIP_ERROR ApplyScene (EndpointId endpoint, ClusterId cluster, ByteSpan & serialisedBytes , TransitionTimeMs timeMs) = 0;
93
105
};
94
106
95
107
class SceneTable
@@ -318,21 +330,50 @@ class SceneTable
318
330
virtual CHIP_ERROR RemoveSceneTableEntry (FabricIndex fabric_index, SceneStorageId scene_id) = 0;
319
331
virtual CHIP_ERROR RemoveSceneTableEntryAtPosition (FabricIndex fabric_index, SceneIndex scened_idx) = 0;
320
332
321
- // Iterators
322
- using SceneEntryIterator = CommonIterator<SceneTableEntry>;
333
+ // SceneHandlers
334
+ virtual CHIP_ERROR RegisterHandler (SceneHandler * handler) = 0;
335
+ virtual CHIP_ERROR UnregisterHandler (uint8_t position) = 0;
323
336
324
- virtual SceneEntryIterator * IterateSceneEntry (FabricIndex fabric_index) = 0;
337
+ // Extension field sets operation
338
+ virtual CHIP_ERROR SceneSaveEFS (SceneTableEntry & scene) = 0;
339
+ virtual CHIP_ERROR SceneApplyEFS (FabricIndex fabric_index, const SceneStorageId & scene_id) = 0;
325
340
326
341
// Fabrics
327
342
virtual CHIP_ERROR RemoveFabric (FabricIndex fabric_index) = 0;
328
343
344
+ // Iterators
345
+ using SceneEntryIterator = CommonIterator<SceneTableEntry>;
346
+
347
+ virtual SceneEntryIterator * IterateSceneEntry (FabricIndex fabric_index) = 0;
348
+
329
349
// Handlers
330
- SceneHandler * mHandlers [CHIP_CONFIG_SCENES_MAX_CLUSTERS_PER_SCENES] = { nullptr };
331
- uint8_t handlerNum = 0 ;
350
+ virtual bool HandlerListEmpty () { return (handlerNum == 0 ); }
351
+ virtual bool HandlerListFull () { return (handlerNum >= kMaxSceneHandlers ); }
352
+ virtual uint8_t GetHandlerNum () { return this ->handlerNum ; }
332
353
333
- protected:
334
- const uint8_t mMaxScenePerFabric = kMaxScenePerFabric ;
354
+ SceneHandler * mHandlers [ kMaxSceneHandlers ] = { nullptr };
355
+ uint8_t handlerNum = 0 ;
335
356
};
336
357
358
+ /* *
359
+ * Instance getter for the global SceneTable.
360
+ *
361
+ * Callers have to externally synchronize usage of this function.
362
+ *
363
+ * @return The global Scene Table
364
+ */
365
+ SceneTable * GetSceneTable ();
366
+
367
+ /* *
368
+ * Instance setter for the global Scene Table.
369
+ *
370
+ * Callers have to externally synchronize usage of this function.
371
+ *
372
+ * The `provider` can be set to nullptr if the owner is done with it fully.
373
+ *
374
+ * @param[in] provider pointer to the Scene Table global instance to use
375
+ */
376
+ void SetSceneTable (SceneTable * provider);
377
+
337
378
} // namespace scenes
338
379
} // namespace chip
0 commit comments