Skip to content

Commit 195e640

Browse files
authored
[Cellular Library] Align the logging method with the other library. (#34)
* [Cellular Library] Align the logging method with the other library. * [Cellular Library] Fix complexity and remove unused file. * [Cellular Library] Remove all prefix Cellular in Log functions.
1 parent ae477e6 commit 195e640

23 files changed

Lines changed: 1125 additions & 750 deletions

common/src/cellular_3gpp_api.c

Lines changed: 139 additions & 145 deletions
Large diffs are not rendered by default.

common/src/cellular_3gpp_urc_handler.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -138,22 +138,22 @@ static CellularPktStatus_t _parseRegStatusInRegStatusParsing( CellularContext_t
138138

139139
if( regStatus == REGISTRATION_STATUS_REGISTERED_HOME )
140140
{
141-
CellularLogDebug( "Netowrk registration : HOME" );
141+
LogDebug( ( "Netowrk registration : HOME" ) );
142142
}
143143
else if( regStatus == REGISTRATION_STATUS_ROAMING_REGISTERED )
144144
{
145-
CellularLogDebug( "Netowrk registration : ROAMING" );
145+
LogDebug( ( "Netowrk registration : ROAMING" ) );
146146
}
147147
else if( regStatus == REGISTRATION_STATUS_REGISTRATION_DENIED )
148148
{
149149
/* clear the atlib data if the registration failed. */
150-
CellularLogDebug( "Netowrk registration : DEINED" );
150+
LogDebug( ( "Netowrk registration : DEINED" ) );
151151
_Cellular_InitAtData( pContext, 1 );
152152
}
153153
else
154154
{
155155
/* clear the atlib data if the registration failed. */
156-
CellularLogDebug( "Netowrk registration : OTHERS" );
156+
LogDebug( ( "Netowrk registration : OTHERS" ) );
157157
_Cellular_InitAtData( pContext, 1 );
158158
}
159159
}
@@ -227,7 +227,7 @@ static CellularPktStatus_t _parseCellIdInRegStatus( const char * pToken,
227227
}
228228
else
229229
{
230-
CellularLogError( "Error in processing Cell Id. Token %s", pToken );
230+
LogError( ( "Error in processing Cell Id. Token %s", pToken ) );
231231
atCoreStatus = CELLULAR_AT_ERROR;
232232
}
233233
}
@@ -252,7 +252,7 @@ static CellularPktStatus_t _parseRatInfoInRegStatus( const char * pToken,
252252
if( var >= ( int32_t ) CELLULAR_RAT_MAX )
253253
{
254254
atCoreStatus = CELLULAR_AT_ERROR;
255-
CellularLogError( "Error in processing RAT. Token %s", pToken );
255+
LogError( ( "Error in processing RAT. Token %s", pToken ) );
256256
}
257257
else if( ( var == ( int32_t ) CELLULAR_RAT_GSM ) || ( var == ( int32_t ) CELLULAR_RAT_EDGE ) ||
258258
( var == ( int32_t ) CELLULAR_RAT_CATM1 ) || ( var == ( int32_t ) CELLULAR_RAT_NBIOT ) )
@@ -424,7 +424,7 @@ static CellularPktStatus_t _regStatusSwitchParsingFunc( CellularContext_t * pCon
424424
break;
425425

426426
default:
427-
CellularLogDebug( "Unknown Parameter Position in Registration URC" );
427+
LogDebug( ( "Unknown Parameter Position in Registration URC" ) );
428428
break;
429429
}
430430

@@ -440,19 +440,19 @@ static void _regStatusGenerateLog( char * pRegPayload,
440440

441441
if( regType == CELLULAR_REG_TYPE_CREG )
442442
{
443-
CellularLogDebug( "URC: CREG: %s", pRegPayload );
443+
LogDebug( ( "URC: CREG: %s", pRegPayload ) );
444444
}
445445
else if( regType == CELLULAR_REG_TYPE_CGREG )
446446
{
447-
CellularLogDebug( "URC: CGREG: %s", pRegPayload );
447+
LogDebug( ( "URC: CGREG: %s", pRegPayload ) );
448448
}
449449
else if( regType == CELLULAR_REG_TYPE_CEREG )
450450
{
451-
CellularLogDebug( "URC: CEREG: %s", pRegPayload );
451+
LogDebug( ( "URC: CEREG: %s", pRegPayload ) );
452452
}
453453
else
454454
{
455-
CellularLogDebug( " URC: Unknown " );
455+
LogDebug( ( " URC: Unknown " ) );
456456
}
457457
}
458458

@@ -525,7 +525,7 @@ static bool _Cellular_RegEventStatus( const cellularAtData_t * pLibAtData,
525525
break;
526526

527527
default:
528-
CellularLogInfo( "_Cellular_RegEventStatus : unknown reg type " );
528+
LogInfo( ( "_Cellular_RegEventStatus : unknown reg type " ) );
529529
break;
530530
}
531531

@@ -633,7 +633,7 @@ CellularPktStatus_t Cellular_CommonUrcProcessCreg( CellularContext_t * pContext,
633633

634634
if( pktStatus != CELLULAR_PKT_STATUS_OK )
635635
{
636-
CellularLogDebug( "Creg Parse failure" );
636+
LogDebug( ( "Creg Parse failure" ) );
637637
}
638638

639639
_Cellular_UnlockAtDataMutex( pContext );
@@ -660,7 +660,7 @@ CellularPktStatus_t Cellular_CommonUrcProcessCgreg( CellularContext_t * pContext
660660

661661
if( pktStatus != CELLULAR_PKT_STATUS_OK )
662662
{
663-
CellularLogDebug( "Cgreg Parse failure" );
663+
LogDebug( ( "Cgreg Parse failure" ) );
664664
}
665665

666666
_Cellular_UnlockAtDataMutex( pContext );
@@ -687,7 +687,7 @@ CellularPktStatus_t Cellular_CommonUrcProcessCereg( CellularContext_t * pContext
687687

688688
if( pktStatus != CELLULAR_PKT_STATUS_OK )
689689
{
690-
CellularLogDebug( "Cereg Parse failure" );
690+
LogDebug( ( "Cereg Parse failure" ) );
691691
}
692692

693693
_Cellular_UnlockAtDataMutex( pContext );

common/src/cellular_common.c

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ static CellularError_t libOpen( CellularContext_t * pContext )
202202

203203
if( pktStatus != CELLULAR_PKT_STATUS_OK )
204204
{
205-
CellularLogError( "pktio failed to initialize" );
205+
LogError( ( "pktio failed to initialize" ) );
206206
_Cellular_PktioShutdown( pContext );
207207
_Cellular_PktHandlerCleanup( pContext );
208208
}
@@ -268,7 +268,7 @@ static void libClose( CellularContext_t * pContext )
268268
}
269269

270270
PlatformMutex_Unlock( &pContext->libStatusMutex );
271-
CellularLogDebug( "CELLULARLib closed" );
271+
LogDebug( ( "CELLULARLib closed" ) );
272272
}
273273

274274
/*-----------------------------------------------------------*/
@@ -390,22 +390,22 @@ static CellularError_t checkInitParameter( const CellularHandle_t * pCellularHan
390390

391391
if( pCellularHandle == NULL )
392392
{
393-
CellularLogError( "Invalid CellularHandler pointer." );
393+
LogError( ( "Invalid CellularHandler pointer." ) );
394394
cellularStatus = CELLULAR_INVALID_HANDLE;
395395
}
396396
else if( ( pCommInterface == NULL ) || ( pCommInterface->open == NULL ) ||
397397
( pCommInterface->close == NULL ) || ( pCommInterface->send == NULL ) ||
398398
( pCommInterface->recv == NULL ) )
399399
{
400-
CellularLogError( "All the functions in the CellularCommInterface should be valid." );
400+
LogError( ( "All the functions in the CellularCommInterface should be valid." ) );
401401
cellularStatus = CELLULAR_BAD_PARAMETER;
402402
}
403403
else if( ( pTokenTable == NULL ) || ( pTokenTable->pCellularUrcHandlerTable == NULL ) ||
404404
( pTokenTable->pCellularSrcTokenErrorTable == NULL ) ||
405405
( pTokenTable->pCellularSrcTokenSuccessTable == NULL ) ||
406406
( pTokenTable->pCellularUrcTokenWoPrefixTable == NULL ) )
407407
{
408-
CellularLogError( "All the token tables in the CellularTokenTable should be valid." );
408+
LogError( ( "All the token tables in the CellularTokenTable should be valid." ) );
409409
cellularStatus = CELLULAR_BAD_PARAMETER;
410410
}
411411
else
@@ -453,7 +453,7 @@ CellularError_t _Cellular_CheckLibraryStatus( CellularContext_t * pContext )
453453

454454
if( ( pContext->bLibShutdown == true ) || ( pContext->bLibClosing == true ) )
455455
{
456-
CellularLogError( "Cellular Lib indicated a failure[%d][%d]", pContext->bLibShutdown, pContext->bLibClosing );
456+
LogError( ( "Cellular Lib indicated a failure[%d][%d]", pContext->bLibShutdown, pContext->bLibClosing ) );
457457
cellularStatus = CELLULAR_INTERNAL_FAILURE;
458458
}
459459

@@ -484,7 +484,7 @@ CellularError_t _Cellular_TranslatePktStatus( CellularPktStatus_t status )
484484
case CELLULAR_PKT_STATUS_BAD_RESPONSE:
485485
case CELLULAR_PKT_STATUS_SIZE_MISMATCH:
486486
default:
487-
CellularLogError( "_Cellular_TranslatePktStatus: Status %d", status );
487+
LogError( ( "_Cellular_TranslatePktStatus: Status %d", status ) );
488488
cellularStatus = CELLULAR_INTERNAL_FAILURE;
489489
break;
490490
}
@@ -514,7 +514,7 @@ CellularPktStatus_t _Cellular_TranslateAtCoreStatus( CellularATError_t status )
514514
case CELLULAR_AT_ERROR:
515515
case CELLULAR_AT_UNKNOWN:
516516
default:
517-
CellularLogError( "_Cellular_TranslateAtCoreStatus: Status %d", status );
517+
LogError( ( "_Cellular_TranslateAtCoreStatus: Status %d", status ) );
518518
pktStatus = CELLULAR_PKT_STATUS_FAILURE;
519519
break;
520520
}
@@ -571,11 +571,11 @@ CellularError_t _Cellular_CreateSocketData( CellularContext_t * pContext,
571571

572572
if( cellularStatus == CELLULAR_NO_MEMORY )
573573
{
574-
CellularLogError( "_Cellular_CreateSocket, Out of memory" );
574+
LogError( ( "_Cellular_CreateSocket, Out of memory" ) );
575575
}
576576
else if( socketId >= CELLULAR_NUM_SOCKET_MAX )
577577
{
578-
CellularLogError( "_Cellular_CreateSocket, No free socket slots are available" );
578+
LogError( ( "_Cellular_CreateSocket, No free socket slots are available" ) );
579579
cellularStatus = CELLULAR_NO_MEMORY;
580580
}
581581
else
@@ -596,7 +596,7 @@ CellularError_t _Cellular_RemoveSocketData( CellularContext_t * pContext,
596596

597597
if( socketHandle->socketState == SOCKETSTATE_CONNECTING )
598598
{
599-
CellularLogWarn( "_Cellular_RemoveSocket, socket is connecting state [%d]", socketHandle->socketId );
599+
LogWarn( ( "_Cellular_RemoveSocket, socket is connecting state [%d]", socketHandle->socketId ) );
600600
}
601601

602602
taskENTER_CRITICAL();
@@ -649,7 +649,7 @@ CellularError_t _Cellular_IsValidSocket( const CellularContext_t * pContext,
649649
{
650650
if( ( sockIndex >= CELLULAR_NUM_SOCKET_MAX ) || ( pContext->pSocketData[ sockIndex ] == NULL ) )
651651
{
652-
CellularLogError( "_Cellular_IsValidSocket, invalid socket handle %d", sockIndex );
652+
LogError( ( "_Cellular_IsValidSocket, invalid socket handle %d", sockIndex ) );
653653
cellularStatus = CELLULAR_BAD_PARAMETER;
654654
}
655655
}
@@ -665,8 +665,8 @@ CellularError_t _Cellular_IsValidPdn( uint8_t contextId )
665665

666666
if( ( contextId > CELLULAR_PDN_CONTEXT_ID_MAX ) || ( contextId < CELLULAR_PDN_CONTEXT_ID_MIN ) )
667667
{
668-
CellularLogError( "_Cellular_IsValidPdn: ContextId out of range %d",
669-
contextId );
668+
LogError( ( "_Cellular_IsValidPdn: ContextId out of range %d",
669+
contextId ) );
670670
cellularStatus = CELLULAR_BAD_PARAMETER;
671671
}
672672

@@ -794,12 +794,12 @@ CellularError_t _Cellular_ComputeSignalBars( CellularRat_t rat,
794794
if( ( rat == CELLULAR_RAT_GSM ) || ( rat == CELLULAR_RAT_EDGE ) )
795795
{
796796
pSignalInfo->bars = _getSignalBars( pSignalInfo->rssi, rat );
797-
CellularLogDebug( "_computeSignalBars: RSSI %d Bars %d", pSignalInfo->rssi, pSignalInfo->bars );
797+
LogDebug( ( "_computeSignalBars: RSSI %d Bars %d", pSignalInfo->rssi, pSignalInfo->bars ) );
798798
}
799799
else if( ( rat == CELLULAR_RAT_LTE ) || ( rat == CELLULAR_RAT_CATM1 ) || ( rat == CELLULAR_RAT_NBIOT ) )
800800
{
801801
pSignalInfo->bars = _getSignalBars( pSignalInfo->rsrp, rat );
802-
CellularLogDebug( "_computeSignalBars: RSRP %d Bars %d", pSignalInfo->rsrp, pSignalInfo->bars );
802+
LogDebug( ( "_computeSignalBars: RSRP %d Bars %d", pSignalInfo->rsrp, pSignalInfo->bars ) );
803803
}
804804
else
805805
{
@@ -822,7 +822,7 @@ CellularError_t _Cellular_GetCurrentRat( CellularContext_t * pContext,
822822

823823
if( cellularStatus != CELLULAR_SUCCESS )
824824
{
825-
CellularLogDebug( "_Cellular_CheckLibraryStatus failed" );
825+
LogDebug( ( "_Cellular_CheckLibraryStatus failed" ) );
826826
}
827827
else if( pRat == NULL )
828828
{
@@ -907,13 +907,13 @@ CellularSocketContext_t * _Cellular_GetSocketData( const CellularContext_t * pCo
907907

908908
if( pContext == NULL )
909909
{
910-
CellularLogError( "Invalid context" );
910+
LogError( ( "Invalid context" ) );
911911
}
912912
else
913913
{
914914
if( ( sockIndex >= CELLULAR_NUM_SOCKET_MAX ) || ( pContext->pSocketData[ sockIndex ] == NULL ) )
915915
{
916-
CellularLogError( "_Cellular_GetSocketData, invalid socket handle %d", sockIndex );
916+
LogError( ( "_Cellular_GetSocketData, invalid socket handle %d", sockIndex ) );
917917
}
918918
else
919919
{
@@ -941,15 +941,15 @@ CellularError_t _Cellular_LibInit( CellularHandle_t * pCellularHandle,
941941

942942
if( cellularStatus != CELLULAR_SUCCESS )
943943
{
944-
CellularLogError( "_Cellular_CommonInit checkInitParameter failed" );
944+
LogError( ( "_Cellular_CommonInit checkInitParameter failed" ) );
945945
}
946946
else
947947
{
948948
pContext = _Cellular_AllocContext();
949949

950950
if( pContext == NULL )
951951
{
952-
CellularLogError( "CellularContext_t allocation failed" );
952+
LogError( ( "CellularContext_t allocation failed" ) );
953953
cellularStatus = CELLULAR_NO_MEMORY;
954954
}
955955
else
@@ -967,7 +967,7 @@ CellularError_t _Cellular_LibInit( CellularHandle_t * pCellularHandle,
967967
{
968968
if( _Cellular_CreateLibStatusMutex( pContext ) != true )
969969
{
970-
CellularLogError( "Could not create CellularLib status mutex" );
970+
LogError( ( "Could not create CellularLib status mutex" ) );
971971
cellularStatus = CELLULAR_RESOURCE_CREATION_FAIL;
972972
}
973973
else
@@ -980,7 +980,7 @@ CellularError_t _Cellular_LibInit( CellularHandle_t * pCellularHandle,
980980
{
981981
if( _Cellular_CreateAtDataMutex( pContext ) != true )
982982
{
983-
CellularLogError( "Could not create CELLULAR AT Data mutex " );
983+
LogError( ( "Could not create CELLULAR AT Data mutex " ) );
984984
cellularStatus = CELLULAR_RESOURCE_CREATION_FAIL;
985985
}
986986
else
@@ -993,7 +993,7 @@ CellularError_t _Cellular_LibInit( CellularHandle_t * pCellularHandle,
993993
{
994994
if( _Cellular_CreatePktRequestMutex( pContext ) != true )
995995
{
996-
CellularLogError( "Could not create CELLULAR Pkt Req mutex " );
996+
LogError( ( "Could not create CELLULAR Pkt Req mutex " ) );
997997
cellularStatus = CELLULAR_RESOURCE_CREATION_FAIL;
998998
}
999999
else
@@ -1006,7 +1006,7 @@ CellularError_t _Cellular_LibInit( CellularHandle_t * pCellularHandle,
10061006
{
10071007
if( _Cellular_CreatePktResponseMutex( pContext ) != true )
10081008
{
1009-
CellularLogError( "Could not create CELLULAR Pkt Resp mutex " );
1009+
LogError( ( "Could not create CELLULAR Pkt Resp mutex " ) );
10101010
cellularStatus = CELLULAR_RESOURCE_CREATION_FAIL;
10111011
}
10121012
else

0 commit comments

Comments
 (0)