Skip to content

Commit

Permalink
Fix Spelling and Complexity.
Browse files Browse the repository at this point in the history
  • Loading branch information
ActoryOu committed Nov 19, 2024
1 parent 693b195 commit 613ce99
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 42 deletions.
100 changes: 59 additions & 41 deletions source/cellular_3gpp_urc_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
{
Expand All @@ -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;
}
}

Expand Down
2 changes: 1 addition & 1 deletion test/unit-test/cellular_3gpp_urc_handler_utest.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
{
Expand Down

0 comments on commit 613ce99

Please sign in to comment.