Progressbar on OTA/FOTA
This examples shows how to use onUpdateFirmwareProgress callback to show user updating is going on.
You can find the example here or download full examples files.
Setup Callback
The code below is the most simple OTA callback handling to show the progress is going on.
void onUpdateProgress(int progress, int totalt)
{
static int last = 0;
int progressPercent = (100 * progress) / totalt;
Serial.print("*");
if (last != progressPercent && progressPercent % 10 == 0)
{
// print every 10%
Serial.printf("%d", progressPercent);
}
last = progressPercent;
}
void setup()
{
...
OTADRIVE.onUpdateFirmwareProgress(onUpdateProgress);
}
Final result
Here is final result of the example.