Skip to content

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

Open
@frogen1

Description

@frogen1

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 );

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions