Added JSON driven watchdog
This commit is contained in:
parent
3e4ce429c7
commit
8a237059fd
|
@ -215,6 +215,7 @@ bool bBTconnected = false;
|
||||||
long BootTime;
|
long BootTime;
|
||||||
|
|
||||||
hw_timer_t *watchdogTimer = NULL;
|
hw_timer_t *watchdogTimer = NULL;
|
||||||
|
hw_timer_t *JSONwatchdog = NULL;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Bluetooth instantiation
|
// Bluetooth instantiation
|
||||||
|
@ -455,6 +456,11 @@ void setup() {
|
||||||
timerAlarmEnable(watchdogTimer); //enable interrupt
|
timerAlarmEnable(watchdogTimer); //enable interrupt
|
||||||
#endif
|
#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.ipVolts.setRounding(0.1);
|
||||||
FilteredSamples.GlowAmps.setRounding(0.01);
|
FilteredSamples.GlowAmps.setRounding(0.01);
|
||||||
FilteredSamples.GlowVolts.setRounding(0.1);
|
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
|
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()
|
void doStreaming()
|
||||||
{
|
{
|
||||||
|
|
|
@ -144,6 +144,9 @@ void interpretJsonCommand(char* pLine)
|
||||||
if(it->value.as<int>() == 8861)
|
if(it->value.as<int>() == 8861)
|
||||||
saveNV();
|
saveNV();
|
||||||
}
|
}
|
||||||
|
else if(strcmp("Watchdog", it->key) == 0) {
|
||||||
|
doJSONwatchdog(it->value.as<int>());
|
||||||
|
}
|
||||||
else if(strcmp("DateTime", it->key) == 0) {
|
else if(strcmp("DateTime", it->key) == 0) {
|
||||||
setDateTime(it->value.as<const char*>());
|
setDateTime(it->value.as<const char*>());
|
||||||
bTriggerDateTime = true;
|
bTriggerDateTime = true;
|
||||||
|
|
|
@ -426,11 +426,11 @@ sMQTTparams::load()
|
||||||
// **** MAX LENGTH is 15 for names ****
|
// **** MAX LENGTH is 15 for names ****
|
||||||
preferences.begin("mqtt", false);
|
preferences.begin("mqtt", false);
|
||||||
validatedLoad("enabled", enabled, 0, u8inBounds, 0, 1);
|
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("qos", qos, 0, u8inBounds, 0, 2);
|
||||||
validatedLoad("host", host, 127, "hostIP");
|
validatedLoad("host", host, 127, "");
|
||||||
validatedLoad("username", username, 31, "username");
|
validatedLoad("username", username, 31, "");
|
||||||
validatedLoad("password", password, 31, "password");
|
validatedLoad("password", password, 31, "");
|
||||||
validatedLoad("topic", topic, 31, "Afterburner");
|
validatedLoad("topic", topic, 31, "Afterburner");
|
||||||
preferences.end();
|
preferences.end();
|
||||||
}
|
}
|
||||||
|
|
|
@ -223,7 +223,7 @@ struct sMQTTparams : public CESP32_NVStorage {
|
||||||
char topic[32];
|
char topic[32];
|
||||||
void init() {
|
void init() {
|
||||||
enabled = false;
|
enabled = false;
|
||||||
port = 1234;
|
port = 1883;
|
||||||
qos = 0;
|
qos = 0;
|
||||||
memset(host, 0, 128);
|
memset(host, 0, 128);
|
||||||
memset(username, 0, 32);
|
memset(username, 0, 32);
|
||||||
|
|
|
@ -86,6 +86,7 @@ extern float getGlowVolts();
|
||||||
extern float getGlowCurrent();
|
extern float getGlowCurrent();
|
||||||
extern float getFanSpeed();
|
extern float getFanSpeed();
|
||||||
extern int sysUptime();
|
extern int sysUptime();
|
||||||
|
extern void doJSONwatchdog(int topup);
|
||||||
|
|
||||||
void setSSID(const char* name);
|
void setSSID(const char* name);
|
||||||
void setAPpassword(const char* name);
|
void setAPpassword(const char* name);
|
||||||
|
|
Loading…
Reference in a new issue