diff --git a/source/cellular_3gpp_urc_handler.c b/source/cellular_3gpp_urc_handler.c index dba4bb6a..6b13f929 100644 --- a/source/cellular_3gpp_urc_handler.c +++ b/source/cellular_3gpp_urc_handler.c @@ -733,17 +733,48 @@ CellularPktStatus_t _Cellular_ParseRegStatus( CellularContext_t * pContext, packetStatus = CELLULAR_PKT_STATUS_BAD_PARAM; } else + { + /* Empty else MISRA 15.7 */ + } + + if( packetStatus == CELLULAR_PKT_STATUS_OK ) { pLibAtData = &( pContext->libAtData ); - if( isUrc == true ) + pRegStr = pRegPayload; + + switch( regType ) { - i++; + case CELLULAR_REG_TYPE_CREG: + pRegStatusParsingFunc = _regStatusSwitchParsingFuncCreg; + break; + + case CELLULAR_REG_TYPE_CGREG: + pRegStatusParsingFunc = _regStatusSwitchParsingFuncCgreg; + break; + + case CELLULAR_REG_TYPE_CEREG: + pRegStatusParsingFunc = _regStatusSwitchParsingFuncCereg; + break; + + default: + LogDebug( ( "Unknown Registration Type %d", regType ) ); + atCoreStatus = CELLULAR_AT_BAD_PARAMETER; + break; } - pRegStr = pRegPayload; + if( atCoreStatus != CELLULAR_AT_SUCCESS ) + { + packetStatus = _Cellular_TranslateAtCoreStatus( atCoreStatus ); + } + } - atCoreStatus = Cellular_ATRemoveAllDoubleQuote( pRegStr ); + if( packetStatus == CELLULAR_PKT_STATUS_OK ) + { + if( atCoreStatus == CELLULAR_AT_SUCCESS ) + { + atCoreStatus = Cellular_ATRemoveAllDoubleQuote( pRegStr ); + } if( atCoreStatus == CELLULAR_AT_SUCCESS ) { @@ -755,51 +786,38 @@ CellularPktStatus_t _Cellular_ParseRegStatus( CellularContext_t * pContext, atCoreStatus = Cellular_ATGetNextTok( &pRegStr, &pToken ); } - if( atCoreStatus == CELLULAR_AT_SUCCESS ) + if( atCoreStatus != CELLULAR_AT_SUCCESS ) { - switch( regType ) - { - case CELLULAR_REG_TYPE_CREG: - pRegStatusParsingFunc = _regStatusSwitchParsingFuncCreg; - break; - - case CELLULAR_REG_TYPE_CGREG: - pRegStatusParsingFunc = _regStatusSwitchParsingFuncCgreg; - break; - - case CELLULAR_REG_TYPE_CEREG: - pRegStatusParsingFunc = _regStatusSwitchParsingFuncCereg; - break; - - default: - LogDebug( ( "Unknown Registration Type %d", regType ) ); - atCoreStatus = CELLULAR_AT_BAD_PARAMETER; - break; - } + packetStatus = _Cellular_TranslateAtCoreStatus( atCoreStatus ); } + } - if( atCoreStatus == CELLULAR_AT_SUCCESS ) + if( packetStatus == CELLULAR_PKT_STATUS_OK ) + { + if( isUrc == true ) { - /* Backup the previous regStatus. */ - prevCsRegStatus = pLibAtData->csRegStatus; - prevPsRegStatus = pLibAtData->psRegStatus; + i++; + } - while( pToken != NULL ) - { - i++; + /* Backup the previous regStatus. */ + prevCsRegStatus = pLibAtData->csRegStatus; + prevPsRegStatus = pLibAtData->psRegStatus; + + while( pToken != NULL ) + { + i++; - packetStatus = pRegStatusParsingFunc( pContext, i, pToken, pLibAtData ); + packetStatus = pRegStatusParsingFunc( pContext, i, pToken, pLibAtData ); - if( packetStatus != CELLULAR_PKT_STATUS_OK ) - { - break; - } + if( packetStatus != CELLULAR_PKT_STATUS_OK ) + { + break; + } - /* Getting next token to parse. */ - if( Cellular_ATGetNextTok( &pRegStr, &pToken ) != CELLULAR_AT_SUCCESS ) - { - break; - } + /* Getting next token to parse. */ + if( Cellular_ATGetNextTok( &pRegStr, &pToken ) != CELLULAR_AT_SUCCESS ) + { + break; } } diff --git a/test/unit-test/cellular_3gpp_urc_handler_utest.c b/test/unit-test/cellular_3gpp_urc_handler_utest.c index 394e20db..fe47fd2d 100644 --- a/test/unit-test/cellular_3gpp_urc_handler_utest.c +++ b/test/unit-test/cellular_3gpp_urc_handler_utest.c @@ -1073,7 +1073,7 @@ void test_Cellular_ParseRegStatus_Regs_TooManyParametersInCgreg( void ) } /** - * @brief Test that more paremeters in +CEEG response. + * @brief Test that more paremeters in +CEREG response. */ void test_Cellular_ParseRegStatus_Regs_TooManyParametersInCereg( void ) {