//-------------------------------------------------------------------------------------------------- static void VerifyApnConfig ( const char* testApnNamePtr, const char* testUserNamePtr, const char* testUserPasswordPtr ) { char apnName[LE_AVC_APN_NAME_MAX_LEN_BYTES]; char userName[LE_AVC_USERNAME_MAX_LEN_BYTES]; char password[LE_AVC_PASSWORD_MAX_LEN_BYTES]; le_result_t rc; rc = le_avc_SetApnConfig(testApnNamePtr, testUserNamePtr, testUserPasswordPtr); if (rc != LE_OK) { LE_ERROR("Failed to write APN Config."); } rc = le_avc_GetApnConfig(apnName, sizeof(apnName), userName, sizeof(userName), password, sizeof(password)); if (rc != LE_OK) { LE_ERROR("Failed to read APN config."); } if (strcmp(apnName, testApnNamePtr) != 0 || strcmp(userName, testUserNamePtr) != 0 || strcmp(password, testUserPasswordPtr) != 0) { LE_ERROR("APN Config test failed."); LE_DEBUG("APN Name : %s", apnName); LE_DEBUG("User Name %s: ", userName); LE_DEBUG("Password : %s", password); } }
//-------------------------------------------------------------------------------------------------- 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)); } }