diff --git a/scripts/tools/zap/tests/outputs/all-clusters-app/app-templates/endpoint_config.h b/scripts/tools/zap/tests/outputs/all-clusters-app/app-templates/endpoint_config.h index 8c1c6c7564cc02..09b17447be9e52 100644 --- a/scripts/tools/zap/tests/outputs/all-clusters-app/app-templates/endpoint_config.h +++ b/scripts/tools/zap/tests/outputs/all-clusters-app/app-templates/endpoint_config.h @@ -3069,8 +3069,8 @@ static_assert(ATTRIBUTE_LARGEST <= CHIP_CONFIG_MAX_ATTRIBUTE_STORE_ELEMENT_SIZE, 0, 1, 2, 3 \ } -// Array of networks supported on each endpoint -#define FIXED_NETWORKS \ +// Array of parent endpoints for each endpoint +#define FIXED_PARENT_ENDPOINTS \ { \ 0, 0, 0, 0 \ } diff --git a/scripts/tools/zap/tests/outputs/lighting-app/app-templates/endpoint_config.h b/scripts/tools/zap/tests/outputs/lighting-app/app-templates/endpoint_config.h index 4e21190fdd22bd..0e6ba62431b71e 100644 --- a/scripts/tools/zap/tests/outputs/lighting-app/app-templates/endpoint_config.h +++ b/scripts/tools/zap/tests/outputs/lighting-app/app-templates/endpoint_config.h @@ -1207,8 +1207,8 @@ static_assert(ATTRIBUTE_LARGEST <= CHIP_CONFIG_MAX_ATTRIBUTE_STORE_ELEMENT_SIZE, 0, 1 \ } -// Array of networks supported on each endpoint -#define FIXED_NETWORKS \ +// Array of parent endpoints for each endpoint +#define FIXED_PARENT_ENDPOINTS \ { \ 0, 0 \ } diff --git a/src/app/util/attribute-storage.cpp b/src/app/util/attribute-storage.cpp index 431f3091a22977..3bce63e6da254c 100644 --- a/src/app/util/attribute-storage.cpp +++ b/src/app/util/attribute-storage.cpp @@ -130,11 +130,13 @@ constexpr const EmberAfCluster generatedClusters[] = GENERATED_CLUSTERS; #define ZAP_CLUSTER_INDEX(index) (&generatedClusters[index]) #endif +#if FIXED_ENDPOINT_COUNT > 0 constexpr const EmberAfEndpointType generatedEmberAfEndpointTypes[] = GENERATED_ENDPOINT_TYPES; constexpr const EmberAfDeviceType fixedDeviceTypeList[] = FIXED_DEVICE_TYPES; // Not const, because these need to mutate. DataVersion fixedEndpointDataVersions[ZAP_FIXED_ENDPOINT_DATA_VERSION_COUNT]; +#endif // FIXED_ENDPOINT_COUNT > 0 AttributeAccessInterface * gAttributeAccessOverrides = nullptr; AttributeAccessInterfaceCache gAttributeAccessInterfaceCache; @@ -183,10 +185,15 @@ void emberAfEndpointConfigure() static_assert(FIXED_ENDPOINT_COUNT <= std::numeric_limits::max(), "FIXED_ENDPOINT_COUNT must not exceed the size of the endpoint data type"); - uint16_t fixedEndpoints[] = FIXED_ENDPOINT_ARRAY; - uint16_t fixedDeviceTypeListLengths[] = FIXED_DEVICE_TYPE_LENGTHS; - uint16_t fixedDeviceTypeListOffsets[] = FIXED_DEVICE_TYPE_OFFSETS; - uint8_t fixedEmberAfEndpointTypes[] = FIXED_ENDPOINT_TYPES; + emberEndpointCount = FIXED_ENDPOINT_COUNT; + +#if FIXED_ENDPOINT_COUNT > 0 + + constexpr uint16_t fixedEndpoints[] = FIXED_ENDPOINT_ARRAY; + constexpr uint16_t fixedDeviceTypeListLengths[] = FIXED_DEVICE_TYPE_LENGTHS; + constexpr uint16_t fixedDeviceTypeListOffsets[] = FIXED_DEVICE_TYPE_OFFSETS; + constexpr uint8_t fixedEmberAfEndpointTypes[] = FIXED_ENDPOINT_TYPES; + constexpr EndpointId fixedParentEndpoints[] = FIXED_PARENT_ENDPOINTS; #if ZAP_FIXED_ENDPOINT_DATA_VERSION_COUNT > 0 // Initialize our data version storage. If @@ -201,7 +208,6 @@ void emberAfEndpointConfigure() } #endif // ZAP_FIXED_ENDPOINT_DATA_VERSION_COUNT > 0 - emberEndpointCount = FIXED_ENDPOINT_COUNT; DataVersion * currentDataVersions = fixedEndpointDataVersions; for (ep = 0; ep < FIXED_ENDPOINT_COUNT; ep++) { @@ -210,6 +216,14 @@ void emberAfEndpointConfigure() Span(&fixedDeviceTypeList[fixedDeviceTypeListOffsets[ep]], fixedDeviceTypeListLengths[ep]); emAfEndpoints[ep].endpointType = &generatedEmberAfEndpointTypes[fixedEmberAfEndpointTypes[ep]]; emAfEndpoints[ep].dataVersions = currentDataVersions; + if (fixedParentEndpoints[ep] == 0) + { + emAfEndpoints[ep].parentEndpointId = kInvalidEndpointId; + } + else + { + emAfEndpoints[ep].parentEndpointId = fixedParentEndpoints[ep]; + } emAfEndpoints[ep].bitmask.Set(EmberAfEndpointOptions::isEnabled); emAfEndpoints[ep].bitmask.Set(EmberAfEndpointOptions::isFlatComposition); @@ -219,6 +233,8 @@ void emberAfEndpointConfigure() currentDataVersions += emberAfClusterCountByIndex(ep, /* server = */ true); } +#endif // FIXED_ENDPOINT_COUNT > 0 + #if CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT if (MAX_ENDPOINT_COUNT > FIXED_ENDPOINT_COUNT) { diff --git a/src/app/zap-templates/templates/app/endpoint_config.zapt b/src/app/zap-templates/templates/app/endpoint_config.zapt index f67c779089a1f2..43ef32436d3aa3 100644 --- a/src/app/zap-templates/templates/app/endpoint_config.zapt +++ b/src/app/zap-templates/templates/app/endpoint_config.zapt @@ -95,7 +95,7 @@ static_assert(ATTRIBUTE_LARGEST <= CHIP_CONFIG_MAX_ATTRIBUTE_STORE_ELEMENT_SIZE, // Array of endpoint types supported on each endpoint #define FIXED_ENDPOINT_TYPES {{endpoint_fixed_endpoint_type_array}} -// Array of networks supported on each endpoint -#define FIXED_NETWORKS {{endpoint_fixed_network_array}} +// Array of parent endpoints for each endpoint +#define FIXED_PARENT_ENDPOINTS {{endpoint_fixed_parent_id_array}} {{/endpoint_config}} diff --git a/src/darwin/Framework/CHIP/zap-generated/endpoint_config.h b/src/darwin/Framework/CHIP/zap-generated/endpoint_config.h index 27cfbdb778d5f5..5f7965897a6570 100644 --- a/src/darwin/Framework/CHIP/zap-generated/endpoint_config.h +++ b/src/darwin/Framework/CHIP/zap-generated/endpoint_config.h @@ -36,16 +36,3 @@ #define GENERATED_ATTRIBUTES {} -#define GENERATED_ENDPOINT_TYPES {} - -#define FIXED_DEVICE_TYPES {} - -#define ZAP_FIXED_ENDPOINT_DATA_VERSION_COUNT 0 - -#define FIXED_ENDPOINT_ARRAY {} - -#define FIXED_DEVICE_TYPE_LENGTHS {} - -#define FIXED_DEVICE_TYPE_OFFSETS {} - -#define FIXED_ENDPOINT_TYPES {}