18
18
*/
19
19
20
20
#include " LockManager.h"
21
-
22
21
#include " AppConfig.h"
23
22
#include " AppTask.h"
24
23
#include < app-common/zap-generated/attributes/Accessors.h>
@@ -377,7 +376,7 @@ bool LockManager::GetUser(chip::EndpointId endpointId, uint16_t userIndex, Ember
377
376
uint16_t credentialSize = static_cast <uint16_t >(sizeof (CredentialStruct) * userInStorage.currentCredentialCount );
378
377
379
378
error =
380
- chip::Server::GetInstance ().GetPersistentStorage ().SyncGetKeyValue (credentialKey.KeyName (), & mCredential , credentialSize);
379
+ chip::Server::GetInstance ().GetPersistentStorage ().SyncGetKeyValue (credentialKey.KeyName (), mCredentials , credentialSize);
381
380
382
381
// If no data is found at credential key
383
382
if (error == CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND)
@@ -387,7 +386,7 @@ bool LockManager::GetUser(chip::EndpointId endpointId, uint16_t userIndex, Ember
387
386
// Else if KVS read was successful
388
387
else if (error == CHIP_NO_ERROR)
389
388
{
390
- user.credentials = chip::Span<const CredentialStruct>{ & mCredential , userInStorage.currentCredentialCount };
389
+ user.credentials = chip::Span<const CredentialStruct>{ mCredentials , userInStorage.currentCredentialCount };
391
390
}
392
391
else
393
392
{
@@ -503,7 +502,7 @@ bool LockManager::GetCredential(chip::EndpointId endpointId, uint16_t credential
503
502
504
503
uint16_t size = static_cast <uint16_t >(sizeof (LockCredentialInfo));
505
504
506
- chip::StorageKeyName key = LockCredentialEndpoint (credentialIndex, endpointId);
505
+ chip::StorageKeyName key = LockCredentialEndpoint (credentialIndex, credentialType, endpointId);
507
506
508
507
error = chip::Server::GetInstance ().GetPersistentStorage ().SyncGetKeyValue (key.KeyName (), &credentialInStorage, size);
509
508
@@ -578,7 +577,7 @@ bool LockManager::SetCredential(chip::EndpointId endpointId, uint16_t credential
578
577
579
578
memcpy (credentialInStorage.credentialData , credentialData.data (), credentialInStorage.credentialDataSize );
580
579
581
- chip::StorageKeyName key = LockCredentialEndpoint (credentialIndex, endpointId);
580
+ chip::StorageKeyName key = LockCredentialEndpoint (credentialIndex, credentialType, endpointId);
582
581
583
582
if ((error != CHIP_NO_ERROR))
584
583
{
@@ -912,11 +911,11 @@ bool LockManager::setLockState(chip::EndpointId endpointId, const Nullable<chip:
912
911
913
912
chip::StorageKeyName credentialKey = LockUserCredentialMap (userIndex);
914
913
915
- uint16_t credentialSize = static_cast <uint16_t >(sizeof (CredentialStruct) * userInStorage.currentCredentialCount );
914
+ uint16_t credentialStructSize = static_cast <uint16_t >(sizeof (CredentialStruct) * userInStorage.currentCredentialCount );
916
915
917
916
// Get array of credential indices and types associated to user
918
917
error = chip::Server::GetInstance ().GetPersistentStorage ().SyncGetKeyValue (credentialKey.KeyName (), &mCredentials ,
919
- credentialSize );
918
+ credentialStructSize );
920
919
921
920
// No credential data associated with user
922
921
if (error != CHIP_NO_ERROR)
@@ -930,14 +929,15 @@ bool LockManager::setLockState(chip::EndpointId endpointId, const Nullable<chip:
930
929
if (mCredentials [j].credentialType == CredentialTypeEnum::kPin )
931
930
{
932
931
// Read the individual credential at credentialIndex j
933
- uint16_t size = static_cast <uint16_t >(sizeof (LockCredentialInfo));
932
+ uint16_t credentialSize = static_cast <uint16_t >(sizeof (LockCredentialInfo));
934
933
935
- chip::StorageKeyName key = LockCredentialEndpoint (mCredentials [j].credentialIndex , endpointId);
934
+ chip::StorageKeyName key =
935
+ LockCredentialEndpoint (mCredentials [j].credentialIndex , mCredentials [j].credentialType , endpointId);
936
936
937
- error =
938
- chip::Server::GetInstance (). GetPersistentStorage (). SyncGetKeyValue (key. KeyName (), &credentialInStorage, size );
937
+ error = chip::Server::GetInstance (). GetPersistentStorage (). SyncGetKeyValue (key. KeyName (), &credentialInStorage,
938
+ credentialSize );
939
939
940
- if (error != CHIP_NO_ERROR)
940
+ if (( error != CHIP_NO_ERROR) && (error != CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND) )
941
941
{
942
942
ChipLogError (Zcl, " Error reading credential" );
943
943
return false ;
0 commit comments