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

Make sure to generate events when we clear credentials. #25028

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
26 changes: 20 additions & 6 deletions src/app/clusters/door-lock-server/door-lock-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2899,23 +2899,37 @@ EmberAfStatus DoorLockServer::clearCredentials(chip::EndpointId endpointId, chip
return EMBER_ZCL_STATUS_FAILURE;
}

EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS;
bool clearedCredential = false;
for (uint16_t i = 1; i < maxNumberOfCredentials; ++i)
{
auto status = clearCredential(endpointId, modifier, sourceNodeId, credentialType, i, false);
if (EMBER_ZCL_STATUS_SUCCESS != status)
EmberAfStatus clearStatus = clearCredential(endpointId, modifier, sourceNodeId, credentialType, i, false);
bzbarsky-apple marked this conversation as resolved.
Show resolved Hide resolved
if (EMBER_ZCL_STATUS_SUCCESS != clearStatus)
{
ChipLogError(Zcl,
"[clearCredentials] Unable to clear the credential - internal error "
"[endpointId=%d,credentialType=%u,credentialIndex=%d,status=%d]",
endpointId, to_underlying(credentialType), i, status);
return status;
if (status == EMBER_ZCL_STATUS_SUCCESS)
{
status = clearStatus;
}
}
else
{
clearedCredential = true;
}
}

sendRemoteLockUserChange(endpointId, credentialTypeToLockDataType(credentialType), DataOperationTypeEnum::kClear, sourceNodeId,
modifier, 0xFFFE, 0xFFFE);
// Generate the event if we cleared any credentials, even if we then had errors
// clearing other ones, so we don't have credentials silently disappearing.
if (clearedCredential)
{
sendRemoteLockUserChange(endpointId, credentialTypeToLockDataType(credentialType), DataOperationTypeEnum::kClear,
sourceNodeId, modifier, 0xFFFE, 0xFFFE);
}

return EMBER_ZCL_STATUS_SUCCESS;
return status;
}

bool DoorLockServer::clearFabricFromCredentials(chip::EndpointId endpointId, CredentialTypeEnum credentialType,
Expand Down