Browse Source

Watchdog

pull/1367/head
Patrick Amrhein 1 year ago
parent
commit
28dbc8b224
  1. 43
      src/app.cpp
  2. 3
      src/app.h
  3. 2
      src/defines.h

43
src/app.cpp

@ -7,6 +7,8 @@
#include "app.h" #include "app.h"
#include "utils/sun.h" #include "utils/sun.h"
#define WDT_TIMEOUT_SECONDS 8 // Watchdog Timeout 8s
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
app::app() : ah::Scheduler {} {} app::app() : ah::Scheduler {} {}
@ -18,6 +20,11 @@ void app::setup() {
while (!Serial) while (!Serial)
yield(); yield();
#if defined(ESP32)
esp_task_wdt_init(WDT_TIMEOUT_SECONDS, true);
esp_task_wdt_add(NULL);
#endif
resetSystem(); resetSystem();
mSettings.setup(); mSettings.setup();
@ -30,6 +37,10 @@ void app::setup() {
else else
DBGPRINTLN(F("false")); DBGPRINTLN(F("false"));
#if defined(ESP32)
esp_task_wdt_reset();
#endif
if(mConfig->nrf.enabled) { if(mConfig->nrf.enabled) {
mNrfRadio.setup(&mConfig->serial.debug, &mConfig->serial.privacyLog, &mConfig->serial.printWholeTrace, mConfig->nrf.pinIrq, mConfig->nrf.pinCe, mConfig->nrf.pinCs, mConfig->nrf.pinSclk, mConfig->nrf.pinMosi, mConfig->nrf.pinMiso); mNrfRadio.setup(&mConfig->serial.debug, &mConfig->serial.privacyLog, &mConfig->serial.printWholeTrace, mConfig->nrf.pinIrq, mConfig->nrf.pinCe, mConfig->nrf.pinCs, mConfig->nrf.pinSclk, mConfig->nrf.pinMosi, mConfig->nrf.pinMiso);
} }
@ -50,6 +61,10 @@ void app::setup() {
#endif #endif
#endif /* defined(ETHERNET) */ #endif /* defined(ETHERNET) */
#if defined(ESP32)
esp_task_wdt_reset();
#endif
mCommunication.setup(&mTimestamp, &mConfig->serial.debug, &mConfig->serial.privacyLog, &mConfig->serial.printWholeTrace, &mConfig->inst.gapMs); mCommunication.setup(&mTimestamp, &mConfig->serial.debug, &mConfig->serial.privacyLog, &mConfig->serial.printWholeTrace, &mConfig->inst.gapMs);
mCommunication.addPayloadListener(std::bind(&app::payloadEventListener, this, std::placeholders::_1, std::placeholders::_2)); mCommunication.addPayloadListener(std::bind(&app::payloadEventListener, this, std::placeholders::_1, std::placeholders::_2));
#if defined(ENABLE_MQTT) #if defined(ENABLE_MQTT)
@ -65,6 +80,10 @@ void app::setup() {
DPRINTLN(DBG_WARN, F("WARNING! your NRF24 module can't be reached, check the wiring")); DPRINTLN(DBG_WARN, F("WARNING! your NRF24 module can't be reached, check the wiring"));
} }
#if defined(ESP32)
esp_task_wdt_reset();
#endif
// when WiFi is in client mode, then enable mqtt broker // when WiFi is in client mode, then enable mqtt broker
#if !defined(AP_ONLY) #if !defined(AP_ONLY)
#if defined(ENABLE_MQTT) #if defined(ENABLE_MQTT)
@ -78,11 +97,19 @@ void app::setup() {
#endif #endif
setupLed(); setupLed();
#if defined(ESP32)
esp_task_wdt_reset();
#endif
mWeb.setup(this, &mSys, mConfig); mWeb.setup(this, &mSys, mConfig);
mWeb.setProtection(strlen(mConfig->sys.adminPwd) != 0); mWeb.setProtection(strlen(mConfig->sys.adminPwd) != 0);
mApi.setup(this, &mSys, mWeb.getWebSrvPtr(), mConfig); mApi.setup(this, &mSys, mWeb.getWebSrvPtr(), mConfig);
#if defined(ESP32)
esp_task_wdt_reset();
#endif
#ifdef ENABLE_SYSLOG #ifdef ENABLE_SYSLOG
mDbgSyslog.setup(mConfig); // be sure to init after mWeb.setup (webSerial uses also debug callback) mDbgSyslog.setup(mConfig); // be sure to init after mWeb.setup (webSerial uses also debug callback)
#endif #endif
@ -96,12 +123,20 @@ void app::setup() {
#endif #endif
#endif #endif
#if defined(ESP32)
esp_task_wdt_reset();
#endif
#if defined(ENABLE_HISTORY) #if defined(ENABLE_HISTORY)
mHistory.setup(this, &mSys, mConfig, &mTimestamp); mHistory.setup(this, &mSys, mConfig, &mTimestamp);
#endif /*ENABLE_HISTORY*/ #endif /*ENABLE_HISTORY*/
mPubSerial.setup(mConfig, &mSys, &mTimestamp); mPubSerial.setup(mConfig, &mSys, &mTimestamp);
#if defined(ESP32)
esp_task_wdt_reset();
#endif
#if !defined(ETHERNET) #if !defined(ETHERNET)
//mImprov.setup(this, mConfig->sys.deviceName, mVersion); //mImprov.setup(this, mConfig->sys.deviceName, mVersion);
#endif #endif
@ -118,6 +153,10 @@ void app::setup() {
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void app::loop(void) { void app::loop(void) {
#if defined(ESP32)
esp_task_wdt_reset();
#endif
if(mConfig->nrf.enabled) if(mConfig->nrf.enabled)
mNrfRadio.loop(); mNrfRadio.loop();
#if defined(ESP32) #if defined(ESP32)
@ -125,6 +164,10 @@ void app::loop(void) {
mCmtRadio.loop(); mCmtRadio.loop();
#endif #endif
#if defined(ESP32)
esp_task_wdt_reset();
#endif
ah::Scheduler::loop(); ah::Scheduler::loop();
mCommunication.loop(); mCommunication.loop();

3
src/app.h

@ -8,6 +8,9 @@
#include <Arduino.h> #include <Arduino.h>
#include <ArduinoJson.h> #include <ArduinoJson.h>
#if defined(ESP32)
#include <esp_task_wdt.h>
#endif
#include "config/settings.h" #include "config/settings.h"
#include "defines.h" #include "defines.h"

2
src/defines.h

@ -13,7 +13,7 @@
//------------------------------------- //-------------------------------------
#define VERSION_MAJOR 0 #define VERSION_MAJOR 0
#define VERSION_MINOR 8 #define VERSION_MINOR 8
#define VERSION_PATCH 56 #define VERSION_PATCH 560001
//------------------------------------- //-------------------------------------
typedef struct { typedef struct {

Loading…
Cancel
Save