ESP32 Simple OTA/FOTA Example

You can find the example here or download full examples files.

This example shows the minimum code to use the OTAdrive in your application.
You should initialize the OTAdrive library by calling otadrive_setInfo once in the statup initialize of the program. You can also monitor all event during library operations by registering to its events OTADRIVE_EVENTS.
Copy the API key from your product overview tab and replace it in the code. Replace some numbers in version code (v@2.10.33 ex.) then compile and download the code to the MCU via USB. Then unplug the USB, change the code upload the .bin file to the OTAdrive and power on the mcu, then see the output.

You can go ahead via Quick-start guide for more info.

#include <otadrive_esp.h>

// OTAdrive APIkey for this product
#define APIKEY "COPY_APIKEY_HERE"
// this app version
#define FW_VER "v@x.x.x"
...
void app_main(void)
{
    ...
    // OTAdrive initialize
    esp_event_handler_register(OTADRIVE_EVENTS, ESP_EVENT_ANY_ID, &otadrive_event_handler, NULL);
    otadrive_setInfo(OTADRIVE_APIKEY, APP_VERSION);
    ...
}
...
void thread_loop()
{
    // Every 30 seconds
    if (otadrive_timeTick(30))
    {
        otadrive_result r = otadrive_updateFirmwareInfo();
        ESP_LOGI(TAG, "Check new OTA result %d,%lu", r.code, r.available_size);
        if (r.code == OTADRIVE_NewFirmwareExists)
        {
            ESP_LOGI(TAG, "Lets download new firmware %s,%luBytes. Current firmware is %s",
                      r.available_version, r.available_size, otadrive_currentversion());

            r = otadrive_updateFirmware(false);
            if(r.code == OTADRIVE_Success)
            {
                // do something to prepare device for reboot
                esp_restart();
            }

            ESP_LOGI(TAG, "OTA Download Result %d", r.code);
        }
    }
}