@@ -106,12 +106,10 @@ bool LockManager::IsValidUserIndex(uint16_t userIndex)
106
106
107
107
bool LockManager::IsValidCredentialIndex (uint16_t credentialIndex, DlCredentialType type)
108
108
{
109
- // appclusters, 5.2.6.3.1: 0 is allowed index for Programming PIN credential only
110
109
if (DlCredentialType::kProgrammingPIN == type)
111
110
{
112
- return (0 == credentialIndex);
111
+ return (0 == credentialIndex); // 0 is required index for Programming PIN
113
112
}
114
-
115
113
return (credentialIndex < kMaxCredentialsPerUser );
116
114
}
117
115
@@ -406,19 +404,19 @@ bool LockManager::GetCredential(chip::EndpointId endpointId, uint16_t credential
406
404
EmberAfPluginDoorLockCredentialInfo & credential)
407
405
{
408
406
409
- VerifyOrReturnValue (IsValidCredentialIndex (--credentialIndex, credentialType), false ); // indices are one-indexed
407
+ if (DlCredentialType::kProgrammingPIN == credentialType)
408
+ {
409
+ VerifyOrReturnValue (IsValidCredentialIndex (credentialIndex, credentialType),
410
+ false ); // programming pin index is only index allowed to contain 0
411
+ }
412
+ else
413
+ {
414
+ VerifyOrReturnValue (IsValidCredentialIndex (--credentialIndex, credentialType), false ); // otherwise, indices are one-indexed
415
+ }
410
416
411
417
ChipLogProgress (Zcl, " Lock App: LockManager::GetCredential [credentialType=%u], credentialIndex=%d" ,
412
418
to_underlying (credentialType), credentialIndex);
413
419
414
- if (credentialType == DlCredentialType::kProgrammingPIN )
415
- {
416
- ChipLogError (Zcl, " Programming user not supported [credentialType=%u], credentialIndex=%d" , to_underlying (credentialType),
417
- credentialIndex);
418
-
419
- return true ;
420
- }
421
-
422
420
const auto & credentialInStorage = mLockCredentials [credentialIndex];
423
421
424
422
credential.status = credentialInStorage.status ;
@@ -449,7 +447,15 @@ bool LockManager::SetCredential(chip::EndpointId endpointId, uint16_t credential
449
447
const chip::ByteSpan & credentialData)
450
448
{
451
449
452
- VerifyOrReturnValue (IsValidCredentialIndex (--credentialIndex, credentialType), false ); // indices are one-indexed
450
+ if (DlCredentialType::kProgrammingPIN == credentialType)
451
+ {
452
+ VerifyOrReturnValue (IsValidCredentialIndex (credentialIndex, credentialType),
453
+ false ); // programming pin index is only index allowed to contain 0
454
+ }
455
+ else
456
+ {
457
+ VerifyOrReturnValue (IsValidCredentialIndex (--credentialIndex, credentialType), false ); // otherwise, indices are one-indexed
458
+ }
453
459
454
460
ChipLogProgress (Zcl,
455
461
" Door Lock App: LockManager::SetCredential "
0 commit comments