From e8f7c8757936325987790cf3bf4fa268665582a1 Mon Sep 17 00:00:00 2001 From: technyon Date: Mon, 15 Aug 2022 22:49:35 +0200 Subject: [PATCH] restore authId and authName nodes --- NetworkLock.cpp | 21 ++++++++++++++++++++- NetworkOpener.cpp | 18 ++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/NetworkLock.cpp b/NetworkLock.cpp index 0d14b96..b2675ab 100644 --- a/NetworkLock.cpp +++ b/NetworkLock.cpp @@ -235,10 +235,22 @@ void NetworkLock::publishAuthorizationInfo(const std::list& { char str[50]; + bool authFound = false; + uint32_t authId = 0; + char authName[33]; + memset(authName, 0, sizeof(authName)); + String json = "[\n"; for(const auto& log : logEntries) { + if((log.loggingType == NukiLock::LoggingType::LockAction || log.loggingType == NukiLock::LoggingType::KeypadAction) && ! authFound) + { + authFound = true; + authId = log.authId; + memcpy(authName, log.name, sizeof(log.name)); + } + json.concat("{\n"); json.concat("\"index\": "); json.concat(log.index); json.concat(",\n"); @@ -323,12 +335,19 @@ void NetworkLock::publishAuthorizationInfo(const std::list& json.concat("]"); publishString(mqtt_topic_lock_log, json.c_str()); + + if(authFound) + { + publishUInt(mqtt_topic_lock_auth_id, authId); + publishString(mqtt_topic_lock_auth_name, authName); + } } void NetworkLock::clearAuthorizationInfo() { publishString(mqtt_topic_lock_log, ""); -} + publishUInt(mqtt_topic_lock_auth_id, 0); + publishString(mqtt_topic_lock_auth_name, "--");} void NetworkLock::publishCommandResult(const char *resultStr) { diff --git a/NetworkOpener.cpp b/NetworkOpener.cpp index e6344db..a87c8ef 100644 --- a/NetworkOpener.cpp +++ b/NetworkOpener.cpp @@ -146,10 +146,22 @@ void NetworkOpener::publishAuthorizationInfo(const std::list