Runtime alt connect and debug logging
This commit is contained in:
@@ -227,6 +227,7 @@ In a browser navigate to the IP address assigned to the ESP32.
|
||||
|
||||
- Nuki Smartlock enabled: Enable if you want Nuki Hub to connect to a Nuki Lock (1.0-4.0)
|
||||
- Nuki Opener enabled: Enable if you want Nuki Hub to connect to a Nuki Opener
|
||||
- New Nuki Bluetooth connection mode (disable if there are connection issues): Enable to use the latest Nuki BLE connection mode (recommended). Disable if you have issues communicating with the lock/opener
|
||||
|
||||
#### Advanced Nuki Configuration
|
||||
|
||||
|
||||
Submodule lib/nuki_ble updated: 0647d251b7...983b38ca2a
@@ -77,7 +77,7 @@ extra_scripts =
|
||||
post:pio_package_post.py
|
||||
build_flags =
|
||||
${env.build_flags}
|
||||
-DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_NONE
|
||||
-DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG
|
||||
-DCONFIG_NIMBLE_CPP_LOG_LEVEL=0
|
||||
-DCONFIG_BT_NIMBLE_LOG_LEVEL=0
|
||||
|
||||
@@ -138,12 +138,6 @@ build_flags =
|
||||
-DCONFIG_NIMBLE_CPP_LOG_LEVEL=0
|
||||
-DCONFIG_BT_NIMBLE_LOG_LEVEL=0
|
||||
-DDEBUG_NUKIHUB
|
||||
-DDEBUG_SENSE_NUKI
|
||||
-DDEBUG_NUKI_COMMAND
|
||||
-DDEBUG_NUKI_CONNECT
|
||||
-DDEBUG_NUKI_COMMUNICATION
|
||||
;-DDEBUG_NUKI_HEX_DATA
|
||||
-DDEBUG_NUKI_READABLE_DATA
|
||||
|
||||
[env:esp32-c3_dbg]
|
||||
extends = env:esp32-c3
|
||||
@@ -156,12 +150,6 @@ build_flags =
|
||||
-DCONFIG_NIMBLE_CPP_LOG_LEVEL=0
|
||||
-DCONFIG_BT_NIMBLE_LOG_LEVEL=0
|
||||
-DDEBUG_NUKIHUB
|
||||
-DDEBUG_SENSE_NUKI
|
||||
-DDEBUG_NUKI_COMMAND
|
||||
-DDEBUG_NUKI_CONNECT
|
||||
-DDEBUG_NUKI_COMMUNICATION
|
||||
;-DDEBUG_NUKI_HEX_DATA
|
||||
-DDEBUG_NUKI_READABLE_DATA
|
||||
|
||||
[env:esp32-c6_dbg]
|
||||
extends = env:esp32-c6
|
||||
@@ -174,12 +162,6 @@ build_flags =
|
||||
-DCONFIG_NIMBLE_CPP_LOG_LEVEL=0
|
||||
-DCONFIG_BT_NIMBLE_LOG_LEVEL=0
|
||||
-DDEBUG_NUKIHUB
|
||||
-DDEBUG_SENSE_NUKI
|
||||
-DDEBUG_NUKI_COMMAND
|
||||
-DDEBUG_NUKI_CONNECT
|
||||
-DDEBUG_NUKI_COMMUNICATION
|
||||
;-DDEBUG_NUKI_HEX_DATA
|
||||
-DDEBUG_NUKI_READABLE_DATA
|
||||
|
||||
[env:esp32-h2_dbg]
|
||||
extends = env:esp32-h2
|
||||
@@ -193,12 +175,6 @@ build_flags =
|
||||
-DCONFIG_NIMBLE_CPP_LOG_LEVEL=0
|
||||
-DCONFIG_BT_NIMBLE_LOG_LEVEL=0
|
||||
-DDEBUG_NUKIHUB
|
||||
-DDEBUG_SENSE_NUKI
|
||||
-DDEBUG_NUKI_COMMAND
|
||||
-DDEBUG_NUKI_CONNECT
|
||||
-DDEBUG_NUKI_COMMUNICATION
|
||||
;-DDEBUG_NUKI_HEX_DATA
|
||||
-DDEBUG_NUKI_READABLE_DATA
|
||||
|
||||
[env:esp32-s3_dbg]
|
||||
extends = env:esp32-s3
|
||||
@@ -211,12 +187,6 @@ build_flags =
|
||||
-DCONFIG_NIMBLE_CPP_LOG_LEVEL=0
|
||||
-DCONFIG_BT_NIMBLE_LOG_LEVEL=0
|
||||
-DDEBUG_NUKIHUB
|
||||
-DDEBUG_SENSE_NUKI
|
||||
-DDEBUG_NUKI_COMMAND
|
||||
-DDEBUG_NUKI_CONNECT
|
||||
-DDEBUG_NUKI_COMMUNICATION
|
||||
;-DDEBUG_NUKI_HEX_DATA
|
||||
-DDEBUG_NUKI_READABLE_DATA
|
||||
|
||||
[env:esp32-s3-oct_dbg]
|
||||
extends = env:esp32-s3-oct
|
||||
@@ -229,12 +199,6 @@ build_flags =
|
||||
-DCONFIG_NIMBLE_CPP_LOG_LEVEL=0
|
||||
-DCONFIG_BT_NIMBLE_LOG_LEVEL=0
|
||||
-DDEBUG_NUKIHUB
|
||||
-DDEBUG_SENSE_NUKI
|
||||
-DDEBUG_NUKI_COMMAND
|
||||
-DDEBUG_NUKI_CONNECT
|
||||
-DDEBUG_NUKI_COMMUNICATION
|
||||
;-DDEBUG_NUKI_HEX_DATA
|
||||
-DDEBUG_NUKI_READABLE_DATA
|
||||
|
||||
[env:esp32-solo1_dbg]
|
||||
extends = env:esp32-solo1
|
||||
@@ -247,9 +211,3 @@ build_flags =
|
||||
-DCONFIG_NIMBLE_CPP_LOG_LEVEL=0
|
||||
-DCONFIG_BT_NIMBLE_LOG_LEVEL=0
|
||||
-DDEBUG_NUKIHUB
|
||||
-DDEBUG_SENSE_NUKI
|
||||
-DDEBUG_NUKI_COMMAND
|
||||
-DDEBUG_NUKI_CONNECT
|
||||
-DDEBUG_NUKI_COMMUNICATION
|
||||
;-DDEBUG_NUKI_HEX_DATA
|
||||
-DDEBUG_NUKI_READABLE_DATA
|
||||
@@ -86,6 +86,7 @@ CONFIG_HEAP_TASK_TRACKING=n
|
||||
CONFIG_LOG_COLORS=n
|
||||
CONFIG_LOG_MAXIMUM_EQUALS_DEFAULT=n
|
||||
CONFIG_LOG_MAXIMUM_LEVEL=4
|
||||
CONFIG_ARDUHAL_ESP_LOG=y
|
||||
CONFIG_ETH_ENABLED=y
|
||||
CONFIG_ETH_USE_SPI_ETHERNET=y
|
||||
CONFIG_ETH_SPI_ETHERNET_W5500=y
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
CONFIG_LOG_DEFAULT_LEVEL_NONE=y
|
||||
CONFIG_LOG_DEFAULT_LEVEL=0
|
||||
CONFIG_ESP_IPC_TASK_STACK_SIZE=1024
|
||||
CONFIG_LOG_DEFAULT_LEVEL_DEBUG=y
|
||||
CONFIG_LOG_DEFAULT_LEVEL=4
|
||||
CONFIG_ESP_IPC_TASK_STACK_SIZE=2048
|
||||
CONFIG_BOOTLOADER_LOG_LEVEL_ERROR=y
|
||||
CONFIG_BOOTLOADER_LOG_LEVEL=1
|
||||
@@ -5,7 +5,7 @@
|
||||
#define NUKI_HUB_VERSION "9.05"
|
||||
#define NUKI_HUB_VERSION_INT (uint32_t)905
|
||||
#define NUKI_HUB_BUILD "unknownbuildnr"
|
||||
#define NUKI_HUB_DATE "2024-12-17"
|
||||
#define NUKI_HUB_DATE "2024-12-18"
|
||||
|
||||
#define GITHUB_LATEST_RELEASE_URL (char*)"https://github.com/technyon/nuki_hub/releases/latest"
|
||||
#define GITHUB_OTA_MANIFEST_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/manifest.json"
|
||||
|
||||
@@ -48,7 +48,13 @@ NukiOpenerWrapper::~NukiOpenerWrapper()
|
||||
|
||||
void NukiOpenerWrapper::initialize()
|
||||
{
|
||||
_nukiOpener.initialize();
|
||||
_nukiOpener.setDebugConnect(_preferences->getBool(preference_debug_connect, false));
|
||||
_nukiOpener.setDebugCommunication(_preferences->getBool(preference_debug_communication, false));
|
||||
_nukiOpener.setDebugReadableData(_preferences->getBool(preference_debug_readable_data, false));
|
||||
_nukiOpener.setDebugHexData(_preferences->getBool(preference_debug_hex_data, false));
|
||||
_nukiOpener.setDebugCommand(_preferences->getBool(preference_debug_command, false));
|
||||
|
||||
_nukiOpener.initialize(_preferences->getBool(preference_connect_mode, false));
|
||||
_nukiOpener.registerBleScanner(_bleScanner);
|
||||
_nukiOpener.setEventHandler(this);
|
||||
_nukiOpener.setConnectTimeout(3);
|
||||
|
||||
@@ -49,7 +49,13 @@ NukiWrapper::~NukiWrapper()
|
||||
|
||||
void NukiWrapper::initialize()
|
||||
{
|
||||
_nukiLock.initialize();
|
||||
_nukiLock.setDebugConnect(_preferences->getBool(preference_debug_connect, false));
|
||||
_nukiLock.setDebugCommunication(_preferences->getBool(preference_debug_communication, false));
|
||||
_nukiLock.setDebugReadableData(_preferences->getBool(preference_debug_readable_data, false));
|
||||
_nukiLock.setDebugHexData(_preferences->getBool(preference_debug_hex_data, false));
|
||||
_nukiLock.setDebugCommand(_preferences->getBool(preference_debug_command, false));
|
||||
|
||||
_nukiLock.initialize(_preferences->getBool(preference_connect_mode, false));
|
||||
_nukiLock.registerBleScanner(_bleScanner);
|
||||
_nukiLock.setEventHandler(this);
|
||||
_nukiLock.setConnectTimeout(3);
|
||||
|
||||
@@ -61,6 +61,12 @@
|
||||
#define preference_wifi_ssid (char*)"wifiSSID"
|
||||
#define preference_wifi_pass (char*)"wifiPass"
|
||||
#define preference_disable_network_not_connected (char*)"disNtwNoCon"
|
||||
#define preference_debug_connect (char*)"dbgConnect"
|
||||
#define preference_debug_communication (char*)"dbgCommu"
|
||||
#define preference_debug_readable_data (char*)"dbgReadData"
|
||||
#define preference_debug_hex_data (char*)"dbgHexData"
|
||||
#define preference_debug_command (char*)"dbgCommand"
|
||||
#define preference_connect_mode (char*)"nukiConnMode"
|
||||
|
||||
// CHANGE DOES NOT REQUIRE REBOOT TO TAKE EFFECT
|
||||
#define preference_find_best_rssi (char*)"nwbestrssi"
|
||||
@@ -204,6 +210,13 @@ inline void initPreferences(Preferences* preferences)
|
||||
preferences->putInt(preference_query_interval_battery, 1800);
|
||||
preferences->putInt(preference_query_interval_keypad, 1800);
|
||||
|
||||
preferences->putBool(preference_debug_connect, false);
|
||||
preferences->putBool(preference_debug_communication, false);
|
||||
preferences->putBool(preference_debug_readable_data, false);
|
||||
preferences->putBool(preference_debug_hex_data, false);
|
||||
preferences->putBool(preference_debug_command, false);
|
||||
preferences->putBool(preference_connect_mode, false);
|
||||
|
||||
#ifndef CONFIG_IDF_TARGET_ESP32H2
|
||||
WiFi.begin();
|
||||
WiFi.disconnect(true, true);
|
||||
@@ -362,7 +375,9 @@ private:
|
||||
preference_network_custom_rst, preference_network_custom_cs, preference_network_custom_sck, preference_network_custom_miso, preference_network_custom_mosi,
|
||||
preference_network_custom_pwr, preference_network_custom_mdio, preference_ntw_reconfigure, preference_lock_max_auth_entry_count, preference_opener_max_auth_entry_count,
|
||||
preference_auth_control_enabled, preference_auth_topic_per_entry, preference_auth_info_enabled, preference_auth_max_entries, preference_wifi_ssid, preference_wifi_pass,
|
||||
preference_keypad_check_code_enabled, preference_disable_network_not_connected, preference_mqtt_hass_enabled, preference_hass_device_discovery
|
||||
preference_keypad_check_code_enabled, preference_disable_network_not_connected, preference_mqtt_hass_enabled, preference_hass_device_discovery,
|
||||
preference_debug_connect, preference_debug_communication, preference_debug_readable_data, preference_debug_hex_data, preference_debug_command, preference_connect_mode
|
||||
|
||||
};
|
||||
std::vector<char*> _redact =
|
||||
{
|
||||
@@ -378,7 +393,8 @@ private:
|
||||
preference_publish_authdata, preference_publish_debug_info, preference_official_hybrid_enabled, preference_mqtt_hass_enabled,
|
||||
preference_official_hybrid_actions, preference_official_hybrid_retry, preference_conf_info_enabled, preference_disable_non_json, preference_update_from_mqtt,
|
||||
preference_auth_control_enabled, preference_auth_topic_per_entry, preference_auth_info_enabled, preference_webserial_enabled, preference_hass_device_discovery,
|
||||
preference_ntw_reconfigure, preference_keypad_check_code_enabled, preference_disable_network_not_connected, preference_find_best_rssi
|
||||
preference_ntw_reconfigure, preference_keypad_check_code_enabled, preference_disable_network_not_connected, preference_find_best_rssi,
|
||||
preference_debug_connect, preference_debug_communication, preference_debug_readable_data, preference_debug_hex_data, preference_debug_command, preference_connect_mode
|
||||
};
|
||||
std::vector<char*> _bytePrefs =
|
||||
{
|
||||
|
||||
@@ -2190,6 +2190,56 @@ bool WebCfgServer::processArgs(PsychicRequest *request, String& message)
|
||||
//configChanged = true;
|
||||
}
|
||||
}
|
||||
else if(key == "DBGCONN")
|
||||
{
|
||||
if(_preferences->getBool(preference_debug_connect, false) != (value == "1"))
|
||||
{
|
||||
_preferences->putBool(preference_debug_connect, (value == "1"));
|
||||
Log->print(F("Setting changed: "));
|
||||
Log->println(key);
|
||||
configChanged = true;
|
||||
}
|
||||
}
|
||||
else if(key == "DBGCOMMU")
|
||||
{
|
||||
if(_preferences->getBool(preference_debug_communication, false) != (value == "1"))
|
||||
{
|
||||
_preferences->putBool(preference_debug_communication, (value == "1"));
|
||||
Log->print(F("Setting changed: "));
|
||||
Log->println(key);
|
||||
configChanged = true;
|
||||
}
|
||||
}
|
||||
else if(key == "DBGREAD")
|
||||
{
|
||||
if(_preferences->getBool(preference_debug_readable_data, false) != (value == "1"))
|
||||
{
|
||||
_preferences->putBool(preference_debug_readable_data, (value == "1"));
|
||||
Log->print(F("Setting changed: "));
|
||||
Log->println(key);
|
||||
configChanged = true;
|
||||
}
|
||||
}
|
||||
else if(key == "DBGHEX")
|
||||
{
|
||||
if(_preferences->getBool(preference_debug_hex_data, false) != (value == "1"))
|
||||
{
|
||||
_preferences->putBool(preference_debug_hex_data, (value == "1"));
|
||||
Log->print(F("Setting changed: "));
|
||||
Log->println(key);
|
||||
configChanged = true;
|
||||
}
|
||||
}
|
||||
else if(key == "DBGCOMM")
|
||||
{
|
||||
if(_preferences->getBool(preference_debug_command, false) != (value == "1"))
|
||||
{
|
||||
_preferences->putBool(preference_debug_command, (value == "1"));
|
||||
Log->print(F("Setting changed: "));
|
||||
Log->println(key);
|
||||
configChanged = true;
|
||||
}
|
||||
}
|
||||
else if(key == "ACLLVLCHANGED")
|
||||
{
|
||||
aclLvlChanged = true;
|
||||
@@ -2728,6 +2778,16 @@ bool WebCfgServer::processArgs(PsychicRequest *request, String& message)
|
||||
configChanged = true;
|
||||
}
|
||||
}
|
||||
else if(key == "CONNMODE")
|
||||
{
|
||||
if(_preferences->getBool(preference_connect_mode, false) != (value == "1"))
|
||||
{
|
||||
_preferences->putBool(preference_connect_mode, (value == "1"));
|
||||
Log->print(F("Setting changed: "));
|
||||
Log->println(key);
|
||||
configChanged = true;
|
||||
}
|
||||
}
|
||||
else if(key == "CREDUSER")
|
||||
{
|
||||
if(value == "#")
|
||||
@@ -3613,6 +3673,13 @@ esp_err_t WebCfgServer::buildAdvancedConfigHtml(PsychicRequest *request)
|
||||
}
|
||||
printInputField(&response, "OTAUPD", "Custom URL to update Nuki Hub updater", "", 255, "");
|
||||
printInputField(&response, "OTAMAIN", "Custom URL to update Nuki Hub", "", 255, "");
|
||||
|
||||
printCheckBox(&response, "DBGCONN", "Enable Nuki connect debug logging", _preferences->getBool(preference_debug_connect, false), "");
|
||||
printCheckBox(&response, "DBGCOMMU", "Enable Nuki communication debug logging", _preferences->getBool(preference_debug_communication, false), "");
|
||||
printCheckBox(&response, "DBGREAD", "Enable Nuki readable data debug logging", _preferences->getBool(preference_debug_readable_data, false), "");
|
||||
printCheckBox(&response, "DBGHEX", "Enable Nuki hex data debug logging", _preferences->getBool(preference_debug_hex_data, false), "");
|
||||
printCheckBox(&response, "DBGCOMM", "Enable Nuki command debug logging", _preferences->getBool(preference_debug_command, false), "");
|
||||
|
||||
response.print("</table>");
|
||||
|
||||
response.print("<br><input type=\"submit\" name=\"submit\" value=\"Save\">");
|
||||
@@ -3930,6 +3997,7 @@ esp_err_t WebCfgServer::buildNukiConfigHtml(PsychicRequest *request)
|
||||
response.print("<table>");
|
||||
printCheckBox(&response, "LOCKENA", "Nuki Lock enabled", _preferences->getBool(preference_lock_enabled), "");
|
||||
printCheckBox(&response, "OPENA", "Nuki Opener enabled", _preferences->getBool(preference_opener_enabled), "");
|
||||
printCheckBox(&response, "CONNMODE", "New Nuki Bluetooth connection mode (disable if there are connection issues)", _preferences->getBool(preference_connect_mode, false), "");
|
||||
response.print("</table><br>");
|
||||
response.print("<h3>Advanced Nuki Configuration</h3>");
|
||||
response.print("<table>");
|
||||
|
||||
31
src/main.cpp
31
src/main.cpp
@@ -7,6 +7,7 @@
|
||||
#include "esp_https_ota.h"
|
||||
#include "esp_task_wdt.h"
|
||||
#include "Config.h"
|
||||
#include "esp32-hal-log.h"
|
||||
|
||||
#ifndef NUKI_HUB_UPDATER
|
||||
#include "NukiWrapper.h"
|
||||
@@ -115,17 +116,31 @@ int _log_vprintf(const char *fmt, va_list args)
|
||||
void setReroute()
|
||||
{
|
||||
esp_log_set_vprintf(_log_vprintf);
|
||||
if(preferences->getBool(preference_mqtt_log_enabled))
|
||||
{
|
||||
esp_log_level_set("*", ESP_LOG_INFO);
|
||||
esp_log_level_set("mqtt", ESP_LOG_NONE);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
#ifdef DEBUG_NUKIHUB
|
||||
esp_log_level_set("*", ESP_LOG_DEBUG);
|
||||
esp_log_level_set("nvs", ESP_LOG_INFO);
|
||||
esp_log_level_set("wifi", ESP_LOG_INFO);
|
||||
#else
|
||||
esp_log_level_set("*", ESP_LOG_NONE);
|
||||
esp_log_level_set("httpd", ESP_LOG_ERROR);
|
||||
esp_log_level_set("httpd_sess", ESP_LOG_ERROR);
|
||||
esp_log_level_set("httpd_parse", ESP_LOG_ERROR);
|
||||
esp_log_level_set("httpd_txrx", ESP_LOG_ERROR);
|
||||
esp_log_level_set("httpd_uri", ESP_LOG_ERROR);
|
||||
esp_log_level_set("event", ESP_LOG_ERROR);
|
||||
esp_log_level_set("psychic", ESP_LOG_ERROR);
|
||||
esp_log_level_set("ARDUINO", ESP_LOG_DEBUG);
|
||||
esp_log_level_set("nvs", ESP_LOG_ERROR);
|
||||
esp_log_level_set("wifi", ESP_LOG_ERROR);
|
||||
|
||||
#endif
|
||||
|
||||
if(preferences->getBool(preference_mqtt_log_enabled))
|
||||
{
|
||||
esp_log_level_set("mqtt", ESP_LOG_NONE);
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -174,7 +189,7 @@ void networkTask(void *pvParameters)
|
||||
network->update();
|
||||
bool connected = network->isConnected();
|
||||
|
||||
#ifdef DEBUG_NUKIHUB
|
||||
#ifndef NUKI_HUB_UPDATER
|
||||
if(connected && reroute)
|
||||
{
|
||||
reroute = false;
|
||||
|
||||
Reference in New Issue
Block a user