System calls
onAssetOta - System
Since 5.5.0:
Register a handler function that will be called by Device OS when new assets have been delivered to the device using Asset OTA. Your handler will be called before the application setup()
. It will receive a vector of all the application assets, not just the new ones.
The System.onAssetOta()
call is typically made from the STARTUP()
macro to ensure your handler is registered before setup()
is called.
void handleAssets(spark::Vector<ApplicationAsset> assets);
STARTUP(System.onAssetOta(handleAssets));
- The parameter is a
std::function
so it can be a C++11 lambda, if desired. - An additional overload also takes a context pointer.
- An additional overload allows the callback to be an method of a C++ class.
See ApplicationAsset
class for using the vector of application asset objects passed to your callback function and additional information on Asset OTA.
- Particle Workbench and the Particle CLI will automatically generated bundled assets when the
project.properties
file contains anassetOtaDir
key and a value containing a valid directory.
assetOtaDir=assets
- When using Particle: Compile Application or
particle compile
projects with bundled assets are built into a .zip file. This file contains both the firmware binary (.bin) as well as the assets. - The asset bundle .zip can be uploaded to the console as product firmware binary.
- When using Particle: Flash application or
particle flash
the same process is followed, except the device is flashed. - When flashing OTA, the asset bundle is transmitted using resumable OTA and compression for efficient data use.
- You will need to include code in your application firmware to process the additional assets, such as sending them to a coprocessor or saving them to the file system.
- Creating bundled assets will not be not possible in the Web IDE. Particle Workbench is recommended.