Added SW watchdog
This commit is contained in:
parent
843c382325
commit
da33a02844
|
@ -110,6 +110,7 @@
|
|||
#if USE_SPIFFS == 1
|
||||
#include <SPIFFS.h>
|
||||
#endif
|
||||
//#include "esp_system.h"
|
||||
|
||||
//#define AP_SSID "Afterburner"
|
||||
//#define AP_PASSWORD "thereisnospoon"
|
||||
|
@ -189,6 +190,8 @@ bool bUpdateDisplay = false;
|
|||
bool bHaveWebClient = false;
|
||||
bool bBTconnected = false;
|
||||
|
||||
hw_timer_t *watchdogTimer = NULL;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Bluetooth instantiation
|
||||
//
|
||||
|
@ -295,6 +298,12 @@ void listDir(fs::FS &fs, const char * dirname, uint8_t levels)
|
|||
}
|
||||
#endif
|
||||
|
||||
void interruptReboot()
|
||||
{
|
||||
ets_printf("Software watchdog reboot......\r\n");
|
||||
esp_restart();
|
||||
}
|
||||
|
||||
void setup() {
|
||||
char msg[128];
|
||||
TempSensor.begin();
|
||||
|
@ -424,6 +433,14 @@ void setup() {
|
|||
|
||||
setupGPIO();
|
||||
|
||||
#if USE_SW_WATCHDOG == 1
|
||||
// create a watchdog timer
|
||||
watchdogTimer = timerBegin(0, 80, true); //timer 0, divisor 80
|
||||
timerAlarmWrite(watchdogTimer, 4000000, false); //set time in uS must be fed within this time or reboot
|
||||
timerAttachInterrupt(watchdogTimer, &interruptReboot, true);
|
||||
timerAlarmEnable(watchdogTimer); //enable interrupt
|
||||
#endif
|
||||
|
||||
delay(1000); // just to hold the splash screeen for while
|
||||
}
|
||||
|
||||
|
@ -546,6 +563,10 @@ void loop()
|
|||
|
||||
case CommStates::Idle:
|
||||
|
||||
#if USE_SW_WATCHDOG == 1
|
||||
timerWrite(watchdogTimer, 0); //reset timer (feed watchdog)
|
||||
#endif
|
||||
|
||||
moderator = 50;
|
||||
|
||||
#if RX_LED == 1
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include <Arduino.h>
|
||||
#include "NVCore.h"
|
||||
#include "DebugPort.h"
|
||||
#include <functional>
|
||||
|
||||
|
||||
bool
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include <Preferences.h>
|
||||
#include <functional>
|
||||
|
||||
|
||||
bool u8inBounds(uint8_t test, uint8_t minLim, uint8_t maxLim);
|
||||
bool s8inBounds(int8_t test, int8_t minLim, int8_t maxLim);
|
||||
bool u8Match2(uint8_t test, uint8_t test1, uint8_t test2);
|
||||
|
|
|
@ -113,7 +113,7 @@ bool initWifi(int initpin,const char *failedssid, const char *failedpassword)
|
|||
// if you get here you have connected to the WiFi
|
||||
isSTA = true;
|
||||
DebugPort.println("WiFiManager connected in STA mode OK");
|
||||
DebugPort.printf(" STA IP address: %s\r\n", WiFi.localIP());
|
||||
DebugPort.printf(" STA IP address: %s\r\n", WiFi.localIP().toString().c_str());
|
||||
// must use same radio channel as STA to go to STA+AP, otherwise we drop the STA!
|
||||
chnl = WiFi.channel();
|
||||
DebugPort.println("Now promoting to STA+AP mode...");
|
||||
|
@ -128,7 +128,7 @@ bool initWifi(int initpin,const char *failedssid, const char *failedpassword)
|
|||
WiFi.softAP(APname, failedpassword, chnl);
|
||||
WiFi.enableAP(true);
|
||||
DebugPort.printf(" AP SSID: %s\r\n", WiFi.softAPgetHostname());
|
||||
DebugPort.printf(" AP IP address: %s\r\n", WiFi.softAPIP());
|
||||
DebugPort.printf(" AP IP address: %s\r\n", WiFi.softAPIP().toString().c_str());
|
||||
DebugPort.printf("WifiMode after initWifi = %d\r\n", WiFi.getMode());
|
||||
#endif
|
||||
|
||||
|
|
|
@ -107,3 +107,9 @@
|
|||
// Protocol exploration
|
||||
//
|
||||
//#define PROTOCOL_INVESTIGATION
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Software base watchdog
|
||||
//
|
||||
#define USE_SW_WATCHDOG 1
|
||||
|
||||
|
|
Binary file not shown.
Loading…
Reference in a new issue