-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Question: getting update progress #4010
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@MCMeGa I believe the updated class has callbacks, and one is for progress. I haven't used them myself, but "use the source, Luke!". |
It works, maybe someone will need it! void updateESP() {
sendWS(NULL, "infoMessage", "FFS Update...");
if (_updateFW(true)) {
delay(250);
sendWS(NULL, "infoMessage", "ESP Update...");
if (_updateFW(false)) {
sendWS(NULL, "infoMessage", "All Updates Completed");
delay(250);
}
}
}
bool _updateFW(bool updTarget) {
udp.close();
HTTPClient httpClient;
httpClient.useHTTP10(true);
httpClient.setTimeout(5000);
char url[65];
sprintf(url, "http://%s/%s-%d-%s.bin", OTA_HOST, DEVICE_MODEL, latVer, updTarget ? "ffs" : "esp");
httpClient.begin(url);
if (httpClient.GET() != HTTP_CODE_OK) {
sendWS(NULL, "infoMessage", "Unable to fetch, please reboot the device and try again");
return false;
}
int httpSize = httpClient.getSize();
if (!Update.setMD5(updTarget ? ffsMD5 : espMD5)) {
sendWS(NULL, "infoMessage", "Invalid MD5, please reboot the device and try again");
return false;
}
if (!Update.begin(httpSize, updTarget ? U_SPIFFS : U_FLASH)) {
sendWS(NULL, "infoMessage", "Incorrect startup conditions, please reboot the device and try again");
return false;
}
uint8_t buff[1024] = { 0 };
size_t sizePack;
WiFiClient * stream = httpClient.getStreamPtr();
while (httpClient.connected() && (httpSize > 0 || httpSize == -1)) {
sizePack = stream->available();
if (sizePack) {
int c = stream->readBytes(buff, ((sizePack > sizeof(buff)) ? sizeof(buff) : sizePack));
Update.write(buff, c);
if (httpSize > 0)
httpSize -= c;
}
if (progress != int(Update.progress() * 100 / httpClient.getSize())) {
progress = int(Update.progress() * 100 / httpClient.getSize());
updTarget ? sendWS(NULL, "updPrgFFS", String(progress)) : sendWS(NULL, "updPrgESP", String(progress));
}
}
if (!Update.end()) {
sendWS(NULL, "infoMessage", "Invalid completion conditions, please reboot the device and try again");
return false;
}
httpClient.end();
return true;
} |
Its would be really great to have a callback function for the progress, instead of hacky workarounds :/ How can I get the progress working with my code? void checkForUpdates() {
display_text("Checking for updates");
// display.drawProgressBar(4, 40, 120, 8, 10);
// display.display();
// String fwVersionURL = String(fwUrlBase)+"/"+String(DeviceName)+".version";
Debug.println("[checkForUpdates]: Checking for firmware updates.");
Debug.println("[checkForUpdates]: Firmware version URL: "+String(fwUrlBase));
t_httpUpdate_return ret = ESPhttpUpdate.update(fwUrlBase, String(FW_VERSION));
switch(ret) {
case HTTP_UPDATE_FAILED:
Debug.println("[checkForUpdates]: Update failed: "+String(ESPhttpUpdate.getLastErrorString()));
break;
case HTTP_UPDATE_NO_UPDATES:
Debug.println("[checkForUpdates]: No Update needed");
break;
case HTTP_UPDATE_OK:
Debug.println("[checkForUpdates]: Update ok."); // may not called we reboot the ESP
break;
}
|
Yes, I too would like to get progress when using ESPhttpUpdate.update(). Thanks! |
I managed to get a progress bar working on httpupdate but not on this library. Please help us here. |
duplicate with opened #5715 |
Hi! I see this progress callback function is merged, but how to use it? Are there any examples? |
@franzuu Thanks for the link, it was helpful. |
Hi guys!
How can I get the firmware upgrade progress?
ESP8285
1M/128K
80MHz
The update is going well, but I want to know how much is completed.
Help.
The text was updated successfully, but these errors were encountered: