Пример #1
0
//--------------------------------------------------------------------------------------------------
static void PrintErrorMsg
(
    void
)
{
    switch (le_update_GetErrorCode())
    {
        case LE_UPDATE_ERR_NONE:
            fprintf(stderr, "\n***Error: Unexpected error code: NONE\n");
            return;

        case LE_UPDATE_ERR_BAD_PACKAGE:
            fprintf(stderr, "\n***Error: Received bad update package. See log for details.\n");
            return;

        case LE_UPDATE_ERR_SECURITY_FAILURE:
            fprintf(stderr, "\n***Error: Security check failure. See log for details.\n");
            return;

        case LE_UPDATE_ERR_INTERNAL_ERROR:
            fprintf(stderr, "\n***Error: Internal error during update. See log for details.\n");
            return;
    }

    fprintf(stderr, "\n***Error: Unexpected error code: %d.\n", le_update_GetErrorCode());
}
Пример #2
0
//--------------------------------------------------------------------------------------------------
static void UpdateProgressHandler
(
    le_update_State_t updateState,   ///< Current State of ongoing update task in Update State
                                     ///< machine.

    uint percentDone,                ///< Percent done for current state. As example: at state
                                     ///< LE_UPDATE_STATE_UNPACKING, percentDone=80 means,
                                     ///< 80% of the update file data is already transferred to
                                     ///< unpack process.

    void* contextPtr                 ///< Context pointer.
)
{
    static const int StatusMsgBytes = 100;
    char statusMsg[StatusMsgBytes];

    switch(updateState)
    {
        // TODO: Currently app/firmware(app script, modemService) tools are not able to give
        // status in the middle of installation. Revise the way of printing when these tools
        // will be able to provide installation status.
        case LE_UPDATE_STATE_NEW:
            // Update started. Print this information.
            fprintf(stdout, "New update started\n");
            break;

        case LE_UPDATE_STATE_UNPACKING:
            // Reset all characters to zero.
            memset(statusMsg, 0, StatusMsgBytes);
            snprintf(statusMsg, sizeof(statusMsg), "Unpacking package");
            // Print progress bar if there is any noticeable progress.
            PrintProgressBar(percentDone, statusMsg);
            break;

        case LE_UPDATE_STATE_APPLYING:
            // Reset all characters to zero.
            memset(statusMsg, 0, StatusMsgBytes);
            snprintf(statusMsg, sizeof(statusMsg), "Applying update");
            // Print progress bar if there is any noticeable progress.
            PrintProgressBar(percentDone, statusMsg);
            break;

        case LE_UPDATE_STATE_SUCCESS:
            //Successful update(install/remove) task.
            fprintf(stdout, "SUCCESS\n");
            le_update_Delete(Handle);
            exit(EXIT_SUCCESS);

        case LE_UPDATE_STATE_FAILED:
            // Failure in update, exit with failure code.
            PrintErrorMsg(le_update_GetErrorCode(Handle));
            fprintf(stderr, "FAILED\n");
            le_update_Delete(Handle);
            exit(EXIT_FAILURE);
    }

}