Resource Files OTA

This example shows how to download application resource files (such as jpg, html, css, js, ...) files and save them to the user file system area (SPIFFS / LittleFS). To know about resources on OTAdrive please check here. You can find the example here or download full examples files.

Create A Resource

To know about resources on OTAdrive please check here.
Create a resource as follow and assign it to the group of your device.
SPIFFS OTA

SPIFFS OTA

Setup File System

To use this feauture your device should have an initialized file system and pass its handler to the OTAdrive library in setup procedure.

void setup()
{
  ...  
  // Initialize file system and set the OTAdrive library file handler
  if (!SPIFFS.begin(true))
  {
    Serial.println("SPIFFS Mount Failed");
    return;
  }
  OTADRIVE.setFileSystem(&SPIFFS);
  ...
}

Sync files

Then you can simply call the OTADRIVE.syncResources() method to download and save all new/modified files from server to the file system area.

// Every n seconds
if (OTADRIVE.timeTick(30))
{
    // download new files (and rewrite modified files) from the OTAdrive
    OTADRIVE.syncResources();
    ..
}

Final Result