static _atRespType_t _getMsgType()

in source/cellular_pktio.c [401:457]


static _atRespType_t _getMsgType( const CellularContext_t * pContext,
                                  const char * pLine,
                                  const char * pRespPrefix )
{
    _atRespType_t atRespType = AT_UNDEFINED;
    CellularATError_t atStatus = CELLULAR_AT_SUCCESS;
    bool inputWithPrefix = false;
    bool inputWithSrcPrefix = false;

    if( pContext->tokenTable.pCellularUrcTokenWoPrefixTable == NULL )
    {
        atStatus = CELLULAR_AT_ERROR;
        atRespType = AT_UNDEFINED;
    }
    else if( urcTokenWoPrefix( pContext, pLine ) == true )
    {
        atRespType = AT_UNSOLICITED;
    }
    else
    {
        /* Check if prefix exist in pLine. */
        ( void ) Cellular_ATIsPrefixPresent( pLine, &inputWithPrefix );

        if( ( inputWithPrefix == true ) && ( pRespPrefix != NULL ) )
        {
            /* Check if SRC prefix exist in pLine. */
            atStatus = Cellular_ATStrStartWith( pLine, pRespPrefix, &inputWithSrcPrefix );
        }
    }

    if( ( atStatus == CELLULAR_AT_SUCCESS ) && ( atRespType == AT_UNDEFINED ) )
    {
        if( inputWithPrefix == true )
        {
            if( ( pContext->PktioAtCmdType != CELLULAR_AT_NO_COMMAND ) && ( inputWithSrcPrefix == true ) )
            {
                atRespType = AT_SOLICITED;
            }
            else
            {
                atRespType = AT_UNSOLICITED;
            }
        }
        else
        {
            if( ( ( pContext->PktioAtCmdType != CELLULAR_AT_NO_COMMAND ) && ( pRespPrefix == NULL ) ) ||
                ( pContext->PktioAtCmdType == CELLULAR_AT_MULTI_DATA_WO_PREFIX ) ||
                ( pContext->PktioAtCmdType == CELLULAR_AT_WITH_PREFIX ) ||
                ( pContext->PktioAtCmdType == CELLULAR_AT_MULTI_WITH_PREFIX ) )
            {
                atRespType = AT_SOLICITED;
            }
        }
    }

    return atRespType;
}