Skip to content

Commit 9d080c1

Browse files
committed
matter: samples: Remove unused code
Remove old code handling clearing users/credentials from fabric as it's unused and not spec compilant. Signed-off-by: Adrian Gielniewski <adrian.gielniewski@nordicsemi.no>
1 parent 889f929 commit 9d080c1

File tree

3 files changed

+4
-51
lines changed

3 files changed

+4
-51
lines changed

samples/matter/lock/Kconfig

-7
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,6 @@ config SHELL_CMD_BUFF_SIZE
7171

7272
endif
7373

74-
config LOCK_LEAVE_FABRIC_CLEAR_CREDENTIAL
75-
bool "Clear all credentials assigned to given fabric index"
76-
default y
77-
help
78-
This feature allows to remove all credentials which were created or modified
79-
within the fabric which is being removed from the door lock.
80-
8174
config STATE_LEDS
8275
bool "Use LEDs to indicate the device state"
8376
default y

samples/matter/lock/src/access/access_manager.h

-13
Original file line numberDiff line numberDiff line change
@@ -264,15 +264,6 @@ template <DoorLockData::CredentialsBits CRED_BIT_MASK> class AccessManager {
264264
*/
265265
bool GetRequirePIN() { return mRequirePINForRemoteOperation; };
266266

267-
#ifdef CONFIG_LOCK_LEAVE_FABRIC_CLEAR_CREDENTIAL
268-
/**
269-
* @brief Clear all credentials from the fabric which is currently being removed
270-
*
271-
* @return true on success, false otherwise
272-
*/
273-
bool ClearAllCredentialsFromFabric();
274-
#endif
275-
276267
#ifdef CONFIG_LOCK_ENABLE_DEBUG
277268
/* DEBUG API allowing to retrieve internally stored credentials and user data */
278269
void PrintCredential(CredentialTypeEnum type, uint16_t index);
@@ -336,10 +327,6 @@ template <DoorLockData::CredentialsBits CRED_BIT_MASK> class AccessManager {
336327
DlCredentialStatus credentialStatus, CredentialTypeEnum credentialType,
337328
const chip::ByteSpan &secret);
338329

339-
#ifdef CONFIG_LOCK_LEAVE_FABRIC_CLEAR_CREDENTIAL
340-
static bool ClearCredential(DoorLockData::Credential &credential, uint8_t credIdx);
341-
#endif
342-
343330
SetCredentialCallback mSetCredentialCallback{ nullptr };
344331
ClearCredentialCallback mClearCredentialCallback{ nullptr };
345332
ValidateCredentialCallback mValidateCredentialCallback{ nullptr };

samples/matter/lock/src/access/access_manager_credentials.cpp

+4-31
Original file line numberDiff line numberDiff line change
@@ -145,32 +145,6 @@ CHIP_ERROR AccessManager<CRED_BIT_MASK>::GetCredentialUserId(uint16_t credential
145145
return CHIP_ERROR_NOT_FOUND;
146146
}
147147

148-
#ifdef CONFIG_LOCK_LEAVE_FABRIC_CLEAR_CREDENTIAL
149-
template <CredentialsBits CRED_BIT_MASK> bool AccessManager<CRED_BIT_MASK>::ClearAllCredentialsFromFabric()
150-
{
151-
return mCredentials.ForEach([](DoorLockData::Credential &credential, uint8_t credIdx) {
152-
/* At this point the door-lock-server already invalidated both mCreatedBy and mLastModifiedBy
153-
of all credentials assigned to the fabric which is currently being removed */
154-
if (credential.mInfo.mFields.mCreatedBy == kUndefinedFabricIndex &&
155-
credential.mInfo.mFields.mLastModifiedBy == kUndefinedFabricIndex &&
156-
credential.mSecret.mDataLength != 0) {
157-
return Instance().ClearCredential(credential, credIdx);
158-
}
159-
return true;
160-
});
161-
}
162-
163-
template <CredentialsBits CRED_BIT_MASK>
164-
bool AccessManager<CRED_BIT_MASK>::ClearCredential(DoorLockData::Credential &credential, uint8_t credIdx)
165-
{
166-
credIdx++; /* DoSetCredential expects indexes starting from 1 */
167-
return DoSetCredential(credential, credIdx, kUndefinedFabricIndex, kUndefinedFabricIndex,
168-
DlCredentialStatus::kAvailable,
169-
static_cast<CredentialTypeEnum>(credential.mInfo.mFields.mCredentialType),
170-
chip::ByteSpan());
171-
}
172-
#endif
173-
174148
template <CredentialsBits CRED_BIT_MASK> void AccessManager<CRED_BIT_MASK>::LoadCredentialsFromPersistentStorage()
175149
{
176150
uint8_t credentialData[DoorLockData::Credential::RequiredBufferSize()] = { 0 };
@@ -186,8 +160,8 @@ template <CredentialsBits CRED_BIT_MASK> void AccessManager<CRED_BIT_MASK>::Load
186160
}
187161
outSize = 0;
188162
if (!AccessStorage::Instance().Load(AccessStorage::Type::CredentialsIndexes,
189-
credentialIndexesSerialized,
190-
sizeof(credentialIndexesSerialized), outSize, type)) {
163+
credentialIndexesSerialized, sizeof(credentialIndexesSerialized),
164+
outSize, type)) {
191165
LOG_INF("No stored indexes for credential of type: %d", type);
192166
continue;
193167
}
@@ -203,8 +177,7 @@ template <CredentialsBits CRED_BIT_MASK> void AccessManager<CRED_BIT_MASK>::Load
203177
uint16_t credentialIndex = credIndexes.mList.mIndexes[idx];
204178
outSize = 0;
205179
if (!AccessStorage::Instance().Load(AccessStorage::Type::Credential, credentialData,
206-
sizeof(credentialData), outSize, type,
207-
credentialIndex)) {
180+
sizeof(credentialData), outSize, type, credentialIndex)) {
208181
LOG_ERR("Cannot load credentials of type %d for index: %d", static_cast<uint8_t>(type),
209182
credentialIndex);
210183
}
@@ -217,7 +190,7 @@ template <CredentialsBits CRED_BIT_MASK> void AccessManager<CRED_BIT_MASK>::Load
217190
}
218191
outSize = 0;
219192
if (!AccessStorage::Instance().Load(AccessStorage::Type::RequirePIN, &mRequirePINForRemoteOperation,
220-
sizeof(mRequirePINForRemoteOperation), outSize) ||
193+
sizeof(mRequirePINForRemoteOperation), outSize) ||
221194
outSize != sizeof(mRequirePINForRemoteOperation)) {
222195
LOG_DBG("Cannot load RequirePINforRemoteOperation");
223196
}

0 commit comments

Comments
 (0)