From 083e83d9779b9f46ac065fabbcbc5467647191db Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 21 Dec 2024 21:25:43 +0100 Subject: [PATCH] Improve BLE and BLE debug logging --- lib/nuki_ble | 2 +- platformio.ini | 2 +- sdkconfig.defaults | 4 +--- sdkconfig.defaults.esp32 | 4 ---- sdkconfig.release.defaults | 6 +++--- src/NukiOpenerWrapper.cpp | 9 ++------- src/NukiWrapper.cpp | 7 +------ src/main.cpp | 15 ++++++++++----- updater/platformio.ini | 7 ------- 9 files changed, 19 insertions(+), 37 deletions(-) diff --git a/lib/nuki_ble b/lib/nuki_ble index 40840cd..90e482b 160000 --- a/lib/nuki_ble +++ b/lib/nuki_ble @@ -1 +1 @@ -Subproject commit 40840cd123d5e00ae48fde856a23c161d875b4c6 +Subproject commit 90e482b3d45d4cc1d585569b669ab92052a4008c diff --git a/platformio.ini b/platformio.ini index d25e7ae..37ddf68 100644 --- a/platformio.ini +++ b/platformio.ini @@ -77,7 +77,7 @@ extra_scripts = post:pio_package_post.py build_flags = ${env.build_flags} - -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG + -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_NONE -DCONFIG_NIMBLE_CPP_LOG_LEVEL=0 -DCONFIG_BT_NIMBLE_LOG_LEVEL=0 diff --git a/sdkconfig.defaults b/sdkconfig.defaults index f21f8ec..3465515 100644 --- a/sdkconfig.defaults +++ b/sdkconfig.defaults @@ -86,7 +86,6 @@ 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 @@ -106,5 +105,4 @@ CONFIG_HTTPD_PURGE_BUF_LEN=32 CONFIG_HTTPD_WS_SUPPORT=y CONFIG_ESP_HTTPS_SERVER_ENABLE=n CONFIG_BOOTLOADER_WDT_DISABLE_IN_USER_CODE=y -CONFIG_BOOTLOADER_WDT_TIME_MS=90000 -CONFIG_LOG_MASTER_LEVEL=y \ No newline at end of file +CONFIG_BOOTLOADER_WDT_TIME_MS=120000 \ No newline at end of file diff --git a/sdkconfig.defaults.esp32 b/sdkconfig.defaults.esp32 index 6458317..5db25de 100644 --- a/sdkconfig.defaults.esp32 +++ b/sdkconfig.defaults.esp32 @@ -4,7 +4,3 @@ CONFIG_MBEDTLS_DEFAULT_MEM_ALLOC=y CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_DEFAULT=y CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=4096 CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=50768 -CONFIG_LOG_DEFAULT_LEVEL_NONE=y -CONFIG_LOG_DEFAULT_LEVEL=0 -CONFIG_ESP_IPC_TASK_STACK_SIZE=1024 -CORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_NONE diff --git a/sdkconfig.release.defaults b/sdkconfig.release.defaults index 9d2a2eb..7127d99 100644 --- a/sdkconfig.release.defaults +++ b/sdkconfig.release.defaults @@ -1,5 +1,5 @@ -CONFIG_LOG_DEFAULT_LEVEL_DEBUG=y -CONFIG_LOG_DEFAULT_LEVEL=4 -CONFIG_ESP_IPC_TASK_STACK_SIZE=2048 +CONFIG_LOG_DEFAULT_LEVEL_NONE=y +CONFIG_LOG_DEFAULT_LEVEL=0 +CONFIG_ESP_IPC_TASK_STACK_SIZE=1024 CONFIG_BOOTLOADER_LOG_LEVEL_ERROR=y CONFIG_BOOTLOADER_LOG_LEVEL=1 \ No newline at end of file diff --git a/src/NukiOpenerWrapper.cpp b/src/NukiOpenerWrapper.cpp index fdc361b..0698e3c 100644 --- a/src/NukiOpenerWrapper.cpp +++ b/src/NukiOpenerWrapper.cpp @@ -54,13 +54,8 @@ void NukiOpenerWrapper::initialize() _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)); - - if (_preferences->getBool(preference_debug_connect, false) || _preferences->getBool(preference_debug_communication, false) || _preferences->getBool(preference_debug_readable_data, false) || - _preferences->getBool(preference_debug_hex_data, false) || _preferences->getBool(preference_debug_command, false)) - { - esp_log_set_level_master(ESP_LOG_DEBUG); - } - + _nukiOpener.registerLogger(Log); + _nukiOpener.initialize(_preferences->getBool(preference_connect_mode, true)); _nukiOpener.registerBleScanner(_bleScanner); _nukiOpener.setEventHandler(this); diff --git a/src/NukiWrapper.cpp b/src/NukiWrapper.cpp index dfac659..723b09b 100644 --- a/src/NukiWrapper.cpp +++ b/src/NukiWrapper.cpp @@ -55,12 +55,7 @@ void NukiWrapper::initialize() _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)); - - if (_preferences->getBool(preference_debug_connect, false) || _preferences->getBool(preference_debug_communication, false) || _preferences->getBool(preference_debug_readable_data, false) || - _preferences->getBool(preference_debug_hex_data, false) || _preferences->getBool(preference_debug_command, false)) - { - esp_log_set_level_master(ESP_LOG_DEBUG); - } + _nukiLock.registerLogger(Log); _nukiLock.initialize(_preferences->getBool(preference_connect_mode, true)); _nukiLock.registerBleScanner(_bleScanner); diff --git a/src/main.cpp b/src/main.cpp index e010e17..56c0ea2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -8,6 +8,7 @@ #include "esp_task_wdt.h" #include "Config.h" #include "esp32-hal-log.h" +#include "hal/wdt_hal.h" #ifndef NUKI_HUB_UPDATER #include "NukiWrapper.h" @@ -110,7 +111,7 @@ int _log_vprintf(const char *fmt, va_list args) { Log->write((uint8_t *)log_print_buffer, (size_t)ret); } - return 0; //return vprintf(fmt, args); + return 0; } void setReroute() @@ -122,6 +123,7 @@ void setReroute() 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); @@ -133,7 +135,7 @@ void setReroute() 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)) @@ -352,6 +354,12 @@ esp_err_t _http_event_handler(esp_http_client_event_t *evt) Log->println("HTTP_EVENT_REDIRECT"); break; } + + wdt_hal_context_t rtc_wdt_ctx = RWDT_HAL_CONTEXT_DEFAULT(); + wdt_hal_write_protect_disable(&rtc_wdt_ctx); + wdt_hal_feed(&rtc_wdt_ctx); + wdt_hal_write_protect_enable(&rtc_wdt_ctx); + return ESP_OK; } @@ -461,9 +469,6 @@ void setupTasks(bool ota) void setup() { //Set Log level to error for all TAGS -#ifndef DEBUG_NUKIHUB - esp_log_set_level_master(ESP_LOG_ERROR); -#endif esp_log_level_set("*", ESP_LOG_ERROR); //Set Log level to none for mqtt TAG esp_log_level_set("mqtt", ESP_LOG_NONE); diff --git a/updater/platformio.ini b/updater/platformio.ini index b7e1e4a..b0c53b2 100644 --- a/updater/platformio.ini +++ b/updater/platformio.ini @@ -34,11 +34,6 @@ build_flags = -DESP32 -DARDUINO_ARCH_ESP32 -DUSE_ESP_IDF_LOG - -DCONFIG_ASYNC_TCP_MAX_ACK_TIME=3000 - -DCONFIG_ASYNC_TCP_PRIORITY=10 - -DCONFIG_ASYNC_TCP_RUNNING_CORE=1 - -DCONFIG_ASYNC_TCP_QUEUE_SIZE=128 - -DCONFIG_ASYNC_TCP_STACK_SIZE=24576 -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_NONE -DETH_SPI_SUPPORTS_NO_IRQ -DNUKI_HUB_UPDATER @@ -95,8 +90,6 @@ extends = env:updater_esp32 board = esp32-h2-devkitm-1 board_build.cmake_extra_args = -DNUKI_TARGET_H2=y -lib_deps = - PsychicHttp=symlink://../lib/PsychicHttp [env:updater_esp32-solo1] extends = env:updater_esp32