Added JSON driven watchdog
This commit is contained in:
parent
3e4ce429c7
commit
8a237059fd
|
@ -215,6 +215,7 @@ bool bBTconnected = false;
|
|||
long BootTime;
|
||||
|
||||
hw_timer_t *watchdogTimer = NULL;
|
||||
hw_timer_t *JSONwatchdog = NULL;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Bluetooth instantiation
|
||||
|
@ -455,6 +456,11 @@ void setup() {
|
|||
timerAlarmEnable(watchdogTimer); //enable interrupt
|
||||
#endif
|
||||
|
||||
JSONwatchdog = timerBegin(1, 80, true);
|
||||
timerAlarmWrite(JSONwatchdog, 60000000, false); //set time in uS must be fed within this time or reboot
|
||||
timerAttachInterrupt(JSONwatchdog, &interruptReboot, true);
|
||||
timerAlarmDisable(JSONwatchdog); //disable interrupt for now
|
||||
|
||||
FilteredSamples.ipVolts.setRounding(0.1);
|
||||
FilteredSamples.GlowAmps.setRounding(0.01);
|
||||
FilteredSamples.GlowVolts.setRounding(0.1);
|
||||
|
@ -1611,6 +1617,19 @@ void feedWatchdog()
|
|||
timerAlarmWrite(watchdogTimer, 15000000, false); //set time in uS must be fed within this time or reboot
|
||||
}
|
||||
|
||||
void doJSONwatchdog(int topup)
|
||||
{
|
||||
if(topup) {
|
||||
timerWrite(JSONwatchdog, 0); //reset timer (feed watchdog)
|
||||
uint64_t deathtime = topup * 1000000;
|
||||
timerAlarmWrite(JSONwatchdog, deathtime, false); //set time in uS must be fed within this time or reboot
|
||||
timerAlarmEnable(JSONwatchdog); //enable interrupt
|
||||
}
|
||||
else {
|
||||
timerAlarmDisable(JSONwatchdog); //disable interrupt
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void doStreaming()
|
||||
{
|
||||
|
|
|
@ -144,6 +144,9 @@ void interpretJsonCommand(char* pLine)
|
|||
if(it->value.as<int>() == 8861)
|
||||
saveNV();
|
||||
}
|
||||
else if(strcmp("Watchdog", it->key) == 0) {
|
||||
doJSONwatchdog(it->value.as<int>());
|
||||
}
|
||||
else if(strcmp("DateTime", it->key) == 0) {
|
||||
setDateTime(it->value.as<const char*>());
|
||||
bTriggerDateTime = true;
|
||||
|
|
|
@ -426,11 +426,11 @@ sMQTTparams::load()
|
|||
// **** MAX LENGTH is 15 for names ****
|
||||
preferences.begin("mqtt", false);
|
||||
validatedLoad("enabled", enabled, 0, u8inBounds, 0, 1);
|
||||
validatedLoad("port", port, 0, u16inBounds, 0, 0xffff);
|
||||
validatedLoad("port", port, 1883, u16inBounds, 0, 0xffff);
|
||||
validatedLoad("qos", qos, 0, u8inBounds, 0, 2);
|
||||
validatedLoad("host", host, 127, "hostIP");
|
||||
validatedLoad("username", username, 31, "username");
|
||||
validatedLoad("password", password, 31, "password");
|
||||
validatedLoad("host", host, 127, "");
|
||||
validatedLoad("username", username, 31, "");
|
||||
validatedLoad("password", password, 31, "");
|
||||
validatedLoad("topic", topic, 31, "Afterburner");
|
||||
preferences.end();
|
||||
}
|
||||
|
|
|
@ -223,7 +223,7 @@ struct sMQTTparams : public CESP32_NVStorage {
|
|||
char topic[32];
|
||||
void init() {
|
||||
enabled = false;
|
||||
port = 1234;
|
||||
port = 1883;
|
||||
qos = 0;
|
||||
memset(host, 0, 128);
|
||||
memset(username, 0, 32);
|
||||
|
|
|
@ -86,6 +86,7 @@ extern float getGlowVolts();
|
|||
extern float getGlowCurrent();
|
||||
extern float getFanSpeed();
|
||||
extern int sysUptime();
|
||||
extern void doJSONwatchdog(int topup);
|
||||
|
||||
void setSSID(const char* name);
|
||||
void setAPpassword(const char* name);
|
||||
|
|
Loading…
Reference in a new issue