예제 #1
0
//--------------------------------------------------------------------------------------------------
static void VerifyRetryTimer
(
    uint16_t* testRetryTimerPtr,
    size_t testNumTimers
)
{
    int i;
    le_result_t rc;
    size_t numTimers;
    uint16_t retryTimer[testNumTimers];

    rc = le_avc_SetRetryTimers(testRetryTimerPtr, testNumTimers);
    if (rc != LE_OK)
    {
        LE_ERROR("Failed to write the retry timers.");
    }

    numTimers = testNumTimers;
    rc = le_avc_GetRetryTimers(retryTimer, &numTimers);

    if (rc != LE_OK
        || numTimers != testNumTimers)
    {
        LE_ERROR("Failed reading retry timer.");
    }

    for (i = 0; i < testNumTimers; i++)
    {
        LE_DEBUG("retryTimer[%d] = %d", i, retryTimer[i]);

        if(testRetryTimerPtr[i] != retryTimer[i])
        {
            LE_ERROR("Retry Timer test failed.");
            return;
        }
    }
}
예제 #2
0
//--------------------------------------------------------------------------------------------------
void ImportConfig
(
    void
)
{
    le_result_t result;

    LE_INFO("Connect avcService");
    le_avc_ConnectService();

    // Don't import config from the modem if it was done before.
    if (le_fs_Exists(AVC_CONFIG_IS_IMPORTED))
    {
        LE_INFO("NOT importing AVMS config from modem to Legato since it was done before.");
    }
    else
    {
        LE_INFO("Importing AVMS config from modem to Legato.");

        /* Get the PDP profile */
        char apnName[LE_AVC_APN_NAME_MAX_LEN_BYTES] = {0};
        char userName[LE_AVC_USERNAME_MAX_LEN_BYTES] = {0};
        char userPassword[LE_AVC_PASSWORD_MAX_LEN_BYTES] = {0};

        result = pa_avc_GetApnConfig(apnName, LE_AVC_APN_NAME_MAX_LEN_BYTES,
                                     userName, LE_AVC_USERNAME_MAX_LEN_BYTES,
                                     userPassword, LE_AVC_PASSWORD_MAX_LEN_BYTES);

        if (result == LE_OK)
        {
            le_avc_SetApnConfig(apnName, userName, userPassword);
        }
        else
        {
            LE_WARN("Failed to get APN config from the modem.");
        }

        /* Get the polling timer */
        uint32_t pollingTimer = 0;

        result = pa_avc_GetPollingTimer(&pollingTimer);

        if (result == LE_OK)
        {
            le_avc_SetPollingTimer(pollingTimer);
        }
        else
        {
            LE_WARN("Failed to get the polling timer from the modem.");
        }

        /* Get the retry timers */
        uint16_t timerValue[LE_AVC_NUM_RETRY_TIMERS];
        size_t numTimers = 0;

        result = pa_avc_GetRetryTimers(timerValue, &numTimers);

        LE_ASSERT(numTimers <= LE_AVC_NUM_RETRY_TIMERS);

        if (result == LE_OK)
        {
            le_avc_SetRetryTimers(timerValue, numTimers);
        }
        else
        {
            LE_WARN("Failed to get the retry timers from the modem.");
        }

        /* Get the user agreement configuration */
        pa_avc_UserAgreement_t userAgreementConfig;
        result = pa_avc_GetUserAgreement(&userAgreementConfig);

        if (result == LE_OK)
        {
            le_avc_SetUserAgreement(LE_AVC_USER_AGREEMENT_CONNECTION,
                                    userAgreementConfig.isAutoConnect);
            le_avc_SetUserAgreement(LE_AVC_USER_AGREEMENT_DOWNLOAD,
                                    userAgreementConfig.isAutoDownload);
            le_avc_SetUserAgreement(LE_AVC_USER_AGREEMENT_INSTALL,
                                    userAgreementConfig.isAutoUpdate);
        }
        else
        {
            LE_WARN("Failed to get user agreement configuration from the modem.");
        }

        // Save status of import
        uint8_t isImported = true;
        WriteFs(AVC_CONFIG_IS_IMPORTED, &isImported, sizeof(int));
    }
}