in modules/sara_r4/cellular_r4_urc_handler.c [371:464]
static void _cellular_UrcProcessUusoco( CellularContext_t * pContext,
char * pInputLine )
{
CellularATError_t atCoreStatus = CELLULAR_AT_SUCCESS;
char * pLocalInputLine = pInputLine;
char * pToken = NULL;
CellularSocketContext_t * pSocketData = NULL;
uint8_t sessionId = 0;
uint8_t socketError = 0;
uint32_t socketIndex = 0;
int32_t tempValue = 0;
if( ( pContext != NULL ) && ( pInputLine != NULL ) )
{
/* The inputline is in this format +UUSOCO: <socket>,<socket_error>
* socket_error = 0 : no error, others : error. */
atCoreStatus = Cellular_ATGetNextTok( &pLocalInputLine, &pToken );
if( atCoreStatus == CELLULAR_AT_SUCCESS )
{
atCoreStatus = Cellular_ATStrtoi( pToken, 10, &tempValue );
if( atCoreStatus == CELLULAR_AT_SUCCESS )
{
if( ( tempValue >= MIN_TCP_SESSION_ID ) && ( tempValue <= MAX_TCP_SESSION_ID ) )
{
sessionId = ( uint8_t ) tempValue;
socketIndex = _Cellular_GetSocketId( pContext, sessionId );
}
else
{
LogError( ( "parsing _cellular_UrcProcessKtcpInd session ID failed" ) );
atCoreStatus = CELLULAR_AT_ERROR;
}
}
}
if( atCoreStatus == CELLULAR_AT_SUCCESS )
{
atCoreStatus = Cellular_ATGetNextTok( &pLocalInputLine, &pToken );
}
if( atCoreStatus == CELLULAR_AT_SUCCESS )
{
atCoreStatus = Cellular_ATStrtoi( pToken, 10, &tempValue );
if( atCoreStatus == CELLULAR_AT_SUCCESS )
{
if( ( tempValue >= 0 ) && ( tempValue <= UINT8_MAX ) )
{
socketError = ( uint8_t ) tempValue;
}
else
{
LogError( ( "parsing _cellular_UrcProcessUusoco socket error failed" ) );
atCoreStatus = CELLULAR_AT_ERROR;
}
}
}
/* Call the callback function of this session. */
if( atCoreStatus == CELLULAR_AT_SUCCESS )
{
pSocketData = _Cellular_GetSocketData( pContext, socketIndex );
if( pSocketData == NULL )
{
LogError( ( "_cellular_UrcProcessUusoco : invalid socket index %u", socketIndex ) );
}
else
{
if( socketError == 0 )
{
pSocketData->socketState = SOCKETSTATE_CONNECTED;
LogDebug( ( "Notify session %d with socket opened\r\n", sessionId ) );
if( pSocketData->openCallback != NULL )
{
pSocketData->openCallback( CELLULAR_URC_SOCKET_OPENED,
pSocketData, pSocketData->pOpenCallbackContext );
}
}
else
{
if( pSocketData->openCallback != NULL )
{
pSocketData->openCallback( CELLULAR_URC_SOCKET_OPEN_FAILED,
pSocketData, pSocketData->pOpenCallbackContext );
}
}
}
}
}
}