From c674cd252e7780913b801f51c4aaeb3d7dc3c841 Mon Sep 17 00:00:00 2001 From: iranl Date: Wed, 18 Dec 2024 22:23:37 +0100 Subject: [PATCH] RTC Watchdog --- sdkconfig.defaults | 4 +++- src/NukiNetwork.cpp | 9 +++++++++ src/NukiOpenerWrapper.cpp | 5 +++++ src/NukiWrapper.cpp | 5 +++++ 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/sdkconfig.defaults b/sdkconfig.defaults index 06bfb9c..6016c90 100644 --- a/sdkconfig.defaults +++ b/sdkconfig.defaults @@ -104,4 +104,6 @@ CONFIG_HTTPD_MAX_URI_LEN=512 CONFIG_HTTPD_ERR_RESP_NO_DELAY=y CONFIG_HTTPD_PURGE_BUF_LEN=32 CONFIG_HTTPD_WS_SUPPORT=y -CONFIG_ESP_HTTPS_SERVER_ENABLE=n \ No newline at end of file +CONFIG_ESP_HTTPS_SERVER_ENABLE=n +CONFIG_BOOTLOADER_WDT_DISABLE_IN_USER_CODE=y +CONFIG_BOOTLOADER_WDT_TIME_MS=90000 \ No newline at end of file diff --git a/src/NukiNetwork.cpp b/src/NukiNetwork.cpp index bac07da..07dc3ba 100644 --- a/src/NukiNetwork.cpp +++ b/src/NukiNetwork.cpp @@ -10,6 +10,7 @@ #include "networkDevices/WifiDevice.h" #endif #include "networkDevices/EthernetDevice.h" +#include "hal/wdt_hal.h" NukiNetwork* NukiNetwork::_inst = nullptr; @@ -225,6 +226,10 @@ void NukiNetwork::initialize() bool NukiNetwork::update() { + 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); _device->update(); return true; } @@ -367,6 +372,10 @@ void NukiNetwork::readSettings() bool NukiNetwork::update() { + 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); int64_t ts = espMillis(); _device->update(); diff --git a/src/NukiOpenerWrapper.cpp b/src/NukiOpenerWrapper.cpp index 6b65c37..f52249a 100644 --- a/src/NukiOpenerWrapper.cpp +++ b/src/NukiOpenerWrapper.cpp @@ -5,6 +5,7 @@ #include "RestartReason.h" #include #include "Config.h" +#include "hal/wdt_hal.h" NukiOpenerWrapper* nukiOpenerInst; Preferences* nukiOpenerPreferences = nullptr; @@ -183,6 +184,10 @@ void NukiOpenerWrapper::readSettings() void NukiOpenerWrapper::update() { + 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); if(!_paired) { Log->println(F("Nuki opener start pairing")); diff --git a/src/NukiWrapper.cpp b/src/NukiWrapper.cpp index db8a02c..0b065b5 100644 --- a/src/NukiWrapper.cpp +++ b/src/NukiWrapper.cpp @@ -5,6 +5,7 @@ #include "RestartReason.h" #include #include "Config.h" +#include "hal/wdt_hal.h" NukiWrapper* nukiInst = nullptr; @@ -190,6 +191,10 @@ void NukiWrapper::readSettings() void NukiWrapper::update() { + 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); if(!_paired) { Log->println(F("Nuki lock start pairing"));