Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update print log fmt #1

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 46 additions & 45 deletions source/cellular_3gpp_api.c

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions source/cellular_3gpp_urc_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ static CellularPktStatus_t _parseCellIdInRegStatus( const char * pToken,
}
else
{
LogError( ( "Error in processing Cell Id. Token %s", pToken ) );
LogError( ( "Error in processing Cell Id. Token %"CELLULAR_LOG_FMT_STR, pToken ) );
atCoreStatus = CELLULAR_AT_ERROR;
}
}
Expand All @@ -255,7 +255,7 @@ static CellularPktStatus_t _parseRatInfoInRegStatus( const char * pToken,
if( var >= ( int32_t ) CELLULAR_RAT_MAX )
{
atCoreStatus = CELLULAR_AT_ERROR;
LogError( ( "Error in processing RAT. Token %s", pToken ) );
LogError( ( "Error in processing RAT. Token %"CELLULAR_LOG_FMT_STR, pToken ) );
}
else if( ( var == ( int32_t ) CELLULAR_RAT_GSM ) || ( var == ( int32_t ) CELLULAR_RAT_EDGE ) ||
( var == ( int32_t ) CELLULAR_RAT_CATM1 ) || ( var == ( int32_t ) CELLULAR_RAT_NBIOT ) )
Expand Down Expand Up @@ -442,15 +442,15 @@ static void _regStatusGenerateLog( char * pRegPayload,

if( regType == CELLULAR_REG_TYPE_CREG )
{
LogDebug( ( "URC: CREG: %s", pRegPayload ) );
LogDebug( ( "URC: CREG: %"CELLULAR_LOG_FMT_STR, pRegPayload ) );
}
else if( regType == CELLULAR_REG_TYPE_CGREG )
{
LogDebug( ( "URC: CGREG: %s", pRegPayload ) );
LogDebug( ( "URC: CGREG: %"CELLULAR_LOG_FMT_STR, pRegPayload ) );
}
else if( regType == CELLULAR_REG_TYPE_CEREG )
{
LogDebug( ( "URC: CEREG: %s", pRegPayload ) );
LogDebug( ( "URC: CEREG: %"CELLULAR_LOG_FMT_STR, pRegPayload ) );
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion source/cellular_at_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ CellularATError_t Cellular_ATHexStrToHex( const char * pString,
}
else
{
firstNibble = firstNibble << 4;
firstNibble = ( uint8_t ) ( firstNibble << 4 );
( pHexData )[ i ] = firstNibble | secondNibble;
}

Expand Down
22 changes: 11 additions & 11 deletions source/cellular_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ static CellularError_t libOpen( CellularContext_t * pContext )

PlatformMutex_Lock( &pContext->libStatusMutex );

( CellularPktStatus_t ) _Cellular_AtParseInit( pContext );
( void ) _Cellular_AtParseInit( pContext );
_Cellular_LockAtDataMutex( pContext );
_Cellular_InitAtData( pContext, 0 );
_Cellular_UnlockAtDataMutex( pContext );
Expand Down Expand Up @@ -456,7 +456,7 @@ CellularError_t _Cellular_CheckLibraryStatus( CellularContext_t * pContext )

if( ( pContext->bLibShutdown == true ) || ( pContext->bLibClosing == true ) )
{
LogError( ( "Cellular Lib indicated a failure[%d][%d]", pContext->bLibShutdown, pContext->bLibClosing ) );
LogError( ( "Cellular Lib indicated a failure[%"CELLULAR_LOG_FMT_INT "][%"CELLULAR_LOG_FMT_INT "]", pContext->bLibShutdown, pContext->bLibClosing ) );
cellularStatus = CELLULAR_INTERNAL_FAILURE;
}

Expand Down Expand Up @@ -487,7 +487,7 @@ CellularError_t _Cellular_TranslatePktStatus( CellularPktStatus_t status )
case CELLULAR_PKT_STATUS_BAD_RESPONSE:
case CELLULAR_PKT_STATUS_SIZE_MISMATCH:
default:
LogError( ( "_Cellular_TranslatePktStatus: Status %d", status ) );
LogError( ( "_Cellular_TranslatePktStatus: Status %"CELLULAR_LOG_FMT_INT, status ) );
cellularStatus = CELLULAR_INTERNAL_FAILURE;
break;
}
Expand Down Expand Up @@ -517,7 +517,7 @@ CellularPktStatus_t _Cellular_TranslateAtCoreStatus( CellularATError_t status )
case CELLULAR_AT_ERROR:
case CELLULAR_AT_UNKNOWN:
default:
LogError( ( "_Cellular_TranslateAtCoreStatus: Status %d", status ) );
LogError( ( "_Cellular_TranslateAtCoreStatus: Status %"CELLULAR_LOG_FMT_INT, status ) );
pktStatus = CELLULAR_PKT_STATUS_FAILURE;
break;
}
Expand Down Expand Up @@ -599,7 +599,7 @@ CellularError_t _Cellular_RemoveSocketData( CellularContext_t * pContext,

if( socketHandle->socketState == SOCKETSTATE_CONNECTING )
{
LogWarn( ( "_Cellular_RemoveSocket, socket is connecting state [%u]", socketHandle->socketId ) );
LogWarn( ( "_Cellular_RemoveSocket, socket is connecting state [%"CELLULAR_LOG_FMT_UINT32 "]", socketHandle->socketId ) );
}

taskENTER_CRITICAL();
Expand Down Expand Up @@ -652,7 +652,7 @@ CellularError_t _Cellular_IsValidSocket( const CellularContext_t * pContext,
{
if( ( sockIndex >= CELLULAR_NUM_SOCKET_MAX ) || ( pContext->pSocketData[ sockIndex ] == NULL ) )
{
LogError( ( "_Cellular_IsValidSocket, invalid socket handle %u", sockIndex ) );
LogError( ( "_Cellular_IsValidSocket, invalid socket handle %"CELLULAR_LOG_FMT_UINT32, sockIndex ) );
cellularStatus = CELLULAR_BAD_PARAMETER;
}
}
Expand All @@ -668,7 +668,7 @@ CellularError_t _Cellular_IsValidPdn( uint8_t contextId )

if( ( contextId > CELLULAR_PDN_CONTEXT_ID_MAX ) || ( contextId < CELLULAR_PDN_CONTEXT_ID_MIN ) )
{
LogError( ( "_Cellular_IsValidPdn: ContextId out of range %d",
LogError( ( "_Cellular_IsValidPdn: ContextId out of range %"CELLULAR_LOG_FMT_INT,
contextId ) );
cellularStatus = CELLULAR_BAD_PARAMETER;
}
Expand Down Expand Up @@ -701,7 +701,7 @@ CellularError_t _Cellular_ConvertCsqSignalRssi( int16_t csqRssi,
}
else
{
rssiValue = SIGNAL_QUALITY_CSQ_RSSI_BASE + ( csqRssi * SIGNAL_QUALITY_CSQ_RSSI_STEP );
rssiValue = ( int16_t ) ( SIGNAL_QUALITY_CSQ_RSSI_BASE + csqRssi * SIGNAL_QUALITY_CSQ_RSSI_STEP );
}
}

Expand Down Expand Up @@ -797,12 +797,12 @@ CellularError_t _Cellular_ComputeSignalBars( CellularRat_t rat,
if( ( rat == CELLULAR_RAT_GSM ) || ( rat == CELLULAR_RAT_EDGE ) )
{
pSignalInfo->bars = _getSignalBars( pSignalInfo->rssi, rat );
LogDebug( ( "_computeSignalBars: RSSI %d Bars %d", pSignalInfo->rssi, pSignalInfo->bars ) );
LogDebug( ( "_computeSignalBars: RSSI %"CELLULAR_LOG_FMT_INT " Bars %"CELLULAR_LOG_FMT_INT, pSignalInfo->rssi, pSignalInfo->bars ) );
}
else if( ( rat == CELLULAR_RAT_LTE ) || ( rat == CELLULAR_RAT_CATM1 ) || ( rat == CELLULAR_RAT_NBIOT ) )
{
pSignalInfo->bars = _getSignalBars( pSignalInfo->rsrp, rat );
LogDebug( ( "_computeSignalBars: RSRP %d Bars %d", pSignalInfo->rsrp, pSignalInfo->bars ) );
LogDebug( ( "_computeSignalBars: RSRP %"CELLULAR_LOG_FMT_INT " Bars %"CELLULAR_LOG_FMT_INT, pSignalInfo->rsrp, pSignalInfo->bars ) );
}
else
{
Expand Down Expand Up @@ -916,7 +916,7 @@ CellularSocketContext_t * _Cellular_GetSocketData( const CellularContext_t * pCo
{
if( ( sockIndex >= CELLULAR_NUM_SOCKET_MAX ) || ( pContext->pSocketData[ sockIndex ] == NULL ) )
{
LogError( ( "_Cellular_GetSocketData, invalid socket handle %u", sockIndex ) );
LogError( ( "_Cellular_GetSocketData, invalid socket handle %"CELLULAR_LOG_FMT_UINT32, sockIndex ) );
}
else
{
Expand Down
4 changes: 2 additions & 2 deletions source/cellular_common_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ static CellularError_t _socketSetSockOptLevelTransport( CellularSocketOption_t o
}
else
{
LogError( ( "Cellular_SocketSetSockOpt: Cannot change the contextID in this state %d or length %d is invalid.",
LogError( ( "Cellular_SocketSetSockOpt: Cannot change the contextID in this state %"CELLULAR_LOG_FMT_INT " or length %"CELLULAR_LOG_FMT_UINT32 " is invalid.",
socketHandle->socketState, optionValueLength ) );
cellularStatus = CELLULAR_INTERNAL_FAILURE;
}
Expand All @@ -123,7 +123,7 @@ static CellularError_t _socketSetSockOptLevelTransport( CellularSocketOption_t o
}
else
{
LogError( ( "Cellular_SocketSetSockOpt: Cannot change the localPort in this state %d or length %d is invalid.",
LogError( ( "Cellular_SocketSetSockOpt: Cannot change the localPort in this state %"CELLULAR_LOG_FMT_INT " or length %"CELLULAR_LOG_FMT_UINT32 " is invalid.",
socketHandle->socketState, optionValueLength ) );
cellularStatus = CELLULAR_INTERNAL_FAILURE;
}
Expand Down
38 changes: 19 additions & 19 deletions source/cellular_pkthandler.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,12 @@ static CellularPktStatus_t _processUrcPacket( CellularContext_t * pContext,
if( atStatus != CELLULAR_AT_SUCCESS )
{
/* Fail to allocate memory. */
LogError( ( "Failed to allocate memory for URC [%s]", pBuf ) );
LogError( ( "Failed to allocate memory for URC [%"CELLULAR_LOG_FMT_STR "]", pBuf ) );
pktStatus = CELLULAR_PKT_STATUS_FAILURE;
}
else
{
LogDebug( ( "Next URC token to parse [%s]", pInputLine ) );
LogDebug( ( "Next URC token to parse [%"CELLULAR_LOG_FMT_STR "]", pInputLine ) );

/* Check if prefix exist in the input string. The pInputLine is checked in Cellular_ATStrDup. */
( void ) Cellular_ATIsPrefixPresent( pInputLine, &inputWithPrefix );
Expand All @@ -158,7 +158,7 @@ static CellularPktStatus_t _processUrcPacket( CellularContext_t * pContext,

if( pTokenPtr == NULL )
{
LogError( ( "_Cellular_AtParse : input string error, start with \"+\" but no token %s", pInputLine ) );
LogError( ( "_Cellular_AtParse : input string error, start with \"+\" but no token %"CELLULAR_LOG_FMT_STR, pInputLine ) );
pktStatus = CELLULAR_PKT_STATUS_BAD_REQUEST;
}
else
Expand All @@ -177,7 +177,7 @@ static CellularPktStatus_t _processUrcPacket( CellularContext_t * pContext,
if( pktStatus == CELLULAR_PKT_STATUS_PREFIX_MISMATCH )
{
/* No URC callback function available, check for generic callback. */
LogDebug( ( "No URC Callback func avail %s, now trying generic URC Callback", pTokenPtr ) );
LogDebug( ( "No URC Callback func avail %"CELLULAR_LOG_FMT_STR ", now trying generic URC Callback", pTokenPtr ) );

if( inputWithPrefix == true )
{
Expand Down Expand Up @@ -213,7 +213,7 @@ static CellularPktStatus_t _Cellular_AtcmdRequestTimeoutWithCallbackRaw( Cellula
}
else
{
LogDebug( ( ">>>>>Start sending [%s]<<<<<", atReq.pAtCmd ) );
LogDebug( ( ">>>>>Start sending [%"CELLULAR_LOG_FMT_STR "]<<<<<", atReq.pAtCmd ) );

/* Fill in request info structure. */
PlatformMutex_Lock( &pContext->PktRespMutex );
Expand All @@ -240,14 +240,14 @@ static CellularPktStatus_t _Cellular_AtcmdRequestTimeoutWithCallbackRaw( Cellula

if( pktStatus != CELLULAR_PKT_STATUS_OK )
{
LogWarn( ( "Modem returns error in sending AT command %s, pktStatus %d.",
LogWarn( ( "Modem returns error in sending AT command %"CELLULAR_LOG_FMT_STR ", pktStatus %"CELLULAR_LOG_FMT_INT ".",
atReq.pAtCmd, pktStatus ) );
} /* Ignore errors from callbacks as they will be handled elsewhere. */
}
else
{
pktStatus = CELLULAR_PKT_STATUS_TIMED_OUT;
LogError( ( "pkt_recv status=%d, AT cmd %s timed out", pktStatus, atReq.pAtCmd ) );
LogError( ( "pkt_recv status=%"CELLULAR_LOG_FMT_INT ", AT cmd %"CELLULAR_LOG_FMT_STR " timed out", pktStatus, atReq.pAtCmd ) );
}
}

Expand All @@ -257,7 +257,7 @@ static CellularPktStatus_t _Cellular_AtcmdRequestTimeoutWithCallbackRaw( Cellula
pContext->pktRespCB = NULL;
pContext->pCurrentCmd = NULL;
PlatformMutex_Unlock( &pContext->PktRespMutex );
LogDebug( ( "<<<<<Exit sending [%s] status[%d]<<<<<", atReq.pAtCmd, pktStatus ) );
LogDebug( ( "<<<<<Exit sending [%"CELLULAR_LOG_FMT_STR "] status[%"CELLULAR_LOG_FMT_INT "]<<<<<", atReq.pAtCmd, pktStatus ) );
}

return pktStatus;
Expand Down Expand Up @@ -329,21 +329,21 @@ static CellularPktStatus_t _Cellular_DataSendWithTimeoutDelayRaw( CellularContex
}
else
{
LogWarn( ( "Modem returns error in sending data, pktStatus %d.", pktStatus ) );
LogWarn( ( "Modem returns error in sending data, pktStatus %"CELLULAR_LOG_FMT_INT ".", pktStatus ) );
}
}
else
{
pktStatus = CELLULAR_PKT_STATUS_TIMED_OUT;
LogError( ( "pkt_recv status=%d, data sending timed out", pktStatus ) );
LogError( ( "pkt_recv status=%"CELLULAR_LOG_FMT_INT ", data sending timed out", pktStatus ) );
}

/* Set AT command type to CELLULAR_AT_NO_COMMAND for timeout case here. */
PlatformMutex_Lock( &pContext->PktRespMutex );
pContext->PktioAtCmdType = CELLULAR_AT_NO_COMMAND;
PlatformMutex_Unlock( &pContext->PktRespMutex );

LogDebug( ( "<<<<<Exit sending data ret[%d]>>>>>", pktStatus ) );
LogDebug( ( "<<<<<Exit sending data ret[%"CELLULAR_LOG_FMT_INT "]>>>>>", pktStatus ) );
}

return pktStatus;
Expand Down Expand Up @@ -456,7 +456,7 @@ static CellularPktStatus_t _atParseGetHandler( CellularContext_t * pContext,
}
else
{
LogWarn( ( "No URC Callback func avail %s", pTokenPtr ) );
LogWarn( ( "No URC Callback func avail %"CELLULAR_LOG_FMT_STR, pTokenPtr ) );
pktStatus = CELLULAR_PKT_STATUS_FAILURE;
}
}
Expand All @@ -479,13 +479,13 @@ static CellularPktStatus_t _handleUndefinedMessage( CellularContext_t * pContext
{
CellularPktStatus_t pktStatus = CELLULAR_PKT_STATUS_OK;

LogInfo( ( "AT_UNDEFINED message received %s\r\n", pLine ) );
LogInfo( ( "AT_UNDEFINED message received %"CELLULAR_LOG_FMT_STR "\r\n", pLine ) );

/* undefined message received. Try to handle it with cellular module
* specific handler. */
if( pContext->undefinedRespCallback == NULL )
{
LogError( ( "No undefined callback for AT_UNDEFINED type message %s received.",
LogError( ( "No undefined callback for AT_UNDEFINED type message %"CELLULAR_LOG_FMT_STR " received.",
pLine ) );
pktStatus = CELLULAR_PKT_STATUS_INVALID_DATA;
}
Expand All @@ -495,7 +495,7 @@ static CellularPktStatus_t _handleUndefinedMessage( CellularContext_t * pContext

if( pktStatus != CELLULAR_PKT_STATUS_OK )
{
LogError( ( "undefinedRespCallback returns error %d for AT_UNDEFINED type message %s received.",
LogError( ( "undefinedRespCallback returns error %"CELLULAR_LOG_FMT_INT " for AT_UNDEFINED type message %"CELLULAR_LOG_FMT_STR " received.",
pktStatus, pLine ) );
pktStatus = CELLULAR_PKT_STATUS_INVALID_DATA;
}
Expand Down Expand Up @@ -554,7 +554,7 @@ CellularPktStatus_t _Cellular_HandlePacket( CellularContext_t * pContext,

default:
pktStatus = CELLULAR_PKT_STATUS_BAD_PARAM;
LogError( ( "_Cellular_HandlePacket Callback type (%d) error", atRespType ) );
LogError( ( "_Cellular_HandlePacket Callback type (%"CELLULAR_LOG_FMT_INT ") error", atRespType ) );
break;
}
}
Expand Down Expand Up @@ -820,8 +820,8 @@ CellularPktStatus_t _Cellular_AtParseInit( const CellularContext_t * pContext )

if( result >= 0 )
{
LogError( ( "AtParseFail for %u: %d %s %s", i, result,
pTokenMap[ i ].pStrValue, pTokenMap[ i + 1U ].pStrValue ) );
LogError( ( "AtParseFail for %"CELLULAR_LOG_FMT_UINT32 ": %"CELLULAR_LOG_FMT_INT32 " %"CELLULAR_LOG_FMT_STR " %"CELLULAR_LOG_FMT_STR,
i, result, pTokenMap[ i ].pStrValue, pTokenMap[ i + 1U ].pStrValue ) );
finit = false;
}
}
Expand All @@ -836,7 +836,7 @@ CellularPktStatus_t _Cellular_AtParseInit( const CellularContext_t * pContext )

for( i = 0; i < tokenMapSize; i++ )
{
LogDebug( ( "Callbacks setup for %u : %s", i, pTokenMap[ i ].pStrValue ) );
LogDebug( ( "Callbacks setup for %"CELLULAR_LOG_FMT_UINT32 " : %"CELLULAR_LOG_FMT_STR, i, pTokenMap[ i ].pStrValue ) );
}
}
else
Expand Down
Loading
Loading