@@ -36,18 +36,25 @@ typedef uint32_t SceneTransitionTime;
36
36
constexpr GroupId kGlobalGroupSceneId = 0x0000 ;
37
37
constexpr SceneIndex kUndefinedSceneIndex = 0xff ;
38
38
constexpr SceneId kUndefinedSceneId = 0xff ;
39
- static constexpr uint8_t kMaxScenePerFabric = CHIP_CONFIG_SCENES_MAX_PER_FABRIC;
39
+ static constexpr uint8_t kMaxScenesPerFabric = CHIP_CONFIG_SCENES_MAX_PER_FABRIC;
40
+
40
41
static constexpr size_t kIteratorsMax = CHIP_CONFIG_MAX_SCENES_CONCURRENT_ITERATORS;
41
- static constexpr size_t kSceneNameMax = CHIP_CONFIG_SCENES_CLUSTER_MAXIMUM_NAME_LENGTH;
42
+ static constexpr size_t kSceneNameMaxLength = CHIP_CONFIG_SCENES_CLUSTER_MAXIMUM_NAME_LENGTH;
43
+
42
44
43
- // / @brief Abstract class allowing different Endpoints interactions with the ExtensionFieldSets added to and retrieved from the
44
- // / scene Table. The Scene Handler's are meant as interface between various clusters and the Scene table. The expected behaviour of
45
- // / the table with the handler is: Once a scene command involving extension field set is received, the Scene Table will go through
46
- // / the list of handlers to either retrieve, populate or apply Extension field sets. Each handler is meant to retrieve an extension
47
- // / field set for a single cluster however it is also possible to use a single generic handler that handles all of them.
45
+ // / @brief SceneHandlers are meant as interface between various clusters and the Scene table.
46
+ // / When a scene command involving extension field sets is received, the Scene Table will go through
47
+ // / the list of handlers to either retrieve, populate or apply those extension field sets.
48
+ // /
49
+ // / Generally, for each specific <endpoint, cluster> pair there should be one and only one handler
50
+ // / registered with the scene table that claims to handle that pair.
48
51
// /
49
- // / @note If more than one handler is implemented for a specific <endpoint, cluster> pair, ONLY THE FIRST HANDLER FOR THAT SPECIFIC
50
- // / PAIR will get called on executing extension field sets related ations on the scene table.
52
+ // / A SceneHandler can handle a single <endpoint, cluster> pair, or many such pairs.
53
+ // /
54
+ // / @note If more than one handler claims to handl a specific <endpoint, cluster> pair, only one of
55
+ // / those handlers will get called when executing actions related to extension field sets on the scene
56
+ // / table. It is not defined which handler will be selected.
57
+
51
58
class SceneHandler : public IntrusiveListNodeBase <>
52
59
{
53
60
public:
@@ -58,8 +65,10 @@ class SceneHandler : public IntrusiveListNodeBase<>
58
65
// / supported clusters
59
66
// / @param endpoint target endpoint
60
67
// / @param clusterBuffer Buffer to hold the supported cluster IDs, cannot hold more than
61
- // / CHIP_CONFIG_SCENES_MAX_CLUSTERS_PER_SCENES, the function shall use the reduce_size() method in the event it is supporting
62
- // / less than CHIP_CONFIG_SCENES_MAX_CLUSTERS_PER_SCENES clusters
68
+ // / CHIP_CONFIG_SCENES_MAX_CLUSTERS_PER_SCENE. The function shall use the reduce_size() method in the event it is supporting
69
+
70
+ // / less than CHIP_CONFIG_SCENES_MAX_CLUSTERS_PER_SCENE clusters.
71
+
63
72
virtual void GetSupportedClusters (EndpointId endpoint, Span<ClusterId> & clusterBuffer) = 0;
64
73
65
74
// / @brief Returns whether or not a cluster for scenes is supported on an endpoint
@@ -69,7 +78,8 @@ class SceneHandler : public IntrusiveListNodeBase<>
69
78
// / @return true if supported, false if not supported
70
79
virtual bool SupportsCluster (EndpointId endpoint, ClusterId cluster) = 0;
71
80
72
- // / @brief From command AddScene, allows handler to filter through clusters in command to serialize only the supported ones.
81
+ // / @brief Called when handling AddScene. Allows the handler to filter through the clusters in the command to serialize only the supported ones.
82
+
73
83
// / @param endpoint[in] Endpoint ID
74
84
// / @param extensionFieldSet[in] ExtensionFieldSets provided by the AddScene Command, pre initialized
75
85
// / @param cluster[out] Cluster in the Extension field set, filled by the function
@@ -79,10 +89,10 @@ class SceneHandler : public IntrusiveListNodeBase<>
79
89
const app::Clusters::Scenes::Structs::ExtensionFieldSet::DecodableType & extensionFieldSet,
80
90
ClusterId & cluster, MutableByteSpan & serialisedBytes) = 0;
81
91
82
- // / @brief From command StoreScene, retrieves ExtensionField from currently active values, it is the function's responsibility
83
- // / to
92
+ // / @brief Called when handling StoreScene, and only if the handler supports the given endpoint and cluster.
93
+ // /
94
+ // / The implementation must write the actual scene data to store to serializedBytes as described below.
84
95
85
- // / place the serialized data in serializedBytes as described below.
86
96
87
97
// / @param endpoint[in] Target Endpoint
88
98
// / @param cluster[in] Target Cluster
@@ -92,7 +102,8 @@ class SceneHandler : public IntrusiveListNodeBase<>
92
102
// / @return CHIP_NO_ERROR if successful, CHIP_ERROR value otherwise
93
103
virtual CHIP_ERROR SerializeSave (EndpointId endpoint, ClusterId cluster, MutableByteSpan & serializedBytes) = 0;
94
104
95
- // / @brief From stored scene (e.g. ViewScene), deserialize ExtensionFieldSet into a cluster object
105
+ // / @brief Deserialize an ExtensionFieldSet into a cluster object (e.g. when handling ViewScene).
106
+
96
107
// / @param endpoint[in] Endpoint ID
97
108
// / @param cluster[in] Cluster ID to save
98
109
// / @param serializedBytes[in] ExtensionFieldSet stored in NVM
@@ -103,7 +114,8 @@ class SceneHandler : public IntrusiveListNodeBase<>
103
114
104
115
app::Clusters::Scenes::Structs::ExtensionFieldSet::Type & extensionFieldSet) = 0;
105
116
106
- // / @brief From stored scene (e.g RecallScene), applies EFS values to cluster at transition time
117
+ // / @brief Restore a stored scene for the given cluster instance, over timeMs milliseconds (e.g. when handling RecallScene)
118
+
107
119
// / @param endpoint[in] Endpoint ID
108
120
// / @param cluster[in] Cluster ID
109
121
// / @param serializedBytes[in] ExtensionFieldSet stored in NVM
@@ -141,7 +153,8 @@ class SceneTable
141
153
142
154
bool operator ==(const SceneStorageId & other)
143
155
{
144
- return (this ->mEndpointId == other.mEndpointId && this ->mGroupId == other.mGroupId && this ->mSceneId == other.mSceneId );
156
+ return (mEndpointId == other.mEndpointId && mGroupId == other.mGroupId && mSceneId == other.mSceneId );
157
+
145
158
}
146
159
};
147
160
@@ -162,17 +175,20 @@ class SceneTable
162
175
163
176
SceneData (const CharSpan & sceneName = CharSpan(), SceneTransitionTime time = 0 ) : mSceneTransitionTimeMs (time)
164
177
{
165
- this ->SetName (sceneName);
178
+ SetName (sceneName);
179
+
166
180
}
167
181
SceneData (EFStype fields, const CharSpan & sceneName = CharSpan(), SceneTransitionTime time = 0 ) :
168
182
mSceneTransitionTimeMs (time)
169
183
{
170
- this ->SetName (sceneName);
184
+ SetName (sceneName);
185
+
171
186
mExtensionFieldSets = fields;
172
187
}
173
188
SceneData (const SceneData & other) : mSceneTransitionTimeMs (other.mSceneTransitionTimeMs )
174
189
{
175
- this ->SetName (CharSpan (other.mName , other.mNameLength ));
190
+ SetName (CharSpan (other.mName , other.mNameLength ));
191
+
176
192
mExtensionFieldSets = other.mExtensionFieldSets ;
177
193
}
178
194
~SceneData (){};
@@ -194,7 +210,8 @@ class SceneTable
194
210
195
211
void Clear ()
196
212
{
197
- this ->SetName (CharSpan ());
213
+ SetName (CharSpan ());
214
+
198
215
mSceneTransitionTimeMs = 0 ;
199
216
mExtensionFieldSets .Clear ();
200
217
}
@@ -229,13 +246,15 @@ class SceneTable
229
246
230
247
bool operator ==(const SceneTableEntry & other)
231
248
{
232
- return (this ->mStorageId == other.mStorageId && this ->mStorageData == other.mStorageData );
249
+ return (mStorageId == other.mStorageId && mStorageData == other.mStorageData );
250
+
233
251
}
234
252
235
253
void operator =(const SceneTableEntry & other)
236
254
{
237
- this ->mStorageId = other.mStorageId ;
238
- this ->mStorageData = other.mStorageData ;
255
+ mStorageId = other.mStorageId ;
256
+ mStorageData = other.mStorageData ;
257
+
239
258
}
240
259
};
241
260
@@ -275,12 +294,11 @@ class SceneTable
275
294
virtual SceneEntryIterator * IterateSceneEntries (FabricIndex fabric_index) = 0;
276
295
277
296
// Handlers
278
- virtual bool HandlerListEmpty () { return ( mNumHandlers == 0 ); }
279
- virtual uint8_t GetHandlerNum () { return this -> mNumHandlers ; }
297
+ virtual bool HandlerListEmpty () { return mHandlerList . Empty ( ); }
298
+
280
299
281
300
// SceneHandler * mHandlers[kMaxSceneHandlers] = { nullptr };
282
301
IntrusiveList<SceneHandler> mHandlerList ;
283
- uint8_t mNumHandlers = 0 ;
284
302
};
285
303
286
304
} // namespace scenes
0 commit comments