diff --git a/examples/lock-app/efr32/src/LockManager.cpp b/examples/lock-app/efr32/src/LockManager.cpp index b59b15b57c4110..ab9e548562981e 100644 --- a/examples/lock-app/efr32/src/LockManager.cpp +++ b/examples/lock-app/efr32/src/LockManager.cpp @@ -406,11 +406,7 @@ bool LockManager::GetCredential(chip::EndpointId endpointId, uint16_t credential EmberAfPluginDoorLockCredentialInfo & credential) { - VerifyOrReturnValue(credentialIndex > 0, false); // indices are one-indexed - - credentialIndex--; - - VerifyOrReturnValue(IsValidCredentialIndex(credentialIndex, credentialType), false); + VerifyOrReturnValue(IsValidCredentialIndex(--credentialIndex, credentialType), false); // indices are one-indexed ChipLogProgress(Zcl, "Lock App: LockManager::GetCredential [credentialType=%u], credentialIndex=%d", to_underlying(credentialType), credentialIndex); @@ -453,11 +449,7 @@ bool LockManager::SetCredential(chip::EndpointId endpointId, uint16_t credential const chip::ByteSpan & credentialData) { - VerifyOrReturnValue(credentialIndex > 0, false); // indices are one-indexed - - credentialIndex--; - - VerifyOrReturnValue(IsValidCredentialIndex(credentialIndex, credentialType), false); + VerifyOrReturnValue(IsValidCredentialIndex(--credentialIndex, credentialType), false); // indices are one-indexed ChipLogProgress(Zcl, "Door Lock App: LockManager::SetCredential " @@ -635,23 +627,6 @@ const char * LockManager::lockStateToString(DlLockState lockState) const bool LockManager::setLockState(chip::EndpointId endpointId, DlLockState lockState, const Optional & pin, DlOperationError & err) { - DlLockState curState = DlLockState::kLocked; - if (mState == kState_UnlockCompleted) - curState = DlLockState::kUnlocked; - - if ((curState == lockState) && (curState == DlLockState::kLocked)) - { - ChipLogDetail(Zcl, "Door Lock App: door is already locked, ignoring command to set lock state to \"%s\" [endpointId=%d]", - lockStateToString(lockState), endpointId); - return true; - } - else if ((curState == lockState) && (curState == DlLockState::kUnlocked)) - { - ChipLogDetail(Zcl, - "Door Lock App: door is already unlocked, ignoring command to set unlock state to \"%s\" [endpointId=%d]", - lockStateToString(lockState), endpointId); - return true; - } // Assume pin is required until told otherwise bool requirePin = true; @@ -661,14 +636,12 @@ bool LockManager::setLockState(chip::EndpointId endpointId, DlLockState lockStat if (!pin.HasValue()) { ChipLogDetail(Zcl, "Door Lock App: PIN code is not specified, but it is required [endpointId=%d]", mEndpointId); - curState = lockState; // If a pin code is not required if (!requirePin) { ChipLogDetail(Zcl, "Door Lock App: setting door lock state to \"%s\" [endpointId=%d]", lockStateToString(lockState), endpointId); - curState = lockState; return true; } @@ -690,8 +663,6 @@ bool LockManager::setLockState(chip::EndpointId endpointId, DlLockState lockStat "Lock App: specified PIN code was found in the database, setting lock state to \"%s\" [endpointId=%d]", lockStateToString(lockState), mEndpointId); - curState = lockState; - return true; } }