diff --git a/src/app/clusters/door-lock-server/door-lock-server.cpp b/src/app/clusters/door-lock-server/door-lock-server.cpp index 01edd3f1b60253..7552841edfb5e6 100644 --- a/src/app/clusters/door-lock-server/door-lock-server.cpp +++ b/src/app/clusters/door-lock-server/door-lock-server.cpp @@ -202,6 +202,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 userId) +{ + SendLockOperationEvent(endpointId, opType, opSource, OperationErrorEnum::kInvalidCredential, userId, + Nullable(), Nullable(), Nullable>(), + 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); diff --git a/src/app/clusters/door-lock-server/door-lock-server.h b/src/app/clusters/door-lock-server/door-lock-server.h index 70988c17786964..a8007f211641a4 100644 --- a/src/app/clusters/door-lock-server/door-lock-server.h +++ b/src/app/clusters/door-lock-server/door-lock-server.h @@ -228,6 +228,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 userId); + private: chip::FabricIndex getFabricIndex(const chip::app::CommandHandler * commandObj); chip::NodeId getNodeId(const chip::app::CommandHandler * commandObj);