Skip to content

Commit c1b2e0e

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 c1b2e0e

File tree

3 files changed

+21
-15
lines changed

3 files changed

+21
-15
lines changed

src/app/util/attribute-storage.cpp

+19-5
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,15 @@ void emberAfEndpointConfigure()
183183
static_assert(FIXED_ENDPOINT_COUNT <= std::numeric_limits<decltype(ep)>::max(),
184184
"FIXED_ENDPOINT_COUNT must not exceed the size of the endpoint data type");
185185

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;
186+
emberEndpointCount = FIXED_ENDPOINT_COUNT;
187+
188+
#if FIXED_ENDPOINT_COUNT > 0
189+
190+
constexpr uint16_t fixedEndpoints[] = FIXED_ENDPOINT_ARRAY;
191+
constexpr uint16_t fixedDeviceTypeListLengths[] = FIXED_DEVICE_TYPE_LENGTHS;
192+
constexpr uint16_t fixedDeviceTypeListOffsets[] = FIXED_DEVICE_TYPE_OFFSETS;
193+
constexpr uint8_t fixedEmberAfEndpointTypes[] = FIXED_ENDPOINT_TYPES;
194+
constexpr EndpointId fixedParentEndpoints[] = FIXED_PARENT_ENDPOINTS;
190195

191196
#if ZAP_FIXED_ENDPOINT_DATA_VERSION_COUNT > 0
192197
// Initialize our data version storage. If
@@ -201,7 +206,6 @@ void emberAfEndpointConfigure()
201206
}
202207
#endif // ZAP_FIXED_ENDPOINT_DATA_VERSION_COUNT > 0
203208

204-
emberEndpointCount = FIXED_ENDPOINT_COUNT;
205209
DataVersion * currentDataVersions = fixedEndpointDataVersions;
206210
for (ep = 0; ep < FIXED_ENDPOINT_COUNT; ep++)
207211
{
@@ -210,6 +214,14 @@ void emberAfEndpointConfigure()
210214
Span<const EmberAfDeviceType>(&fixedDeviceTypeList[fixedDeviceTypeListOffsets[ep]], fixedDeviceTypeListLengths[ep]);
211215
emAfEndpoints[ep].endpointType = &generatedEmberAfEndpointTypes[fixedEmberAfEndpointTypes[ep]];
212216
emAfEndpoints[ep].dataVersions = currentDataVersions;
217+
if (fixedParentEndpoints[ep] == 0)
218+
{
219+
emAfEndpoints[ep].parentEndpointId = kInvalidEndpointId;
220+
}
221+
else
222+
{
223+
emAfEndpoints[ep].parentEndpointId = fixedParentEndpoints[ep];
224+
}
213225

214226
emAfEndpoints[ep].bitmask.Set(EmberAfEndpointOptions::isEnabled);
215227
emAfEndpoints[ep].bitmask.Set(EmberAfEndpointOptions::isFlatComposition);
@@ -219,6 +231,8 @@ void emberAfEndpointConfigure()
219231
currentDataVersions += emberAfClusterCountByIndex(ep, /* server = */ true);
220232
}
221233

234+
#endif // FIXED_ENDPOINT_COUNT > 0
235+
222236
#if CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT
223237
if (MAX_ENDPOINT_COUNT > FIXED_ENDPOINT_COUNT)
224238
{

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

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

0 commit comments

Comments
 (0)