コード例 #1
0
ファイル: dataAppMain.c プロジェクト: ekral85/legato-af
//--------------------------------------------------------------------------------------------------
static void StatusHandler
(
    le_avc_Status_t updateStatus,
    int32_t totalNumBytes,
    int32_t downloadProgress,
    void* contextPtr
)
{
    LE_ERROR("Got status %i", updateStatus);
    switch ( updateStatus )
    {
        case LE_AVC_DOWNLOAD_PENDING:
               LE_WARN("Accept download");
               LE_ASSERT( le_avc_AcceptDownload() == LE_OK );
               break;

           case LE_AVC_INSTALL_PENDING:
               LE_WARN("Accept install");
               LE_ASSERT( le_avc_AcceptInstall() == LE_OK );
               break;

           case LE_AVC_UNINSTALL_PENDING:
               LE_WARN("Accept uninstall");
               LE_ASSERT( le_avc_AcceptUninstall() == LE_OK );
               break;

           default:
               LE_WARN("Update status %i not handled", updateStatus);
    }
}
コード例 #2
0
ファイル: ctrlAppMain.c プロジェクト: tegoo/legato-af
//--------------------------------------------------------------------------------------------------
static void SimpleDownloadAndDeferInstall
(
    le_avc_Status_t updateStatus
)
{
    // Use a count instead of a bool flag, so we could defer multiple times, if we want
    static int count=0;

    le_avc_UpdateType_t updateType;

    switch ( updateStatus )
    {
        case LE_AVC_NO_UPDATE:
            LE_WARN("No action");
            break;

        case LE_AVC_DOWNLOAD_PENDING:
            if ( le_avc_GetUpdateType(&updateType) == LE_OK )
            {
                LE_INFO("Update type is %i", updateType);
            }
            else
            {
                LE_INFO("Update type is not available");
            }

            LE_WARN("Accept download");
            LE_ASSERT( le_avc_AcceptDownload() == LE_OK );
            break;

        case LE_AVC_INSTALL_PENDING:
            if ( count < 1 )
            {
                LE_WARN("Defer install");
                LE_ASSERT( le_avc_DeferInstall(1) == LE_OK );

                count++;
            }
            else
            {
                LE_WARN("Accept install");
                LE_ASSERT( le_avc_AcceptInstall() == LE_OK );
            }
            break;

        case LE_AVC_UNINSTALL_PENDING:
            LE_WARN("Accept uninstall");
            LE_ASSERT( le_avc_AcceptUninstall() == LE_OK );
            break;

        default:
            LE_WARN("Update status %i not handled", updateStatus);
    }
}
コード例 #3
0
ファイル: ctrlAppMain.c プロジェクト: tegoo/legato-af
//--------------------------------------------------------------------------------------------------
static void SimpleDownloadAndInstall
(
    le_avc_Status_t updateStatus
)
{
    le_avc_UpdateType_t updateType;

    switch ( updateStatus )
    {
        case LE_AVC_NO_UPDATE:
            LE_WARN("No action");
            break;

        case LE_AVC_DOWNLOAD_PENDING:
            if ( le_avc_GetUpdateType(&updateType) == LE_OK )
            {
                LE_INFO("Update type is %i", updateType);
            }
            else
            {
                LE_INFO("Update type is not available");
            }

            LE_WARN("Accept download");
            LE_ASSERT( le_avc_AcceptDownload() == LE_OK );
            break;

        case LE_AVC_INSTALL_PENDING:
            LE_WARN("Accept install");
            LE_ASSERT( le_avc_AcceptInstall() == LE_OK );
            break;

        case LE_AVC_UNINSTALL_PENDING:
            LE_WARN("Accept uninstall");
            LE_ASSERT( le_avc_AcceptUninstall() == LE_OK );
            break;

        default:
            LE_WARN("Update status %i not handled", updateStatus);
    }

}
コード例 #4
0
ファイル: ctrlAppMain.c プロジェクト: mbaglin/legato-af
//--------------------------------------------------------------------------------------------------
static void DeferThenDownloadAndInstall
(
    le_avc_Status_t updateStatus
)
{
    // Use a count instead of a bool flag, so we could defer multiple times, if we want
    static int count=0;

    switch ( updateStatus )
    {
        case LE_AVC_DOWNLOAD_PENDING:
            if ( count < 1 )
            {
                LE_WARN("Defer download");
                LE_ASSERT( le_avc_DeferDownload(1) == LE_OK );

                // In the wrong state, so this should be an error
                LE_ASSERT( le_avc_AcceptDownload() == LE_FAULT );

                count++;
            }
            else
            {
                LE_WARN("Accept download");
                LE_ASSERT( le_avc_AcceptDownload() == LE_OK );
            }
            break;

        case LE_AVC_INSTALL_PENDING:
            LE_WARN("Accept install");
            LE_ASSERT( le_avc_AcceptInstall() == LE_OK );
            break;

        default:
            LE_WARN("Update status %i not handled", updateStatus);
    }

}
コード例 #5
0
ファイル: lwm2mControl.c プロジェクト: tegoo/legato-af
//-------------------------------------------------------------------------------------------------
static void StatusHandler
(
    le_avc_Status_t updateStatus,
    int32_t totalNumBytes,
    int32_t downloadProgress,
    void* contextPtr
)
//--------------------------------------------------------------------------------------------------
{
    const char* statusPtr = NULL;

    switch (updateStatus)
    {
    case LE_AVC_NO_UPDATE:
        statusPtr = "NO_UPDATE";
        break;
    case LE_AVC_DOWNLOAD_PENDING:
        statusPtr = "DOWNLOAD_PENDING";
        break;
    case LE_AVC_DOWNLOAD_IN_PROGRESS:
        statusPtr = "DOWNLOAD_IN_PROGRESS";
        break;
    case LE_AVC_DOWNLOAD_COMPLETE:
        statusPtr = "DOWNLOAD_COMPLETE";
        break;
    case LE_AVC_DOWNLOAD_FAILED:
        statusPtr = "DOWNLOAD_FAILED";
        break;
    case LE_AVC_INSTALL_PENDING:
        statusPtr = "INSTALL_PENDING";
        break;
    case LE_AVC_INSTALL_IN_PROGRESS:
        statusPtr = "INSTALL_IN_PROGRESS";
        break;
    case LE_AVC_INSTALL_COMPLETE:
        statusPtr = "INSTALL_COMPLETE";
        break;
    case LE_AVC_INSTALL_FAILED:
        statusPtr = "INSTALL_FAILED";
        break;
    case LE_AVC_UNINSTALL_PENDING:
        statusPtr = "UNINSTALL_PENDING";
        break;
    case LE_AVC_UNINSTALL_IN_PROGRESS:
        statusPtr = "UNINSTALL_IN_PROGRESS";
        break;
    case LE_AVC_UNINSTALL_COMPLETE:
        statusPtr = "UNINSTALL_COMPLETE";
        break;
    case LE_AVC_UNINSTALL_FAILED:
        statusPtr = "UNINSTALL_FAILED";
        break;
    case LE_AVC_SESSION_STARTED:
        statusPtr = "SESSION_STARTED";
        break;
    case LE_AVC_SESSION_STOPPED:
        statusPtr = "SESSION_STOPPED";
        break;
    }

    if (statusPtr == NULL)
    {
        LE_ERROR("Air Vantage agent reported unexpected update status: %d", updateStatus);
    }
    else
    {
        LE_INFO("Air Vantage agent reported update status: %s", statusPtr);

        le_result_t res;

        if (updateStatus == LE_AVC_DOWNLOAD_PENDING)
        {
            LE_INFO("Accepting %s update.", GetUpdateType());
            res = le_avc_AcceptDownload();
            if (res != LE_OK)
            {
                LE_ERROR("Failed to accept download from Air Vantage (%s)", LE_RESULT_TXT(res));
            }
        }
        else if (updateStatus == LE_AVC_INSTALL_PENDING)
        {
            LE_INFO("Accepting %s installation.", GetUpdateType());
            res = le_avc_AcceptInstall();
            if (res != LE_OK)
            {
                LE_ERROR("Failed to accept install from Air Vantage (%s)", LE_RESULT_TXT(res));
            }
        }
        else if (updateStatus == LE_AVC_UNINSTALL_PENDING)
        {
            LE_INFO("Accepting %s uninstall.", GetUpdateType());
            res = le_avc_AcceptUninstall();
            if (res != LE_OK)
            {
                LE_ERROR("Failed to accept uninstall from Air Vantage (%s)", LE_RESULT_TXT(res));
            }
        }
    }
}
コード例 #6
0
ファイル: ctrlAppMain.c プロジェクト: mbaglin/legato-af
//--------------------------------------------------------------------------------------------------
static void DownloadAndInstall
(
    le_avc_Status_t updateStatus,
    int32_t totalNumBytes,
    int32_t progress
)
{
    le_avc_UpdateType_t updateType;

    switch ( updateStatus )
    {
        case LE_AVC_NO_UPDATE:
            // In the wrong state, so this should be an error
            LE_ASSERT( le_avc_AcceptDownload() == LE_FAULT );

            // In the wrong state, so this should be an error
            LE_ASSERT( le_avc_GetUpdateType(&updateType) == LE_FAULT );
            break;

        case LE_AVC_DOWNLOAD_PENDING:
            LE_INFO("Total number of bytes to download = %d", totalNumBytes);
            LE_INFO("Download progress = %d%%", progress);

            // In the wrong state, so this should be an error
            LE_ASSERT( le_avc_AcceptInstall() == LE_FAULT );

            LE_WARN("Accept download");
            LE_ASSERT( le_avc_AcceptDownload() == LE_OK );

            // Verify update type
            LE_ASSERT( le_avc_GetUpdateType(&updateType) == LE_OK );
            //LE_ASSERT( updateType == LE_AVC_FIRMWARE_UPDATE );

            // In the wrong state, so this should be an error
            LE_ASSERT( le_avc_DeferDownload(3) == LE_FAULT );
            break;


        case LE_AVC_DOWNLOAD_IN_PROGRESS:
            LE_INFO("Download in Progress");
            LE_INFO("Total number of bytes to download = %d", totalNumBytes);
            LE_INFO("Download progress = %d%%", progress);
            break;

        case LE_AVC_DOWNLOAD_COMPLETE:
            LE_INFO("Download completed");
            LE_INFO("Total number of bytes to download = %d", totalNumBytes);
            LE_INFO("Download progress = %d%%", progress);
            break;

        case LE_AVC_INSTALL_PENDING:
            // In the wrong state, so this should be an error
            LE_ASSERT( le_avc_AcceptDownload() == LE_FAULT );

            LE_WARN("Accept install");
            LE_ASSERT( le_avc_AcceptInstall() == LE_OK );

            // In the wrong state, so this should be an error
            LE_ASSERT( le_avc_DeferInstall(3) == LE_FAULT );
            break;

        default:
            LE_WARN("Update status %i not handled", updateStatus);
    }

}