in modules/sara_r4/cellular_r4.c [332:431]
CellularError_t Cellular_ModuleEnableUE( CellularContext_t * pContext )
{
CellularError_t cellularStatus = CELLULAR_SUCCESS;
CellularAtReq_t atReqGetNoResult =
{
NULL,
CELLULAR_AT_NO_RESULT,
NULL,
NULL,
NULL,
0
};
CellularAtReq_t atReqGetWithResult =
{
NULL,
CELLULAR_AT_WO_PREFIX,
NULL,
NULL,
NULL,
0
};
char pAtCmdBuf[ CELLULAR_AT_CMD_MAX_SIZE ] = { 0 };
if( pContext != NULL )
{
/* Disable echo. */
atReqGetWithResult.pAtCmd = "ATE0";
cellularStatus = sendAtCommandWithRetryTimeout( pContext, &atReqGetWithResult );
if( cellularStatus == CELLULAR_SUCCESS )
{
/* Disable DTR function. */
atReqGetNoResult.pAtCmd = "AT&D0";
cellularStatus = sendAtCommandWithRetryTimeout( pContext, &atReqGetNoResult );
}
if( cellularStatus == CELLULAR_SUCCESS )
{
/* Enable RTS/CTS hardware flow control. */
atReqGetNoResult.pAtCmd = "AT+IFC=2,2";
cellularStatus = sendAtCommandWithRetryTimeout( pContext, &atReqGetNoResult );
}
if( cellularStatus == CELLULAR_SUCCESS )
{
/* Report verbose mobile termination error. */
atReqGetNoResult.pAtCmd = "AT+CMEE=2";
cellularStatus = sendAtCommandWithRetryTimeout( pContext, &atReqGetNoResult );
}
if( cellularStatus == CELLULAR_SUCCESS )
{
/* Setup mobile network operator profiles. */
/* Setting +UMNOPROF profile will automatically select suitable values for +URAT and +UBANDMASK. */
/* Check current MNO profile first to avoid unneccessary modem reboot. */
MNOProfileType_t currentMNOProfile = MNO_PROFILE_NOT_SET;
cellularStatus = _Cellular_GetCurrentMNOProfile( pContext, ¤tMNOProfile );
LogInfo( ( "Cellular_ModuleEnableUE: currentMNOProfile = [%d], desiredProfile = [%d]", currentMNOProfile, CELLULAR_CONFIG_SARA_R4_SET_MNO_PROFILE ) );
if( cellularStatus == CELLULAR_SUCCESS )
{
/* Set MNO profile if not set already */
if( ( currentMNOProfile != CELLULAR_CONFIG_SARA_R4_SET_MNO_PROFILE ) && ( CELLULAR_CONFIG_SARA_R4_SET_MNO_PROFILE != MNO_PROFILE_NOT_SET ) )
{
atReqGetNoResult.pAtCmd = pAtCmdBuf;
( void ) snprintf( ( char * ) atReqGetNoResult.pAtCmd, CELLULAR_AT_CMD_MAX_SIZE, "%s%d", "AT+COPS=2;+UMNOPROF=", CELLULAR_CONFIG_SARA_R4_SET_MNO_PROFILE );
cellularStatus = sendAtCommandWithRetryTimeout( pContext, &atReqGetNoResult );
if( cellularStatus == CELLULAR_SUCCESS )
{
cellularStatus = rebootCellularModem( pContext, true, true );
}
}
#ifdef CELLULAR_CONFIG_SARA_R4_REBOOT_ON_INIT
else
{
cellularStatus = rebootCellularModem( pContext, true, true );
}
#endif
}
}
if( cellularStatus == CELLULAR_SUCCESS )
{
atReqGetNoResult.pAtCmd = "AT+COPS=0";
cellularStatus = sendAtCommandWithRetryTimeout( pContext, &atReqGetNoResult );
}
if( cellularStatus == CELLULAR_SUCCESS )
{
atReqGetNoResult.pAtCmd = "AT+CFUN=1";
cellularStatus = sendAtCommandWithRetryTimeout( pContext, &atReqGetNoResult );
}
}
return cellularStatus;
}