Update espmega_iot_core.cpp
This commit is contained in:
parent
8bd0fb5ecb
commit
d301462298
|
@ -266,12 +266,15 @@ 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;
|
||||||
panel.writeStr("otatxt.txt",otafiletxt);
|
lcd_send_stop_bit();
|
||||||
|
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))
|
||||||
{
|
{
|
||||||
panel.writeStr("otatxt.txt","Update Failed, Rebooting . . .");
|
panel.writeStr("otatxt.txt", "Update Failed, Rebooting . . .");
|
||||||
Update.printError(Serial);
|
Update.printError(Serial);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -279,20 +282,29 @@ void ota_begin()
|
||||||
{
|
{
|
||||||
if (Update.write(upload.buf, upload.currentSize) != upload.currentSize)
|
if (Update.write(upload.buf, upload.currentSize) != upload.currentSize)
|
||||||
{
|
{
|
||||||
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)
|
||||||
{
|
{
|
||||||
if (Update.end(true))
|
if (Update.end(true))
|
||||||
{
|
{
|
||||||
panel.writeStr("otatxt.txt","Update Completed, Rebooting . . .");
|
panel.writeStr("otatxt.txt", "Update Completed, Rebooting . . .");
|
||||||
Serial.printf("Update Success: %u\nRebooting...\n", upload.totalSize);
|
Serial.printf("Update Success: %u\nRebooting...\n", upload.totalSize);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
panel.writeStr("otatxt.txt","Update Failed, Rebooting . . .");
|
panel.writeStr("otatxt.txt", "Update Failed, Rebooting . . .");
|
||||||
Update.printError(Serial);
|
Update.printError(Serial);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue