Skip to content

Commit 514e2c9

Browse files
[Scenes] Scene Bytes Size Config (project-chip#30628)
* Create a config to allow increasing the SceneTableImpl's scene buffer size in the event the number of clusters per scene would be increased * Added detail about scene size calculation
1 parent d20a10a commit 514e2c9

File tree

2 files changed

+57
-1
lines changed

2 files changed

+57
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ struct EndpointSceneCount : public PersistentData<kPersistentBufferSceneCountByt
103103
// when using the OnOff, Level Control and Color Control as well as the maximal name length of 16 bytes. Putting 256 gives some
104104
// slack in case different clusters are used. Value obtained by using writer.GetLengthWritten at the end of the SceneTableData
105105
// Serialize method.
106-
static constexpr size_t kPersistentSceneBufferMax = 256;
106+
static constexpr size_t kPersistentSceneBufferMax = CHIP_CONFIG_SCENES_MAX_SERIALIZED_SCENE_SIZE_BYTES;
107107

108108
struct SceneTableData : public SceneTableEntry, PersistentData<kPersistentSceneBufferMax>
109109
{

src/lib/core/CHIPConfig.h

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1432,6 +1432,62 @@ extern const char CHIP_NON_PRODUCTION_MARKER[];
14321432
#define CHIP_CONFIG_SCENES_MAX_EXTENSION_FIELDSET_SIZE_PER_CLUSTER 128
14331433
#endif
14341434

1435+
/**
1436+
* @brief The maximum number bytes taken by a scene. This needs to be increased if the number of clusters per scene is increased.
1437+
* @note The default number (256) is based on the assumption that the maximum number of clusters per scene is 3 and that those
1438+
* clusers are onOff, level control and color control cluster.
1439+
* @warning Changing this value will not only affect the RAM usage of a scene but also the size of the scene table in the flash.
1440+
* A scene's size can be calculated based on the following structure:
1441+
* Scene TLV (struct)
1442+
* {
1443+
* 2 bytes GroupID,
1444+
* 1 byte SceneID,
1445+
* 0 - 16 bytes SceneName,
1446+
* 4 bytes Transition time in miliseconds,
1447+
*
1448+
* Extension field sets TLV (array)
1449+
* [
1450+
* EFS TLV (struct)
1451+
* {
1452+
* 4 bytes for the cluster ID,
1453+
* Attribute Value List TLV (array)
1454+
* [
1455+
* AttributeValue Pair TLV (struct)
1456+
* {
1457+
* Attribute ID
1458+
* 4 bytes attributeID,
1459+
* AttributeValue
1460+
* 1 - 8 bytes AttributeValue,
1461+
* },
1462+
* .
1463+
* .
1464+
* .
1465+
*
1466+
* ],
1467+
*
1468+
* },
1469+
* .
1470+
* .
1471+
* .
1472+
* ],
1473+
* }
1474+
*
1475+
* Including all the TLV fields, the following values can help estimate the needed size for a scenes given a number of clusters:
1476+
* Empty EFS Scene Max name size: 33bytes
1477+
* Scene Max name size + OnOff : 51 bytes
1478+
* Scene Max name size + LevelControl : 60 bytes
1479+
* Scene Max name size + ColorControl : 126 bytes
1480+
* Scene Max name size + OnOff + LevelControl + ColoControl : 171 bytes
1481+
*
1482+
* Cluster Sizes:
1483+
* OnOff Cluster Max Size: 18 bytes
1484+
* LevelControl Cluster Max Size: 27 bytes
1485+
* Color Control Cluster Max Size: 93 bytes
1486+
* */
1487+
#ifndef CHIP_CONFIG_SCENES_MAX_SERIALIZED_SCENE_SIZE_BYTES
1488+
#define CHIP_CONFIG_SCENES_MAX_SERIALIZED_SCENE_SIZE_BYTES 256
1489+
#endif
1490+
14351491
/**
14361492
* @def CHIP_CONFIG_MAX_SCENES_CONCURRENT_ITERATORS
14371493
*

0 commit comments

Comments
 (0)