Skip to content

Commit

Permalink
Add handling a local lock operation error to door-lock-server (#29857)
Browse files Browse the repository at this point in the history
The current implementation of the door-lock server supports emitting
the LockOperationEvent only if the credential has been provided remotely.
In case we use a custom handling lock credential in the application
code the event is emitted only on the correct credential, but we also
need a mechanism that allows the door lock server to handle a lock
operation error when the wrong credential has been provided.

Added handling local lock operation error to emit LockOperationEvent
and call HandleWrongCodeEntry.
  • Loading branch information
ArekBalysNordic authored and pull[bot] committed Nov 17, 2023
1 parent d4631c9 commit 5247785
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
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 @@ -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<uint16_t> userId)
{
SendLockOperationEvent(endpointId, opType, opSource, OperationErrorEnum::kInvalidCredential, userId,
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 @@ -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<uint16_t> userId);

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

0 comments on commit 5247785

Please sign in to comment.