Skip to content

Add restart option to handle() or execOTA() add callback for #164

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

Open
frogen1 opened this issue Mar 14, 2025 · 0 comments
Open

Add restart option to handle() or execOTA() add callback for #164

frogen1 opened this issue Mar 14, 2025 · 0 comments

Comments

@frogen1
Copy link

frogen1 commented Mar 14, 2025

I'm fairly new to esp32 and OTA. So far have only gotten this library to work out all the ones I've tried. Thank you for the work.

My project has a touchscreen and I am updating both spiffs and flash. I want to manually trigger update from the touchscreen as well as the reboot.

Would it be possible to add boolean flag to either or both to prevent the automatic restart?
esp32FOTA.execOTA(false) // do not restart when update complete
esp32FOTA.execOTA(true) // restart when update complete

Currently, I downloaded your library and put in my project directory and modifed in the .cpp file

bool esp32FOTA::execOTA()
and changed
// bool ret = execOTA( U_FLASH, true );
bool ret = execOTA( U_FLASH, false );

I then use the .setUpdateFinishedCb and check to see when the update finishes if it is the firmware.

for example:
void my_update_finish_cb(int partition, bool needs_restart)
{
Serial.printf("Update finished for %s partition\n", partition==U_SPIFFS ? "spiffs" : "firmware" );
if (partition!=U_SPIFFS)
{
Serial.println("Press reset to start new firmware");
while(true){}
}

This is working for me, but thought it could be something added to the main library.

The other item I added was an additional setcallback function. FOTA.setUpdateStartCb(my_update_start_cb);
This is slightly different then the UpdateBeginFail_cb but used in the same area.

I want one progress bar on my TFT for both spiffs and firmware. The ProgressCallback_cb does not indicate which partition is updating and provides two progress counts.

So in: bool esp32FOTA::execOTA( int partition, bool restart_after ) I added after if( !canBegin ) {.....

if( !canBegin ) {
    log_e("Not enough space to begin OTA, partition size mismatch?");
    F_abort();
    if( onUpdateBeginFail ) onUpdateBeginFail( partition );
    return false;
}
else  if (onUpdateStart) onUpdateStart( partition );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant