API Reference
This API is used to update the software/firmware of the target device using update packs.
Update packs can contain one or more "tasks" to be performed by the Update Daemon.
from the point of view of the client of this API, the update service follows this state machine while doing an update:
------------------
Create() | | Delete()
--------->| NEW |--------------------------------+
| | |
------------------ |
Start() | |
| |
| |
+-------------+ | |
| | | |
ALL_ITEMS_UNPACKED=NO V V |
| ------------------ |
| | | Delete()/Error* |
+-----------| UNPACKING |---------------------+ |
| | | |
------------------ V V
| ------------------
| | |
ALL_ITEMS_UNPACKED = YES | FAILED |
| | |
V ------------------
------------------ ^
| | Delete()/Error* |
+---->| APPLYING |--------------------------+
| | |
ALL_ITEMS_DONE = NO ------------------
| | |
+---------+ |
|
ALL_ITEMS_DONE = YES
|
V
------------------
| |
| SUCCESS |
| |
------------------
Error: Any kind of error during update.
API Usage Guidelines
Typically, the API used used as follows:
- Client calls le_update_Create(), providing a file descriptor that the update service can read the update pack from.
- Server returns a handle for the update that the client can later use to cancel the update or register for notification of events related to this update.
- Client calls le_update_AddProgressHandler() to register a callback function to be called (by the Legato event loop) when events related to this update are reported by the update service.
- Client calls le_update_Start() to start the update. This is an asynchronous function call, meaning that it returns immediately without providing any status feedback.
- Progress reports are sent to the client periodically via the notification function registered by the client through le_update_AddProgressHandler().
- If the update fails, le_update_GetErrorCode() can be used to find out more information.
- When the client is finished with the update, the client MUST call le_update_Delete() to deallocate resources.
To cancel an update before it finishes, call le_update_Delete().
If the client disconnects before deleting the update, the update will automatically be deleted, and if the update is still in progress, it may be cancelled (if it's not too late).
Sample Code
This code sample calls an update service provider API to perform an update:
void SoftwareUpdate(void)
{
int fd = 0;
if (updateHandle == NULL)
{
fprintf(stderr, "Update already in progress. Try again later.\n");
exit(EXIT_FAILURE);
}
}
static void UpdateProgressHandler
(
uint percentDone,
void* contextPtr
)
{
switch(updateState)
{
fprintf(stdout, "New update started\n");
break;
fprintf(stdout, "Unpacking: %d%% \n", percentDone);
break;
fprintf(stdout, "Applying: %d%% \n", percentDone);
break;
fprintf(stdout, "\nSUCCESS\n");
exit(EXIT_SUCCESS);
exit(EXIT_FAILURE);
}
}
Copyright (C) Sierra Wireless Inc. Use of this work is subject to license.