diff --git a/src/app/clusters/scenes-server/SceneTableImpl.cpp b/src/app/clusters/scenes-server/SceneTableImpl.cpp index f1900416c4499b..7f5870f0ecf2b3 100644 --- a/src/app/clusters/scenes-server/SceneTableImpl.cpp +++ b/src/app/clusters/scenes-server/SceneTableImpl.cpp @@ -284,7 +284,7 @@ struct FabricSceneData : public PersistentData 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) : diff --git a/src/app/clusters/scenes-server/SceneTableImpl.h b/src/app/clusters/scenes-server/SceneTableImpl.h index 60a378f43c3ce8..9f659fab068f50 100644 --- a/src/app/clusters/scenes-server/SceneTableImpl.h +++ b/src/app/clusters/scenes-server/SceneTableImpl.h @@ -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; diff --git a/src/lib/core/CHIPConfig.h b/src/lib/core/CHIPConfig.h index 60efb7118bb72f..2024f9dab62591 100644 --- a/src/lib/core/CHIPConfig.h +++ b/src/lib/core/CHIPConfig.h @@ -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 *