Improve message, tidy up

This commit is contained in:
tjfsteele 2021-02-19 11:44:45 +00:00
parent 610f56d7c7
commit c8b6c08409
2 changed files with 8 additions and 15 deletions

View File

@ -1182,8 +1182,8 @@ void fwupgradestart(const char *hexfile) {
}
}
bool checkforupdatepic(String filename, String version){
WiFiClient client;
String checkforupdatepic(String filename, String version){
WiFiClient client;
HTTPClient http;
String latest;
int code;
@ -1198,7 +1198,7 @@ bool checkforupdatepic(String filename, String version){
latest = http.header(1);
DebugTf("Update %s: %s -> %s\n", filename.c_str(), version.c_str(), latest.c_str());
http.end();
return (latest != version);
return(latest);
}
}
@ -1207,18 +1207,10 @@ void refreshpic(String filename, String version) {
HTTPClient http;
String latest;
int code;
http.begin(client, "http://otgw.tclcode.com/download/" + filename);
http.collectHeaders(hexheaders, 2);
code = http.sendRequest("HEAD");
if (code == HTTP_CODE_OK) {
for (int i = 0; i< http.headers(); i++) {
DebugTf("%s: %s\n", hexheaders[i], http.header(i).c_str());
}
latest = http.header(1);
if (latest=checkforupdatepic(filename, version) != "") {
if (latest != version) {
DebugTf("Update %s: %s -> %s\n", filename.c_str(), version.c_str(), latest.c_str());
http.end();
http.begin(client, "http://otgw.tclcode.com/download/" + filename);
code = http.GET();
if (code == HTTP_CODE_OK) {

View File

@ -84,8 +84,9 @@ void setup() {
resetOTGW(); // reset the OTGW pic
startOTGWstream(); // start port 25238
DebugTf("OTGW PIC firmware version = [%s]\r\n", CSTR(sPICfwversion));
if (checkforupdatepic("gateway.hex", OTGWSerial.firmwareVersion())) {
sMessage = "New PIC version available!";
String latest=checkforupdatepic("gateway.hex", sPICfwversion);
if (latest != sPICfwversion) {
sMessage = "New PIC version " + latest + " available!";
}
DebugTf("Reboot count = [%d]\r\n", rebootCount);
setLed(LED1, OFF);