Added option to disable update check. #255

This commit is contained in:
Robert Strouse 2024-01-31 10:14:33 -08:00
parent a81d1b843d
commit 8bdfd214b5
8 changed files with 23 additions and 7 deletions

View file

@ -7,7 +7,7 @@
extern Preferences pref;
#define SHADE_HDR_VER 19
#define SHADE_HDR_VER 20
#define SHADE_HDR_SIZE 66
#define SHADE_REC_SIZE 276
#define GROUP_REC_SIZE 194
@ -603,6 +603,7 @@ bool ShadeConfigFile::readTransRecord(transceiver_config_t &cfg) {
}
bool ShadeConfigFile::readSettingsRecord() {
if(this->header.settingsRecordSize > 0) {
uint32_t startPos = this->file.position();
Serial.println("Reading settings from file...");
char ver[24];
this->readVarString(ver, sizeof(ver));
@ -610,6 +611,11 @@ bool ShadeConfigFile::readSettingsRecord() {
this->readVarString(settings.NTP.ntpServer, sizeof(settings.NTP.ntpServer));
this->readVarString(settings.NTP.posixZone, sizeof(settings.NTP.posixZone));
settings.ssdpBroadcast = this->readBool(false);
if(this->header.version >= 20) settings.checkForUpdate = this->readBool(true);
if(this->file.position() != startPos + this->header.settingsRecordSize) {
Serial.println("Reading to end of settings record");
this->seekChar(CFG_REC_END);
}
}
return true;
}
@ -872,7 +878,8 @@ bool ShadeConfigFile::writeSettingsRecord() {
this->writeVarString(settings.hostname);
this->writeVarString(settings.NTP.ntpServer);
this->writeVarString(settings.NTP.posixZone);
this->writeBool(settings.ssdpBroadcast, CFG_REC_END);
this->writeBool(settings.ssdpBroadcast);
this->writeBool(settings.checkForUpdate, CFG_REC_END);
return true;
}
bool ShadeConfigFile::writeNetRecord() {

View file

@ -188,6 +188,7 @@ bool ConfigSettings::load() {
pref.begin("CFG");
pref.getString("hostname", this->hostname, sizeof(this->hostname));
this->ssdpBroadcast = pref.getBool("ssdpBroadcast", true);
this->checkForUpdate = pref.getBool("checkForUpdate", true);
this->connType = static_cast<conn_types>(pref.getChar("connType", 0x00));
//Serial.printf("Preference GFG Free Entries: %d\n", pref.freeEntries());
pref.end();
@ -220,6 +221,7 @@ bool ConfigSettings::save() {
pref.putString("hostname", this->hostname);
pref.putBool("ssdpBroadcast", this->ssdpBroadcast);
pref.putChar("connType", static_cast<uint8_t>(this->connType));
pref.putBool("checkForUpdate", this->checkForUpdate);
pref.end();
return true;
}
@ -228,6 +230,7 @@ bool ConfigSettings::toJSON(JsonObject &obj) {
obj["hostname"] = this->hostname;
obj["connType"] = static_cast<uint8_t>(this->connType);
obj["chipModel"] = this->chipModel;
obj["checkForUpdate"] = this->checkForUpdate;
return true;
}
bool ConfigSettings::requiresAuth() { return this->Security.type != security_types::None; }
@ -235,6 +238,7 @@ bool ConfigSettings::fromJSON(JsonObject &obj) {
if(obj.containsKey("ssdpBroadcast")) this->ssdpBroadcast = obj["ssdpBroadcast"];
if(obj.containsKey("hostname")) this->parseValueString(obj, "hostname", this->hostname, sizeof(this->hostname));
if(obj.containsKey("connType")) this->connType = static_cast<conn_types>(obj["connType"].as<uint8_t>());
if(obj.containsKey("checkForUpdate")) this->checkForUpdate = obj["checkForUpdate"];
return true;
}
void ConfigSettings::print() {
@ -251,7 +255,8 @@ uint16_t ConfigSettings::calcSettingsRecSize() {
+ strlen(this->hostname) + 3
+ strlen(this->NTP.ntpServer) + 3
+ strlen(this->NTP.posixZone) + 3
+ 6; // ssdpbroadcast
+ 6 // ssdpbroadcast
+ 6; // updateCheck
}
uint16_t ConfigSettings::calcNetRecSize() {
return 4 // connType

View file

@ -245,7 +245,8 @@ void GitUpdater::loop() {
//this->lastCheck = millis();
//else
if(settings.checkForUpdate &&
(this->lastCheck + 14400000 < millis() || this->lastCheck == 0) && !rebootDelay.reboot) { // 4 hours
//(this->lastCheck + 14400000 < millis() || this->lastCheck == 0) && !rebootDelay.reboot) { // 4 hours
(this->lastCheck + 86400000 < millis() || this->lastCheck == 0) && !rebootDelay.reboot) { // 1 day
this->checkForUpdate();
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -2212,10 +2212,10 @@ void Web::begin() {
HTTPMethod method = server.method();
if (method == HTTP_POST || method == HTTP_PUT) {
// Parse out all the inputs.
if (obj.containsKey("hostname") || obj.containsKey("ssdpBroadcast")) {
if (obj.containsKey("hostname") || obj.containsKey("ssdpBroadcast") || obj.containsKey("checkForUpdate")) {
settings.fromJSON(obj);
settings.save();
net.updateHostname();
if(obj.containsKey("hostname")) net.updateHostname();
}
if (obj.containsKey("ntpServer") || obj.containsKey("ntpServer")) {
settings.NTP.fromJSON(obj);

View file

@ -53,6 +53,10 @@
<input id="cbSsdpBroadcast" name="ssdpBroadcast" type="checkbox" data-bind="general.ssdpBroadcast" style="display:inline-block;" />
<label for="cbSsdpBroadcast" style="display:inline-block;cursor:pointer;">Broadcast uPnP over SSDP</label>
</div>
<div class="field-group">
<input id="cbCheckForUpdate" type="checkbox" data-bind="general.checkForUpdate" style="display:inline-block;" />
<label for="cbCheckForUpdate" style="display:inline-block;cursor:pointer;">Auto Check for Updates</label>
</div>
<div class="button-container">
<button id="btnSaveGeneral" type="button" onclick="general.setGeneral();">
Save
@ -123,7 +127,6 @@
<span style="text-align:right;display:inline-block;color:#00bcd4;width:127px;">Application:</span>
<span id="spanAppVersion" style="padding-left:4px;display:inline-block;text-align:left;width:120px;">v-.--</span>
</div>
<div class="button-container">
<button id="btnUpdateGithub" type="button" onclick="firmware.updateGithub();">
<i class="icss-github-o" style="font-size:1.7em;margin-top:-14px;margin-bottom:-10px;margin-right:7px;"></i><span>Github Update</span>