Skip to content

Commit 509f2e6

Browse files
committed
Use constants for auth data and log limits
1 parent 16bbd9b commit 509f2e6

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

components/nuki_lock/nuki_lock.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ void NukiLockComponent::update_auth_data()
239239
while(retryCount < 3)
240240
{
241241
ESP_LOGD(TAG, "Retrieve Auth Data");
242-
confReqResult = this->nuki_lock_.retrieveAuthorizationEntries(0, 10);
242+
confReqResult = this->nuki_lock_.retrieveAuthorizationEntries(0, MAX_AUTH_DATA_ENTRIES);
243243

244244
if(confReqResult != Nuki::CmdResult::Success)
245245
{
@@ -263,9 +263,9 @@ void NukiLockComponent::update_auth_data()
263263
return a.authId < b.authId;
264264
});
265265

266-
if(authEntries.size() > 20)
266+
if(authEntries.size() > MAX_AUTH_DATA_ENTRIES)
267267
{
268-
authEntries.resize(20);
268+
authEntries.resize(MAX_AUTH_DATA_ENTRIES);
269269
}
270270

271271
for(const auto& entry : authEntries)
@@ -284,7 +284,7 @@ void NukiLockComponent::update_event_logs()
284284
while(retryCount < 3)
285285
{
286286
ESP_LOGD(TAG, "Retrieve Event Logs");
287-
confReqResult = this->nuki_lock_.retrieveLogEntries(0, 10, 1, false);
287+
confReqResult = this->nuki_lock_.retrieveLogEntries(0, MAX_EVENT_LOG_ENTRIES, 1, false);
288288

289289
if(confReqResult != Nuki::CmdResult::Success)
290290
{
@@ -303,9 +303,9 @@ void NukiLockComponent::update_event_logs()
303303
std::list<NukiLock::LogEntry> log;
304304
this->nuki_lock_.getLogEntries(&log);
305305

306-
if(log.size() > 3)
306+
if(log.size() > MAX_EVENT_LOG_ENTRIES)
307307
{
308-
log.resize(3);
308+
log.resize(MAX_EVENT_LOG_ENTRIES);
309309
}
310310

311311
log.sort([](const NukiLock::LogEntry& a, const NukiLock::LogEntry& b)

components/nuki_lock/nuki_lock.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,13 @@ class NukiLockComponent : public lock::Lock, public PollingComponent, public api
7777

7878
static const uint8_t BLE_CONNECT_TIMEOUT_SEC = 3;
7979
static const uint8_t BLE_CONNECT_TIMEOUT_RETRIES = 1;
80+
8081
static const uint8_t MAX_ACTION_ATTEMPTS = 5;
8182
static const uint8_t MAX_TOLERATED_UPDATES_ERRORS = 5;
83+
84+
static const uint8_t MAX_AUTH_DATA_ENTRIES = 10;
85+
static const uint8_t MAX_EVENT_LOG_ENTRIES = 3;
86+
8287
static const uint32_t COOLDOWN_COMMANDS_MILLIS = 1000;
8388
static const uint32_t COOLDOWN_COMMANDS_EXTENDED_MILLIS = 3000;
8489

0 commit comments

Comments
 (0)