Update espmega_iot_core.cpp

This commit is contained in:
Siwat Sirichai 2023-10-01 13:48:02 +07:00
parent 8bd0fb5ecb
commit d301462298
1 changed files with 17 additions and 5 deletions

View File

@ -266,7 +266,10 @@ void ota_begin()
if (upload.status == UPLOAD_FILE_START) if (upload.status == UPLOAD_FILE_START)
{ {
lcd_send_command("page ota"); lcd_send_command("page ota");
Serial.println(upload.currentSize);
String otafiletxt = "Downloading File : " + upload.filename; String otafiletxt = "Downloading File : " + upload.filename;
lcd_send_stop_bit();
panel.writeStr("otatxt.txt", otafiletxt); panel.writeStr("otatxt.txt", otafiletxt);
Serial.printf("Update: %s\n", upload.filename.c_str()); Serial.printf("Update: %s\n", upload.filename.c_str());
if (!Update.begin(UPDATE_SIZE_UNKNOWN)) if (!Update.begin(UPDATE_SIZE_UNKNOWN))
@ -282,6 +285,15 @@ void ota_begin()
panel.writeStr("otatxt.txt", "Update Failed, Rebooting . . ."); panel.writeStr("otatxt.txt", "Update Failed, Rebooting . . .");
Update.printError(Serial); Update.printError(Serial);
} }
if (upload.currentSize != 0 && upload.totalSize != 0)
{
lcd_send_stop_bit();
uint32_t totalsize_kb = upload.totalSize / 1000;
uint32_t upload_pct = 100 * upload.totalSize/1000000;
String otafiletxt = "Downloading File : " + upload.filename + " ("+String(totalsize_kb) + "KB)";
panel.writeNum("prog.val", upload_pct);
panel.writeStr("otatxt.txt", otafiletxt);
}
} }
else if (upload.status == UPLOAD_FILE_END) else if (upload.status == UPLOAD_FILE_END)
{ {