Add onPregress callback

This commit is contained in:
fvanroie 2020-11-23 23:59:43 +01:00
parent 307f259a51
commit 1865e340e9

View File

@ -35,6 +35,14 @@ static inline void otaProgress(void)
(ArduinoOTA.getCommand() == U_FLASH ? PSTR("Firmware") : PSTR("Filesystem")), otaPrecentageComplete); (ArduinoOTA.getCommand() == U_FLASH ? PSTR("Firmware") : PSTR("Filesystem")), otaPrecentageComplete);
} }
void otaOnProgress(unsigned int progress, unsigned int total)
{
if(total != 0) {
otaPrecentageComplete = progress * 100 / total;
haspProgressVal(otaPrecentageComplete);
}
}
void otaSetup(void) void otaSetup(void)
{ {
if(strlen(otaUrl.c_str())) { if(strlen(otaUrl.c_str())) {
@ -63,12 +71,7 @@ void otaSetup(void)
// setup(); // setup();
dispatchReboot(true); dispatchReboot(true);
}); });
ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) { ArduinoOTA.onProgress(otaOnProgress);
if(total != 0) {
otaPrecentageComplete = progress * 100 / total;
haspProgressVal(otaPrecentageComplete);
}
});
ArduinoOTA.onError([](ota_error_t error) { ArduinoOTA.onError([](ota_error_t error) {
char buffer[16]; char buffer[16];
switch(error) { switch(error) {