Skip to content

Commit

Permalink
Added a CHIP config allowing to configure the maximum number of scene…
Browse files Browse the repository at this point in the history
…s per endpoint in flash. This also behaves as a default scene table size in the event the zap config isn't used at build
  • Loading branch information
lpbeliveau-silabs committed Oct 30, 2023
1 parent 268951c commit f329144
Show file tree
Hide file tree
Showing 3 changed files with 21 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 greater than 16");
static constexpr uint16_t kMaxScenesPerFabric = (kMaxScenesPerEndpoint - 1) / 2;

using clusterId = chip::ClusterId;

Expand Down
10 changes: 10 additions & 0 deletions src/lib/core/CHIPConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -1443,6 +1443,16 @@ 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 be greater than 16
* per spec and MUST be increased to allow for configuring a greater scene table size from Zap.
*/
#ifndef CHIP_CONFIG_SCENES_TABLE_SIZE
#define CHIP_CONFIG_MAX_SCENES_TABLE_SIZE 32
#endif

/**
* @def CHIP_CONFIG_TIME_ZONE_LIST_MAX_SIZE
*
Expand Down

0 comments on commit f329144

Please sign in to comment.