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

[nrf fromtree] app: clusters: Add handling a local lock operation error #332

Merged
Merged
Show file tree
Hide file tree
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
12 changes: 12 additions & 0 deletions src/app/clusters/door-lock-server/door-lock-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,18 @@ bool DoorLockServer::SetPrivacyModeButton(chip::EndpointId endpointId, bool isEn
return SetAttribute(endpointId, Attributes::EnablePrivacyModeButton::Id, Attributes::EnablePrivacyModeButton::Set, isEnabled);
}

void DoorLockServer::HandleLocalLockOperationError(chip::EndpointId endpointId, LockOperationTypeEnum opType,
OperationSourceEnum opSource, Nullable<uint16_t> userId)
{
SendLockOperationEvent(endpointId, opType, opSource, OperationErrorEnum::kInvalidCredential, userId,
markaj-nordic marked this conversation as resolved.
Show resolved Hide resolved
Nullable<chip::FabricIndex>(), Nullable<chip::NodeId>(), Nullable<List<const LockOpCredentials>>(),
false);

HandleWrongCodeEntry(endpointId);

ChipLogProgress(Zcl, "Handling a local Lock Operation Error: [endpoint=%d, user=%d]", endpointId, userId.Value());
}

bool DoorLockServer::HandleWrongCodeEntry(chip::EndpointId endpointId)
{
auto endpointContext = getContext(endpointId);
Expand Down
14 changes: 14 additions & 0 deletions src/app/clusters/door-lock-server/door-lock-server.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,20 @@ class DoorLockServer
*/
void ResetWrongCodeEntryAttempts(chip::EndpointId endpointId);

/**
* @brief Handles a local lock operation error. This method allows handling a wrong attempt of providing
* user credential entry that has been provided locally by the user. The method will emit the LockOperationEvent
* to inform the controller that a local wrong attempt occurred, and also call HandleWrongEntry method to
* increment wrong entry counter.
*
* @param endpointId
* @param opType Operation source to be registered in the LockOperationEvent.
* @param opSource source of the operation to be registered in the LockOperationEvent.
* @param userId Optional user id to be registered in the LockOperationEvent
*/
void HandleLocalLockOperationError(chip::EndpointId endpointId, LockOperationTypeEnum opType, OperationSourceEnum opSource,
Nullable<uint16_t> userId);

private:
chip::FabricIndex getFabricIndex(const chip::app::CommandHandler * commandObj);
chip::NodeId getNodeId(const chip::app::CommandHandler * commandObj);
Expand Down