From 05e0292c320c2963d404dafa0b749de98eb8467e Mon Sep 17 00:00:00 2001 From: Tommy van der Vorst Date: Sun, 5 Jan 2025 14:01:48 +0100 Subject: [PATCH] feat: add setting to disable periodic check for PIC firmware updates When connected to networks without internet access or properly working DNS, the periodic check can cause the device to hang and the watchdog to kick in. --- OTGW-firmware.h | 1 + OTGW-firmware.ino | 2 +- data/index.js | 1 + restAPI.ino | 1 + settingStuff.ino | 8 +++++++- 5 files changed, 11 insertions(+), 2 deletions(-) diff --git a/OTGW-firmware.h b/OTGW-firmware.h index 6a9b998..6ea78d2 100644 --- a/OTGW-firmware.h +++ b/OTGW-firmware.h @@ -106,6 +106,7 @@ bool bCheckOTGWPICupdate = true; //All things that are settings String settingHostname = _HOSTNAME; +bool settingOTGWPICautoUpdate = true; //MQTT settings bool statusMQTTconnection = false; diff --git a/OTGW-firmware.ino b/OTGW-firmware.ino index 245acc2..64e6d97 100644 --- a/OTGW-firmware.ino +++ b/OTGW-firmware.ino @@ -285,7 +285,7 @@ void do5minevent(){ sendMQTTuptime(); sendMQTTversioninfo(); sendMQTTstateinformation(); - if (bCheckOTGWPICupdate) { + if (settingOTGWPICautoUpdate && bCheckOTGWPICupdate) { bCheckOTGWPICupdate = false; checkOTWGpicforupdate(); } diff --git a/data/index.js b/data/index.js index 5ad5ea6..c4dc3c0 100644 --- a/data/index.js +++ b/data/index.js @@ -810,6 +810,7 @@ ,[ "gpiooutputsenabled", "GPIO Output Enabled"] ,[ "gpiooutputspin", "GPIO pin # to switch on/off"] ,[ "gpiooutputstriggerbit", "Bit X (master/slave) to trigger on (0-15)"] + ,[ "otgwpicautoupdate", "Automatically check for PIC firmware update"] ]; diff --git a/restAPI.ino b/restAPI.ino index 7c1595b..23ca0e9 100644 --- a/restAPI.ino +++ b/restAPI.ino @@ -455,6 +455,7 @@ void sendDeviceSettings() sendJsonSettingObj("gpiooutputstriggerbit", settingGPIOOUTPUTStriggerBit, "i", 0,16); sendJsonSettingObj("otgwcommandenable", settingOTGWcommandenable, "b"); sendJsonSettingObj("otgwcommands", CSTR(settingOTGWcommands), "s", 128); + sendJsonSettingObj("otgwpicautoupdate", settingOTGWPICautoUpdate, "b"); sendEndJsonObj("settings"); diff --git a/settingStuff.ino b/settingStuff.ino index 283c646..893712f 100644 --- a/settingStuff.ino +++ b/settingStuff.ino @@ -57,6 +57,7 @@ void writeSettings(bool show) root["GPIOOUTPUTSenabled"] = settingGPIOOUTPUTSenabled; root["GPIOOUTPUTSpin"] = settingGPIOOUTPUTSpin; root["GPIOOUTPUTStriggerBit"] = settingGPIOOUTPUTStriggerBit; + root["OTGWPICautoUpdate"] = settingOTGWPICautoUpdate; serializeJsonPretty(root, file); Debugln(F("... done!")); @@ -94,7 +95,8 @@ void readSettings(bool show) // Copy values from the JsonDocument to the Config settingHostname = doc["hostname"].as(); if (settingHostname.length()==0) settingHostname = _HOSTNAME; - settingMQTTenable = doc["MQTTenable"]|settingMQTTenable; + settingMQTTenable = doc["MQTTenable"]|settingMQTTenable; + settingOTGWPICautoUpdate = doc["OTGWPICautoUpdate"] | settingOTGWPICautoUpdate; settingMQTTbroker = doc["MQTTbroker"].as(); settingMQTTbrokerPort = doc["MQTTbrokerPort"]; //default port settingMQTTuser = doc["MQTTuser"].as(); @@ -168,6 +170,7 @@ void readSettings(bool show) Debugf("GPIO Outputs : %s\r\n", CBOOLEAN(settingGPIOOUTPUTSenabled)); Debugf("GPIO Out. Pin : %d\r\n", settingGPIOOUTPUTSpin); Debugf("GPIO Out. Trg. Bit : %d\r\n", settingGPIOOUTPUTStriggerBit); + Debugf("PIC autoupdate enabled: %s\r\n", CBOOLEAN(settingOTGWPICautoUpdate)); } Debugln(F("-\r\n")); @@ -293,6 +296,9 @@ void updateSetting(const char *field, const char *newValue) DebugTf(PSTR("Need reboot before GPIO OUTPUTS will use new trigger bit %d!\r\n\n"), settingGPIOOUTPUTStriggerBit); } + if (strcasecmp(field, "OTGWPICautoUpdate") == 0) + settingOTGWPICautoUpdate = EVALBOOLEAN(newValue); + //finally update write settings writeSettings(false);