|
27 | 27 | #include <cmsis_os2.h>
|
28 | 28 | #include <lib/core/CHIPError.h>
|
29 | 29 |
|
30 |
| -struct WeekDaysScheduleInfo |
| 30 | +#include <lib/support/DefaultStorageKeyAllocator.h> |
| 31 | + |
| 32 | +struct WeekDayScheduleInfo |
31 | 33 | {
|
32 | 34 | DlScheduleStatus status;
|
33 | 35 | EmberAfPluginDoorLockWeekDaySchedule schedule;
|
@@ -112,6 +114,30 @@ class ParamBuilder
|
112 | 114 | using namespace ::chip;
|
113 | 115 | using namespace EFR32DoorLock::ResourceRanges;
|
114 | 116 |
|
| 117 | +struct LockUserInfo |
| 118 | +{ |
| 119 | + char userName[DOOR_LOCK_USER_NAME_BUFFER_SIZE]; |
| 120 | + size_t userNameSize; |
| 121 | + uint32_t userUniqueId; |
| 122 | + UserStatusEnum userStatus; |
| 123 | + UserTypeEnum userType; |
| 124 | + CredentialRuleEnum credentialRule; |
| 125 | + chip::EndpointId endpointId; |
| 126 | + chip::FabricIndex createdBy; |
| 127 | + chip::FabricIndex lastModifiedBy; |
| 128 | + uint16_t currentCredentialCount; |
| 129 | +}; |
| 130 | + |
| 131 | +struct LockCredentialInfo |
| 132 | +{ |
| 133 | + DlCredentialStatus status; |
| 134 | + CredentialTypeEnum credentialType; |
| 135 | + chip::FabricIndex createdBy; |
| 136 | + chip::FabricIndex lastModifiedBy; |
| 137 | + uint8_t credentialData[kMaxCredentialSize]; |
| 138 | + size_t credentialDataSize; |
| 139 | +}; |
| 140 | + |
115 | 141 | class LockManager
|
116 | 142 | {
|
117 | 143 | public:
|
@@ -192,8 +218,6 @@ class LockManager
|
192 | 218 | OperationErrorEnum & err);
|
193 | 219 | const char * lockStateToString(DlLockState lockState) const;
|
194 | 220 |
|
195 |
| - bool ReadConfigValues(); |
196 |
| - |
197 | 221 | void UnlockAfterUnlatch();
|
198 | 222 |
|
199 | 223 | private:
|
@@ -244,17 +268,24 @@ class LockManager
|
244 | 268 | static void ActuatorMovementTimerEventHandler(AppEvent * aEvent);
|
245 | 269 |
|
246 | 270 | osTimerId_t mLockTimer;
|
247 |
| - EmberAfPluginDoorLockUserInfo mLockUsers[kMaxUsers]; |
248 |
| - EmberAfPluginDoorLockCredentialInfo mLockCredentials[kNumCredentialTypes][kMaxCredentials]; |
249 |
| - WeekDaysScheduleInfo mWeekdaySchedule[kMaxUsers][kMaxWeekdaySchedulesPerUser]; |
250 |
| - YearDayScheduleInfo mYeardaySchedule[kMaxUsers][kMaxYeardaySchedulesPerUser]; |
251 |
| - HolidayScheduleInfo mHolidaySchedule[kMaxHolidaySchedules]; |
252 |
| - |
253 |
| - char mUserNames[MATTER_ARRAY_SIZE(mLockUsers)][DOOR_LOCK_MAX_USER_NAME_SIZE]; |
254 |
| - uint8_t mCredentialData[kNumCredentialTypes][kMaxCredentials][kMaxCredentialSize]; |
255 |
| - CredentialStruct mCredentials[kMaxUsers][kMaxCredentials]; |
256 | 271 |
|
257 | 272 | EFR32DoorLock::LockInitParams::LockParam LockParams;
|
| 273 | + |
| 274 | + static StorageKeyName LockUserEndpoint(uint16_t userIndex, chip::EndpointId endpoint) { return StorageKeyName::Formatted("g/lu/%x/e/%x", userIndex, endpoint); } |
| 275 | + static StorageKeyName LockCredentialEndpoint(uint16_t credentialIndex, chip::EndpointId endpoint) { return StorageKeyName::Formatted("g/lc/%x/e/%x", credentialIndex, endpoint); } |
| 276 | + static StorageKeyName LockUserCredentialMap(uint16_t userIndex) { return StorageKeyName::Formatted("g/lu/%x/lc", userIndex); } // Stores all the credential indices that belong to a user |
| 277 | + static StorageKeyName LockUserWeekDayScheduleEndpoint(uint16_t userIndex, uint16_t scheduleIndex, chip::EndpointId endpoint) { return StorageKeyName::Formatted("g/lu/%x/lw/%x/e/%x", userIndex, scheduleIndex, endpoint); } |
| 278 | + static StorageKeyName LockUserYearDayScheduleEndpoint(uint16_t userIndex, uint16_t scheduleIndex, chip::EndpointId endpoint) { return StorageKeyName::Formatted("g/lu/%x/ly/%x/e/%x", userIndex, scheduleIndex, endpoint); } |
| 279 | + static StorageKeyName LockHolidayScheduleEndpoint(uint16_t scheduleIndex, chip::EndpointId endpoint) { return StorageKeyName::Formatted("g/lh/%x/e/%x", scheduleIndex, endpoint); } |
| 280 | + |
| 281 | + LockUserInfo userInStorage; |
| 282 | + LockCredentialInfo credentialInStorage; |
| 283 | + WeekDayScheduleInfo weekDayScheduleInStorage; |
| 284 | + YearDayScheduleInfo yearDayScheduleInStorage; |
| 285 | + HolidayScheduleInfo holidayScheduleInStorage; |
| 286 | + CredentialStruct mCredential; |
| 287 | + CredentialStruct mCredentials[kMaxCredentialsPerUser]; |
| 288 | + |
258 | 289 | };
|
259 | 290 |
|
260 | 291 | LockManager & LockMgr();
|
0 commit comments