From eb4c48405c94fb410635ea433a2879211ad62d5e Mon Sep 17 00:00:00 2001 From: technyon Date: Wed, 1 Jun 2022 21:14:50 +0200 Subject: [PATCH] allow to set opener PIN --- CMakeLists.txt | 2 +- WebCfgServer.cpp | 45 ++++++++++++++++++++++++++++++++++++--------- 2 files changed, 37 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6c774a2..ed3a719 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,7 @@ project(nuki_hub CXX) # ARDUHAL_LOG_LEVEL_NONE, define ARDUHAL_LOG_LEVEL_ERROR, define ARDUHAL_LOG_LEVEL_WARN, define ARDUHAL_LOG_LEVEL_INFO, # define ARDUHAL_LOG_LEVEL_DEBUG, define ARDUHAL_LOG_LEVEL_VERBOSE -set(LOG_LEVEL ARDUHAL_LOG_LEVEL_NONE) +set(LOG_LEVEL ARDUHAL_LOG_LEVEL_DEBUG) include_directories(${PROJECT_NAME} PRIVATE diff --git a/WebCfgServer.cpp b/WebCfgServer.cpp index e4e3cd3..ac258e9 100644 --- a/WebCfgServer.cpp +++ b/WebCfgServer.cpp @@ -229,15 +229,28 @@ bool WebCfgServer::processArgs(String& message) { if(value == "#") { - message = "PIN cleared"; + message = "NUKI Lock PIN cleared"; _nuki->setPin(0xffff); } else { - message = "PIN saved"; + message = "NUKI Lock PIN saved"; _nuki->setPin(value.toInt()); } } + else if(key == "NUKIOPPIN" && _nukiOpener != nullptr) + { + if(value == "#") + { + message = "NUKI Opener PIN cleared"; + _nukiOpener->setPin(0xffff); + } + else + { + message = "NUKI Opener PIN saved"; + _nukiOpener->setPin(value.toInt()); + } + } } if(clearMqttCredentials) @@ -364,13 +377,27 @@ void WebCfgServer::buildCredHtml(String &response) response.concat("
"); response.concat(""); - response.concat("

"); - response.concat("

NUKI Pin Code

"); - response.concat(""); - printInputField(response, "NUKIPIN", "PIN Code (# to clear)", "*", 20, true); - response.concat("
"); - response.concat("
"); - response.concat("
"); + if(_nuki != nullptr) + { + response.concat("

"); + response.concat("

NUKI Lock PIN

"); + response.concat(""); + printInputField(response, "NUKIPIN", "PIN Code (# to clear)", "*", 20, true); + response.concat("
"); + response.concat("
"); + response.concat("
"); + } + + if(_nukiOpener != nullptr) + { + response.concat("

"); + response.concat("

NUKI Opener PIN

"); + response.concat(""); + printInputField(response, "NUKIOPPIN", "PIN Code (# to clear)", "*", 20, true); + response.concat("
"); + response.concat("
"); + response.concat("
"); + } _confirmCode = generateConfirmCode(); if(_nuki != nullptr)