Skip to content

Commit 50273f2

Browse files
Make use of ZAP's new support for specifying the parent of an endpoint.
Specific changes: * Remove unused FIXED_NETWORKS bit from endpoint_config.h. * Add FIXED_PARENT_ENDPOINTS which lists the parents of each fixed endpoint. * Condition the fixed endpoint initialization code on FIXED_ENDPOINT_COUNT > 0 and remove some Darwin hackery that was needed because it was not thus conditioned. * Add initialization of parentEndpointId for fixed endpoints from FIXED_PARENT_ENDPOINTS. At the moment FIXED_PARENT_ENDPOINTS uses 0 to mean "no parent specified", but I am hoping the ZAP folks will fix things so that we can just have kInvalidEndpointId in there and the code in emberAfEndpointConfigure can become simpler/smaller.
1 parent 28da08f commit 50273f2

File tree

5 files changed

+27
-24
lines changed

5 files changed

+27
-24
lines changed

scripts/tools/zap/tests/outputs/all-clusters-app/app-templates/endpoint_config.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -3069,8 +3069,8 @@ static_assert(ATTRIBUTE_LARGEST <= CHIP_CONFIG_MAX_ATTRIBUTE_STORE_ELEMENT_SIZE,
30693069
0, 1, 2, 3 \
30703070
}
30713071

3072-
// Array of networks supported on each endpoint
3073-
#define FIXED_NETWORKS \
3072+
// Array of parent endpoints for each endpoint
3073+
#define FIXED_PARENT_ENDPOINTS \
30743074
{ \
30753075
0, 0, 0, 0 \
30763076
}

scripts/tools/zap/tests/outputs/lighting-app/app-templates/endpoint_config.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1207,8 +1207,8 @@ static_assert(ATTRIBUTE_LARGEST <= CHIP_CONFIG_MAX_ATTRIBUTE_STORE_ELEMENT_SIZE,
12071207
0, 1 \
12081208
}
12091209

1210-
// Array of networks supported on each endpoint
1211-
#define FIXED_NETWORKS \
1210+
// Array of parent endpoints for each endpoint
1211+
#define FIXED_PARENT_ENDPOINTS \
12121212
{ \
12131213
0, 0 \
12141214
}

src/app/util/attribute-storage.cpp

+21-5
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,13 @@ constexpr const EmberAfCluster generatedClusters[] = GENERATED_CLUSTERS;
130130
#define ZAP_CLUSTER_INDEX(index) (&generatedClusters[index])
131131
#endif
132132

133+
#if FIXED_ENDPOINT_COUNT > 0
133134
constexpr const EmberAfEndpointType generatedEmberAfEndpointTypes[] = GENERATED_ENDPOINT_TYPES;
134135
constexpr const EmberAfDeviceType fixedDeviceTypeList[] = FIXED_DEVICE_TYPES;
135136

136137
// Not const, because these need to mutate.
137138
DataVersion fixedEndpointDataVersions[ZAP_FIXED_ENDPOINT_DATA_VERSION_COUNT];
139+
#endif // FIXED_ENDPOINT_COUNT > 0
138140

139141
AttributeAccessInterface * gAttributeAccessOverrides = nullptr;
140142
AttributeAccessInterfaceCache gAttributeAccessInterfaceCache;
@@ -183,10 +185,15 @@ void emberAfEndpointConfigure()
183185
static_assert(FIXED_ENDPOINT_COUNT <= std::numeric_limits<decltype(ep)>::max(),
184186
"FIXED_ENDPOINT_COUNT must not exceed the size of the endpoint data type");
185187

186-
uint16_t fixedEndpoints[] = FIXED_ENDPOINT_ARRAY;
187-
uint16_t fixedDeviceTypeListLengths[] = FIXED_DEVICE_TYPE_LENGTHS;
188-
uint16_t fixedDeviceTypeListOffsets[] = FIXED_DEVICE_TYPE_OFFSETS;
189-
uint8_t fixedEmberAfEndpointTypes[] = FIXED_ENDPOINT_TYPES;
188+
emberEndpointCount = FIXED_ENDPOINT_COUNT;
189+
190+
#if FIXED_ENDPOINT_COUNT > 0
191+
192+
constexpr uint16_t fixedEndpoints[] = FIXED_ENDPOINT_ARRAY;
193+
constexpr uint16_t fixedDeviceTypeListLengths[] = FIXED_DEVICE_TYPE_LENGTHS;
194+
constexpr uint16_t fixedDeviceTypeListOffsets[] = FIXED_DEVICE_TYPE_OFFSETS;
195+
constexpr uint8_t fixedEmberAfEndpointTypes[] = FIXED_ENDPOINT_TYPES;
196+
constexpr EndpointId fixedParentEndpoints[] = FIXED_PARENT_ENDPOINTS;
190197

191198
#if ZAP_FIXED_ENDPOINT_DATA_VERSION_COUNT > 0
192199
// Initialize our data version storage. If
@@ -201,7 +208,6 @@ void emberAfEndpointConfigure()
201208
}
202209
#endif // ZAP_FIXED_ENDPOINT_DATA_VERSION_COUNT > 0
203210

204-
emberEndpointCount = FIXED_ENDPOINT_COUNT;
205211
DataVersion * currentDataVersions = fixedEndpointDataVersions;
206212
for (ep = 0; ep < FIXED_ENDPOINT_COUNT; ep++)
207213
{
@@ -210,6 +216,14 @@ void emberAfEndpointConfigure()
210216
Span<const EmberAfDeviceType>(&fixedDeviceTypeList[fixedDeviceTypeListOffsets[ep]], fixedDeviceTypeListLengths[ep]);
211217
emAfEndpoints[ep].endpointType = &generatedEmberAfEndpointTypes[fixedEmberAfEndpointTypes[ep]];
212218
emAfEndpoints[ep].dataVersions = currentDataVersions;
219+
if (fixedParentEndpoints[ep] == 0)
220+
{
221+
emAfEndpoints[ep].parentEndpointId = kInvalidEndpointId;
222+
}
223+
else
224+
{
225+
emAfEndpoints[ep].parentEndpointId = fixedParentEndpoints[ep];
226+
}
213227

214228
emAfEndpoints[ep].bitmask.Set(EmberAfEndpointOptions::isEnabled);
215229
emAfEndpoints[ep].bitmask.Set(EmberAfEndpointOptions::isFlatComposition);
@@ -219,6 +233,8 @@ void emberAfEndpointConfigure()
219233
currentDataVersions += emberAfClusterCountByIndex(ep, /* server = */ true);
220234
}
221235

236+
#endif // FIXED_ENDPOINT_COUNT > 0
237+
222238
#if CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT
223239
if (MAX_ENDPOINT_COUNT > FIXED_ENDPOINT_COUNT)
224240
{

src/app/zap-templates/templates/app/endpoint_config.zapt

+2-2
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ static_assert(ATTRIBUTE_LARGEST <= CHIP_CONFIG_MAX_ATTRIBUTE_STORE_ELEMENT_SIZE,
9595
// Array of endpoint types supported on each endpoint
9696
#define FIXED_ENDPOINT_TYPES {{endpoint_fixed_endpoint_type_array}}
9797

98-
// Array of networks supported on each endpoint
99-
#define FIXED_NETWORKS {{endpoint_fixed_network_array}}
98+
// Array of parent endpoints for each endpoint
99+
#define FIXED_PARENT_ENDPOINTS {{endpoint_fixed_parent_id_array}}
100100

101101
{{/endpoint_config}}

src/darwin/Framework/CHIP/zap-generated/endpoint_config.h

-13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)