in sim70x0/cellular_sim70x0_api.c [1145:1217]
static CellularPktStatus_t _Cellular_RecvFuncData( CellularContext_t * pContext,
const CellularATCommandResponse_t * pAtResp,
void * pData,
uint16_t dataLen )
{
/*copy +CARECV: <len> / data to recv buffer */
CellularATError_t atCoreStatus = CELLULAR_AT_SUCCESS;
CellularPktStatus_t pktStatus = CELLULAR_PKT_STATUS_OK;
char * pInputLine = NULL;
char * pToken = NULL;
const _socketDataRecv_t * pDataRecv = ( _socketDataRecv_t * ) pData;
int32_t nRecvCnt = 0;
if( pContext == NULL )
{
LogError( ( "Receive Data: invalid context" ) );
pktStatus = CELLULAR_PKT_STATUS_FAILURE;
}
else if( ( pAtResp == NULL ) || ( pAtResp->pItm == NULL ) || ( pAtResp->pItm->pLine == NULL ) )
{
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;
atCoreStatus = Cellular_ATRemovePrefix( &pInputLine );
/* parse the datalen. */
if( atCoreStatus == CELLULAR_AT_SUCCESS )
{
atCoreStatus = Cellular_ATGetNextTok( &pInputLine, &pToken );
}
if( atCoreStatus == CELLULAR_AT_SUCCESS )
{
atCoreStatus = Cellular_ATStrtoi( pToken, 10, &nRecvCnt );
if( ( atCoreStatus == CELLULAR_AT_SUCCESS ) &&
( nRecvCnt >= 0 ) && ( nRecvCnt <= CELLULAR_MAX_RECV_DATA_LEN ) )
{
*pDataRecv->pDataLen = nRecvCnt;
if( nRecvCnt == 0 )
{
/* all data received, next AT+CARECV need +CADATAIND: */
cellularModuleContext_t * pSimContex = ( cellularModuleContext_t * ) pContext->pModueContext;
xEventGroupClearBits( pSimContex->pdnEvent, CNACT_EVENT_BIT_IND );
}
}
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;
}