Skip to content

Commit

Permalink
[Scenes] CHIP config table size (#30095)
Browse files Browse the repository at this point in the history
* Added a CHIP config allowing to configure the maximum number of scenes per endpoint in flash. This also behaves as a default scene table size in the event the zap config isn't used at build

* Aligned assert text with actual assert check

* Update src/lib/core/CHIPConfig.h

Co-authored-by: Tennessee Carmel-Veilleux <[email protected]>

* Decreased CHIP CONFIG Max table size and added a value for test

---------

Co-authored-by: Tennessee Carmel-Veilleux <[email protected]>
  • Loading branch information
2 people authored and pull[bot] committed Mar 28, 2024
1 parent 0fdc407 commit 4307872
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/app/clusters/scenes-server/SceneTableImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ struct FabricSceneData : public PersistentData<kPersistentFabricBufferMax>
uint8_t scene_count = 0;
uint16_t max_scenes_per_fabric;
uint16_t max_scenes_per_endpoint;
SceneStorageId scene_map[kMaxScenesPerFabric];
SceneStorageId scene_map[CHIP_CONFIG_MAX_SCENES_TABLE_SIZE];

FabricSceneData(EndpointId endpoint = kInvalidEndpointId, FabricIndex fabric = kUndefinedFabricIndex,
uint16_t maxScenesPerFabric = kMaxScenesPerFabric, uint16_t maxScenesPerEndpoint = kMaxScenesPerEndpoint) :
Expand Down
11 changes: 10 additions & 1 deletion src/app/clusters/scenes-server/SceneTableImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,17 @@
namespace chip {
namespace scenes {

static constexpr uint16_t kMaxScenesPerFabric = (MATTER_SCENES_TABLE_SIZE - 1) / 2;
#ifdef MATTER_SCENES_TABLE_SIZE
static constexpr uint16_t kMaxScenesPerEndpoint = MATTER_SCENES_TABLE_SIZE;
#else
static constexpr uint16_t kMaxScenesPerEndpoint = CHIP_CONFIG_MAX_SCENES_TABLE_SIZE;
#endif

static_assert(kMaxScenesPerEndpoint <= CHIP_CONFIG_MAX_SCENES_TABLE_SIZE,
"CHIP_CONFIG_MAX_SCENES_TABLE_SIZE is smaller than the zap configuration, please increase "
"CHIP_CONFIG_MAX_SCENES_TABLE_SIZE in CHIPConfig.h if you really need more scenes");
static_assert(kMaxScenesPerEndpoint >= 16, "Per spec, kMaxScenesPerEndpoint must be at least 16");
static constexpr uint16_t kMaxScenesPerFabric = (kMaxScenesPerEndpoint - 1) / 2;

using clusterId = chip::ClusterId;

Expand Down
14 changes: 14 additions & 0 deletions src/lib/core/CHIPConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -1443,6 +1443,20 @@ extern const char CHIP_NON_PRODUCTION_MARKER[];
#define CHIP_CONFIG_MAX_SCENES_CONCURRENT_ITERATORS 2
#endif

/**
* @ def CHIP_CONFIG_MAX_SCENES_TABLE_SIZE
*
* @brief This defines how many scenes a single endpoint is allowed to allocate in flash memory. This value MUST at least 16
* per spec and MUST be increased to allow for configuring a greater scene table size from Zap.
*/
#ifndef CHIP_CONFIG_MAX_SCENES_TABLE_SIZE
#if CHIP_CONFIG_TEST
#define CHIP_CONFIG_MAX_SCENES_TABLE_SIZE 24
#else
#define CHIP_CONFIG_MAX_SCENES_TABLE_SIZE 16
#endif // CHIP_CONFIG_TEST
#endif // CHIP_CONFIG_MAX_SCENES_TABLE_SIZE

/**
* @def CHIP_CONFIG_TIME_ZONE_LIST_MAX_SIZE
*
Expand Down

0 comments on commit 4307872

Please sign in to comment.