API Reference
Update Process
Update Pack Format
Use Software Update
This API uses Update Pack Format to update a target device software/firmware.
Update packs can contain one or more tasks to be performed by the Update Daemon.
From the client view, the update service follows this state machine while doing an update:
Start() |
|
|
+-------------+ |
| | |
ALL_ITEMS_UNPACKED=NO V V
| ------------------
| | | End()/Error*
+-----------| UNPACKING |-------------------------+
| | |
------------------ V
| ------------------
| | |
ALL_ITEMS_UNPACKED = YES | FAILED |
| | |
V ------------------
------------------ ^
| | End()/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 is used like this:
- Client calls le_update_Start() providing a file descriptor for the update service to read the update pack and a notification callback function to call with updates.
- Progress reports are sent to the client periodically through the notification function.
- If the update fails, le_update_GetErrorCode() can be used to find out more info.
- When the client is finished with the update, the client MUST call le_update_End() to deallocate resources.
To cancel an update before it finishes, call le_update_End().
If the client disconnects before ending the update session, the session will automatically end. If the update is still in progress, it may be cancelled (if it's not too late).
Sample Code
This C code sample calls an update service provider API to perform an update:
void SoftwareUpdate(void)
{
int fd = 0;
if (result != LE_OK)
{
fprintf(stderr, "Update refused by server. Try again later.\n");
exit(EXIT_FAILURE);
}
}
static void UpdateProgressHandler
(
uint percentDone,
void* contextPtr
)
{
switch(updateState)
{
case LE_UPDATE_STATE_NEW:
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);
}
}
Installed System Information
It is possible to get the index and hash for all of the currently installed systems. The following is an example of how one would list all installed systems and their hashes.
do
{
{
LE_INFO(
"System: %d -- %s", systemIndex, hashBuffer);
}
else
{
LE_ERROR(
"System: %d -- NOT FOUND", systemIndex);
}
}
Copyright (C) Sierra Wireless Inc. Use of this work is subject to license.