in qgsm/cellular_qgsm_api.c [1268:1361]
static CellularPktStatus_t _Cellular_RecvFuncData( CellularContext_t * pContext,
const CellularATCommandResponse_t * pAtResp,
void * pData,
uint16_t dataLen )
{
CellularATError_t atCoreStatus = CELLULAR_AT_SUCCESS;
CellularPktStatus_t pktStatus = CELLULAR_PKT_STATUS_OK;
char * pInputLine = NULL, * pToken = NULL;
const _socketDataRecv_t * pDataRecv = ( _socketDataRecv_t * ) pData;
int32_t tempValue = 0;
char * location = NULL;
if( pContext == NULL )
{
LogError( ( "Receive Data: invalid context" ) );
pktStatus = CELLULAR_PKT_STATUS_FAILURE;
}
else if( ( pAtResp == NULL ) || ( pAtResp->pItm == NULL ) || ( pAtResp->pItm->pLine == NULL ) )
{
if( pAtResp->status == true )
{
*pDataRecv->pDataLen = 0;
}
else
{
LogError( ( "Receive Data: response is invalid" ) );
pktStatus = CELLULAR_PKT_STATUS_FAILURE;
}
}
else if( ( pDataRecv == NULL ) || ( pDataRecv->pData == NULL ) || ( pDataRecv->pDataLen == NULL ) )
{
LogError( ( "Receive Data: Bad param" ) );
pktStatus = CELLULAR_PKT_STATUS_BAD_PARAM;
}
else
{
pInputLine = pAtResp->pItm->pLine;
location = strstr( pInputLine, "QIRDI" );
while( location != NULL )
{
if( pAtResp->pItm->pNext != NULL )
{
pInputLine = pAtResp->pItm->pNext->pLine;
location = strstr( pInputLine, "QIRDI" );
}
else
{
/* */
}
}
{
atCoreStatus = Cellular_ATRemovePrefix( &pInputLine );
atCoreStatus = Cellular_ATGetNextTok( &pInputLine, &pToken );
atCoreStatus = Cellular_ATGetNextTok( &pInputLine, &pToken );
/* parse the datalen. */
if( atCoreStatus == CELLULAR_AT_SUCCESS )
{
atCoreStatus = Cellular_ATGetNextTok( &pInputLine, &pToken );
}
if( atCoreStatus == CELLULAR_AT_SUCCESS )
{
atCoreStatus = Cellular_ATStrtoi( pToken, 10, &tempValue );
if( atCoreStatus == CELLULAR_AT_SUCCESS )
{
if( ( tempValue >= ( int32_t ) 0 ) && ( tempValue < ( ( int32_t ) CELLULAR_MAX_RECV_DATA_LEN + 1 ) ) )
{
*pDataRecv->pDataLen = ( uint32_t ) tempValue;
}
else
{
LogError( ( "Error in Data Length Processing: No valid digit found. Token %s", pToken ) );
atCoreStatus = CELLULAR_AT_ERROR;
}
}
}
/* Process the data buffer. */
if( atCoreStatus == CELLULAR_AT_SUCCESS )
{
atCoreStatus = getDataFromResp( pAtResp, pDataRecv, dataLen );
}
}
pktStatus = _Cellular_TranslateAtCoreStatus( atCoreStatus );
}
return pktStatus;
}