Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting the endpoint_id of all the uninitialized endpoints to invalid instead of 0 #13814

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions src/app/util/attribute-storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ void emberAfEndpointConfigure(void)
static_assert(EMBER_AF_ENDPOINT_DISABLED == 0, "We are creating enabled dynamic endpoints!");
memset(&emAfEndpoints[FIXED_ENDPOINT_COUNT], 0,
sizeof(EmberAfDefinedEndpoint) * (MAX_ENDPOINT_COUNT - FIXED_ENDPOINT_COUNT));
for (ep = FIXED_ENDPOINT_COUNT; ep < MAX_ENDPOINT_COUNT; ep++)
{
emAfEndpoints[ep].endpoint = kInvalidEndpointId;
}
}
#endif
}
Expand Down Expand Up @@ -180,11 +184,15 @@ EmberAfStatus emberAfSetDynamicEndpoint(uint16_t index, EndpointId id, EmberAfEn
{
return EMBER_ZCL_STATUS_INSUFFICIENT_SPACE;
}
if (id == kInvalidEndpointId)
{
return EMBER_ZCL_STATUS_CONSTRAINT_ERROR;
}

index = static_cast<uint16_t>(realIndex);
for (uint16_t i = FIXED_ENDPOINT_COUNT; i < MAX_ENDPOINT_COUNT; i++)
{
if (emAfEndpoints[i].endpoint == id && emAfEndpoints[i].endpointType != NULL)
if (emAfEndpoints[i].endpoint == id)
{
return EMBER_ZCL_STATUS_DUPLICATE_EXISTS;
}
Expand Down Expand Up @@ -213,15 +221,13 @@ EndpointId emberAfClearDynamicEndpoint(uint16_t index)

index = static_cast<uint8_t>(index + FIXED_ENDPOINT_COUNT);

if ((index < MAX_ENDPOINT_COUNT) && (emAfEndpoints[index].endpoint != 0) && (emberAfEndpointIndexIsEnabled(index)))
if ((index < MAX_ENDPOINT_COUNT) && (emAfEndpoints[index].endpoint != kInvalidEndpointId) &&
(emberAfEndpointIndexIsEnabled(index)))
{
ep = emAfEndpoints[index].endpoint;
if (ep)
{
emberAfSetDeviceEnabled(ep, false);
emberAfEndpointEnableDisable(ep, false);
emAfEndpoints[index].endpoint = 0;
}
emberAfSetDeviceEnabled(ep, false);
emberAfEndpointEnableDisable(ep, false);
emAfEndpoints[index].endpoint = kInvalidEndpointId;
}

return ep;
Expand Down