mirror of
https://github.com/UtilitechAS/amsreader-firmware.git
synced 2026-01-12 00:02:53 +00:00
Fixed firmware upload from GUI
This commit is contained in:
parent
c0d95f918e
commit
40c84d2429
@ -51,7 +51,7 @@ bool AmsFirmwareUpdater::setTargetVersion(const char* version) {
|
||||
#if defined(AMS_REMOTE_DEBUG)
|
||||
if (debugger->isActive(RemoteDebug::INFO))
|
||||
#endif
|
||||
debugger->printf_P(PSTR("Preparing uprade to %s\n"), updateStatus.toVersion);
|
||||
debugger->printf_P(PSTR("Preparing upgrade to %s\n"), updateStatus.toVersion);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -1025,6 +1025,7 @@ bool AmsFirmwareUpdater::startFirmwareUpload(uint32_t size, const char* version)
|
||||
return false;
|
||||
}
|
||||
updateStatus.size = size;
|
||||
md5 = F("unknown");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1040,7 +1041,7 @@ bool AmsFirmwareUpdater::addFirmwareUploadChunk(uint8_t* buf, size_t length) {
|
||||
return false;
|
||||
}
|
||||
bufPos = 0;
|
||||
memset(buf, 0, UPDATE_BUF_SIZE);
|
||||
memset(this->buf, 0, UPDATE_BUF_SIZE);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@ -1056,7 +1057,7 @@ bool AmsFirmwareUpdater::completeFirmwareUpload() {
|
||||
writeBufferToFlash();
|
||||
bufPos = 0;
|
||||
}
|
||||
if(!verifyChecksum()) {
|
||||
if(!md5.equals(F("unknown")) && !verifyChecksum()) {
|
||||
updateStatus.errorCode = AMS_UPDATE_ERR_MD5;
|
||||
updateStatusChanged = true;
|
||||
return false;
|
||||
|
||||
@ -1640,22 +1640,22 @@ void AmsWebServer::handleSave() {
|
||||
#endif
|
||||
} else {
|
||||
#if defined(AMS_REMOTE_DEBUG)
|
||||
if (debugger->isActive(RemoteDebug::WARNING))
|
||||
#endif
|
||||
debugger->printf_P(PSTR("Price service missing...\n"));
|
||||
if (debugger->isActive(RemoteDebug::WARNING))
|
||||
#endif
|
||||
debugger->printf_P(PSTR("Price service missing...\n"));
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(AMS_REMOTE_DEBUG)
|
||||
if (debugger->isActive(RemoteDebug::INFO))
|
||||
#endif
|
||||
debugger->printf_P(PSTR("Saving configuration now...\n"));
|
||||
if (debugger->isActive(RemoteDebug::INFO))
|
||||
#endif
|
||||
debugger->printf_P(PSTR("Saving configuration now...\n"));
|
||||
|
||||
if (config->save()) {
|
||||
#if defined(AMS_REMOTE_DEBUG)
|
||||
if (debugger->isActive(RemoteDebug::INFO))
|
||||
#endif
|
||||
debugger->printf_P(PSTR("Successfully saved.\n"));
|
||||
if (debugger->isActive(RemoteDebug::INFO))
|
||||
#endif
|
||||
debugger->printf_P(PSTR("Successfully saved.\n"));
|
||||
if(config->isNetworkConfigChanged() || performRestart) {
|
||||
performRestart = true;
|
||||
} else {
|
||||
@ -1681,9 +1681,9 @@ debugger->printf_P(PSTR("Successfully saved.\n"));
|
||||
ds->save();
|
||||
}
|
||||
#if defined(AMS_REMOTE_DEBUG)
|
||||
if (debugger->isActive(RemoteDebug::INFO))
|
||||
#endif
|
||||
debugger->printf_P(PSTR("Rebooting\n"));
|
||||
if (debugger->isActive(RemoteDebug::INFO))
|
||||
#endif
|
||||
debugger->printf_P(PSTR("Rebooting\n"));
|
||||
debugger->flush();
|
||||
delay(1000);
|
||||
rdc->cause = 2;
|
||||
@ -1792,7 +1792,7 @@ void AmsWebServer::firmwareUpload() {
|
||||
server.send(500, MIME_JSON, buf);
|
||||
return;
|
||||
}
|
||||
if(!updater->startFirmwareUpload(upload.totalSize, "upload")) {
|
||||
if(!updater->startFirmwareUpload(upload.totalSize, "new")) {
|
||||
#if defined(AMS_REMOTE_DEBUG)
|
||||
if (debugger->isActive(RemoteDebug::ERROR))
|
||||
#endif
|
||||
@ -1814,7 +1814,11 @@ void AmsWebServer::firmwareUpload() {
|
||||
#endif
|
||||
}
|
||||
|
||||
if(upload.status == UPLOAD_FILE_START || upload.status == UPLOAD_FILE_WRITE) {
|
||||
if(upload.currentSize > 0) {
|
||||
#if defined(AMS_REMOTE_DEBUG)
|
||||
if (debugger->isActive(RemoteDebug::DEBUG))
|
||||
#endif
|
||||
debugger->printf_P(PSTR("Writing chunk: %lu bytes\n"), upload.currentSize);
|
||||
if(!updater->addFirmwareUploadChunk(upload.buf, upload.currentSize)) {
|
||||
#if defined(AMS_REMOTE_DEBUG)
|
||||
if (debugger->isActive(RemoteDebug::ERROR))
|
||||
@ -1829,7 +1833,14 @@ void AmsWebServer::firmwareUpload() {
|
||||
server.send(500, MIME_JSON, buf);
|
||||
return;
|
||||
}
|
||||
} else if(upload.status == UPLOAD_FILE_END) {
|
||||
}
|
||||
|
||||
if(upload.status == UPLOAD_FILE_END) {
|
||||
#if defined(AMS_REMOTE_DEBUG)
|
||||
if (debugger->isActive(RemoteDebug::DEBUG))
|
||||
#endif
|
||||
debugger->printf_P(PSTR("Upload complete\n"));
|
||||
|
||||
if(updater->completeFirmwareUpload()) {
|
||||
rebootForUpgrade = true;
|
||||
server.sendHeader(HEADER_LOCATION,F("/"));
|
||||
|
||||
@ -424,10 +424,15 @@ void setup() {
|
||||
}
|
||||
}
|
||||
|
||||
if(!hw.ledOn(LED_GREEN)) {
|
||||
hw.ledOn(LED_INTERNAL);
|
||||
}
|
||||
if(updater.relocateOrRepartitionIfNecessary()) {
|
||||
ESP.restart();
|
||||
return;
|
||||
}
|
||||
hw.ledOff(LED_GREEN);
|
||||
hw.ledOff(LED_INTERNAL);
|
||||
|
||||
WiFi.disconnect(true);
|
||||
WiFi.softAPdisconnect(true);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user