Skip to content

Commit d895bb7

Browse files
Fix Door Lock cluster to not repond DUPLICATE when there is no duplication of credentials. (project-chip#39279)
Spec issue tracking the spec not being clear: CHIP-Specifications/connectedhomeip-spec#11707 Cherry-pick of project-chip#39254
1 parent e677ebd commit d895bb7

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

src/app/clusters/door-lock-server/door-lock-server.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,17 @@ void DoorLockServer::setCredentialCommandHandler(
710710
// appclusters, 5.2.4.41.1: we should return DUPLICATE in the response if we're trying to create duplicated credential entry
711711
for (uint16_t i = 1; CredentialTypeEnum::kProgrammingPIN != credentialType && (i <= maxNumberOfCredentials); ++i)
712712
{
713+
// Ignore the slot we are trying to set, because setting a credential to
714+
// the same value as it already has should be just fine.
715+
//
716+
// This is not clearly defined in the spec;
717+
// https://github.com/CHIP-Specifications/connectedhomeip-spec/issues/11707
718+
// tracks that.
719+
if (i == credentialIndex)
720+
{
721+
continue;
722+
}
723+
713724
EmberAfPluginDoorLockCredentialInfo currentCredential;
714725
if (!emberAfPluginDoorLockGetCredential(commandPath.mEndpointId, i, credentialType, currentCredential))
715726
{

src/app/tests/suites/DL_UsersAndCredentials.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,6 +1117,32 @@ tests:
11171117
- name: "NextCredentialIndex"
11181118
value: null
11191119

1120+
- label: "Verify setting credential to same value is allowed"
1121+
command: "SetCredential"
1122+
timedInteractionTimeoutMs: 10000
1123+
arguments:
1124+
values:
1125+
- name: "OperationType"
1126+
value: 2 # Modify
1127+
- name: "Credential"
1128+
value: { CredentialType: 1, CredentialIndex: 1 }
1129+
- name: "CredentialData"
1130+
value: "000000"
1131+
- name: "UserIndex"
1132+
value: 1
1133+
- name: "UserStatus"
1134+
value: null
1135+
- name: "UserType"
1136+
value: null
1137+
response:
1138+
values:
1139+
- name: "Status"
1140+
value: 0x00
1141+
- name: "UserIndex"
1142+
value: null
1143+
- name: "NextCredentialIndex"
1144+
value: 2
1145+
11201146
- label: "Create new PIN credential and user with index 0 fails"
11211147
command: "SetCredential"
11221148
timedInteractionTimeoutMs: 10000

0 commit comments

Comments
 (0)