Skip to content

Commit

Permalink
Remove the legacy CredentialStruct definition. (#25084)
Browse files Browse the repository at this point in the history
Switches consumers to Clusters::DoorLock::Structs::CredentialStruct::Type.

af-structs.h is now empty, but will be removed in a separate PR to make things a
bit easier to review.
  • Loading branch information
bzbarsky-apple authored Feb 15, 2023
1 parent 03f2782 commit 80ee243
Show file tree
Hide file tree
Showing 12 changed files with 107 additions and 80 deletions.
6 changes: 3 additions & 3 deletions examples/lock-app/genio/src/LockManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -678,13 +678,13 @@ bool LockManager::setLockState(chip::EndpointId endpointId, DlLockState lockStat
{
for (uint8_t j = 0; j < kMaxCredentialsPerUser; j++)
{
if (mLockCredentials[mCredentials[i][j].CredentialIndex - 1].credentialType != CredentialTypeEnum::kPin ||
mLockCredentials[mCredentials[i][j].CredentialIndex - 1].status == DlCredentialStatus::kAvailable)
if (mLockCredentials[mCredentials[i][j].credentialIndex - 1].credentialType != CredentialTypeEnum::kPin ||
mLockCredentials[mCredentials[i][j].credentialIndex - 1].status == DlCredentialStatus::kAvailable)
{
continue;
}

if (mLockCredentials[mCredentials[i][j].CredentialIndex - 1].credentialData.data_equal(pin.Value()) &&
if (mLockCredentials[mCredentials[i][j].credentialIndex - 1].credentialData.data_equal(pin.Value()) &&
mLockUsers[i].userStatus != UserStatusEnum::kOccupiedDisabled)
{
ChipLogDetail(
Expand Down
9 changes: 6 additions & 3 deletions examples/lock-app/infineon/cyw30739/src/LockManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,9 +383,12 @@ bool LockManager::SetUser(chip::EndpointId endpointId, uint16_t userIndex, chip:

for (size_t i = 0; i < totalCredentials; ++i)
{
mCredentials[userIndex][i] = credentials[i];
mCredentials[userIndex][i].CredentialType = 1;
mCredentials[userIndex][i].CredentialIndex = i + 1;
mCredentials[userIndex][i] = credentials[i];
// TODO: Why are we modifying the passed-in credentials?
// https://github.com/project-chip/connectedhomeip/issues/25081
// For now, preserve pre-existing behavior, which set credentialType to 1.
mCredentials[userIndex][i].credentialType = CredentialTypeEnum::kPin;
mCredentials[userIndex][i].credentialIndex = i + 1;
}

userInStorage.credentials = chip::Span<const CredentialStruct>(mCredentials[userIndex], totalCredentials);
Expand Down
9 changes: 6 additions & 3 deletions examples/lock-app/infineon/psoc6/src/LockManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,9 +383,12 @@ bool LockManager::SetUser(chip::EndpointId endpointId, uint16_t userIndex, chip:

for (size_t i = 0; i < totalCredentials; ++i)
{
mCredentials[userIndex][i] = credentials[i];
mCredentials[userIndex][i].CredentialType = 1;
mCredentials[userIndex][i].CredentialIndex = i + 1;
mCredentials[userIndex][i] = credentials[i];
// TODO: Why are we modifying the passed-in credentials?
// https://github.com/project-chip/connectedhomeip/issues/25081
// For now, preserve pre-existing behavior, which set credentialType to 1.
mCredentials[userIndex][i].credentialType = CredentialTypeEnum::kPin;
mCredentials[userIndex][i].credentialIndex = i + 1;
}

userInStorage.credentials = chip::Span<const CredentialStruct>(mCredentials[userIndex], totalCredentials);
Expand Down
2 changes: 1 addition & 1 deletion examples/lock-app/linux/src/LockEndpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ bool LockEndpoint::setLockState(DlLockState lockState, const Optional<chip::Byte
auto credentialIndex = static_cast<unsigned>(credential - pinCredentials.begin());
auto user = std::find_if(mLockUsers.begin(), mLockUsers.end(), [credential, credentialIndex](const LockUserInfo & u) {
return std::any_of(u.credentials.begin(), u.credentials.end(), [&credential, credentialIndex](const CredentialStruct & c) {
return c.CredentialIndex == credentialIndex && c.CredentialType == to_underlying(credential->credentialType);
return c.credentialIndex == credentialIndex && c.credentialType == credential->credentialType;
});
});
if (user == mLockUsers.end())
Expand Down
9 changes: 6 additions & 3 deletions examples/lock-app/silabs/SiWx917/src/LockManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,9 +378,12 @@ bool LockManager::SetUser(chip::EndpointId endpointId, uint16_t userIndex, chip:

for (size_t i = 0; i < totalCredentials; ++i)
{
mCredentials[userIndex][i] = credentials[i];
mCredentials[userIndex][i].CredentialType = 1;
mCredentials[userIndex][i].CredentialIndex = i + 1;
mCredentials[userIndex][i] = credentials[i];
// TODO: Why are we modifying the passed-in credentials?
// https://github.com/project-chip/connectedhomeip/issues/25082
// For now, preserve pre-existing behavior, which set credentialType to 1.
mCredentials[userIndex][i].credentialType = CredentialTypeEnum::kPin;
mCredentials[userIndex][i].credentialIndex = i + 1;
}

userInStorage.credentials = chip::Span<const CredentialStruct>(mCredentials[userIndex], totalCredentials);
Expand Down
9 changes: 6 additions & 3 deletions examples/lock-app/silabs/efr32/src/LockManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,9 +378,12 @@ bool LockManager::SetUser(chip::EndpointId endpointId, uint16_t userIndex, chip:

for (size_t i = 0; i < totalCredentials; ++i)
{
mCredentials[userIndex][i] = credentials[i];
mCredentials[userIndex][i].CredentialType = 1;
mCredentials[userIndex][i].CredentialIndex = i + 1;
mCredentials[userIndex][i] = credentials[i];
// TODO: Why are we modifying the passed-in credentials?
// https://github.com/project-chip/connectedhomeip/issues/25082
// For now, preserve pre-existing behavior, which set credentialType to 1.
mCredentials[userIndex][i].credentialType = CredentialTypeEnum::kPin;
mCredentials[userIndex][i].credentialIndex = i + 1;
}

userInStorage.credentials = chip::Span<const CredentialStruct>(mCredentials[userIndex], totalCredentials);
Expand Down
9 changes: 6 additions & 3 deletions examples/platform/esp32/lock/BoltLockManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,9 +430,12 @@ bool BoltLockManager::SetUser(chip::EndpointId endpointId, uint16_t userIndex, c

for (size_t i = 0; i < totalCredentials; ++i)
{
mCredentials[userIndex][i] = credentials[i];
mCredentials[userIndex][i].CredentialType = 1;
mCredentials[userIndex][i].CredentialIndex = i + 1;
mCredentials[userIndex][i] = credentials[i];
// TODO: Why are we modifying the passed-in credentials?
// https://github.com/project-chip/connectedhomeip/issues/25083
// For now, preserve pre-existing behavior, which set credentialType to 1.
mCredentials[userIndex][i].credentialType = CredentialTypeEnum::kPin;
mCredentials[userIndex][i].credentialIndex = i + 1;
}

userInStorage.credentials = chip::Span<const CredentialStruct>(mCredentials[userIndex], totalCredentials);
Expand Down
Loading

0 comments on commit 80ee243

Please sign in to comment.