Skip to content

Commit

Permalink
[project-chip#19316] Don't require PIN for locking/unlocking the door…
Browse files Browse the repository at this point in the history
… when not required
  • Loading branch information
Morozov-5F committed Jun 8, 2022
1 parent 5362125 commit 6b00742
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 6 deletions.
17 changes: 11 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 @@ -3143,13 +3143,18 @@ bool DoorLockServer::HandleRemoteLockOperation(chip::app::CommandHandler * comma
}
else
{
// appclusters.pdf 5.3.4.1:
// If the RequirePINforRemoteOperation attribute is True then PINCode field SHALL be provided and the door lock SHALL NOT
// grant access if it is not provided.
bool requirePin = false;
VerifyOrExit(GetAttribute(endpoint, Attributes::RequirePINforRemoteOperation::Id,
Attributes::RequirePINforRemoteOperation::Get, requirePin),
/* credentialsOk is false here */);

// appclusters.pdf 5.3.4.1:
// If the RequirePINForRemoteOperation attribute is True then PINCode field SHALL be provided and the door lock SHALL NOT
// grant access if it is not provided. This attribute exists when COTA and PIN features are both enabled. Otherwise we
// assume PIN to be OK.
if (SupportsCredentialsOTA(endpoint) && SupportsPIN(endpoint))
{
VerifyOrExit(GetAttribute(endpoint, Attributes::RequirePINforRemoteOperation::Id,
Attributes::RequirePINforRemoteOperation::Get, requirePin),
/* credentialsOk is false here */);
}
credentialsOk = !requirePin;
}

Expand Down
5 changes: 5 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 @@ -168,6 +168,11 @@ class DoorLockServer

inline bool SupportsSchedules(chip::EndpointId endpointId) { return HasFeature(endpointId, DoorLockFeature::kAccessSchedules); }

inline bool SupportsCredentialsOTA(chip::EndpointId endpointId)
{
return HasFeature(endpointId, DoorLockFeature::kCredentialsOTA);
}

inline bool SupportsUSR(chip::EndpointId endpointId)
{
// appclusters, 5.2.2: USR feature has conformance [PIN | RID | FGP | FACE]
Expand Down
20 changes: 20 additions & 0 deletions src/app/tests/suites/DL_LockUnlock.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,26 @@ tests:
- name: "nodeId"
value: nodeId

- label: "Try to unlock the door without PIN"
command: "UnlockDoor"
timedInteractionTimeoutMs: 10000

- label: "Verify that lock state attribute value is set to Unlocked"
command: "readAttribute"
attribute: "LockState"
response:
value: 2

- label: "Try to unlock the door without a PIN"
command: "LockDoor"
timedInteractionTimeoutMs: 10000

- label: "Verify that lock state attribute value is set to Locked"
command: "readAttribute"
attribute: "LockState"
response:
value: 1

- label: "Create new PIN credential and lock/unlock user"
command: "SetCredential"
timedInteractionTimeoutMs: 10000
Expand Down

0 comments on commit 6b00742

Please sign in to comment.