Skip to content

Commit

Permalink
Add more Logs
Browse files Browse the repository at this point in the history
  • Loading branch information
AzonInc committed Jan 7, 2025
1 parent 998b30b commit 143e82b
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions components/nuki_lock/nuki_lock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,9 +450,14 @@ void NukiLockComponent::update_auth_data()
ESP_LOGD(TAG, "retrieveAuthorizationEntries has resulted in %s (%d)", auth_data_req_result_as_string, auth_data_req_result);

this->set_timeout("wait_for_auth_data", 5000, [this]() {

ESP_LOGD(TAG, "wait_for_auth_data done");

std::list<NukiLock::AuthorizationEntry> authEntries;
this->nuki_lock_.getAuthorizationEntries(&authEntries);

ESP_LOGD(TAG, "getAuthorizationEntries done: %d", authEntries.size());

authEntries.sort([](const NukiLock::AuthorizationEntry& a, const NukiLock::AuthorizationEntry& b)
{
return a.authId < b.authId;
Expand Down Expand Up @@ -495,22 +500,28 @@ void NukiLockComponent::update_event_logs()
ESP_LOGD(TAG, "retrieveLogEntries has resulted in %s (%d)", event_log_req_result_as_string, event_log_req_result);

this->set_timeout("wait_for_log_entries", 5000, [this]() {

ESP_LOGD(TAG, "getLogEntries");


std::list<NukiLock::LogEntry> log;
this->nuki_lock_.getLogEntries(&log);

if(log.size() > MAX_EVENT_LOG_ENTRIES)
{
ESP_LOGD(TAG, "getLogEntries done: %d", log.size());

if(log.size() > MAX_EVENT_LOG_ENTRIES) {
ESP_LOGD(TAG, "resize");
log.resize(MAX_EVENT_LOG_ENTRIES);
}

log.sort([](const NukiLock::LogEntry& a, const NukiLock::LogEntry& b)
{
log.sort([](const NukiLock::LogEntry& a, const NukiLock::LogEntry& b) {
return a.index < b.index;
});

if(log.size() > 0)
{
if(log.size() > 0) {
this->process_log_entries(log);
} else {
ESP_LOGD(TAG, "No log entries");
}
});

Expand Down

0 comments on commit 143e82b

Please sign in to comment.