Skip to content

Commit 11c2d51

Browse files
authored
Fix SARA-R4 cellular module compile warning (#24)
* Fix SARA-R4 compile warning as well as log format compile warning in cellular common.
1 parent 5d2aca7 commit 11c2d51

6 files changed

Lines changed: 261 additions & 167 deletions

File tree

modules/sara_r4/cellular_r4.c

Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,12 @@ static CellularError_t _Cellular_GetCurrentMNOProfile( CellularContext_t * pCont
238238
CELLULAR_AT_WITH_PREFIX,
239239
"+UMNOPROF",
240240
_Cellular_RecvFuncGetCurrentMNOProfile,
241-
pCurrentMNOProfile,
241+
NULL,
242242
sizeof( MNOProfileType_t ),
243243
};
244244

245+
atReqGetCurrentMNOProfile.pData = pCurrentMNOProfile;
246+
245247
/* Internal function. Callee check parameters. */
246248
pktStatus = _Cellular_AtcmdRequestWithCallback( pContext, atReqGetCurrentMNOProfile );
247249
cellularStatus = _Cellular_TranslatePktStatus( pktStatus );
@@ -259,7 +261,7 @@ CellularError_t rebootCellularModem( CellularContext_t * pContext,
259261
{
260262
CellularError_t cellularStatus = CELLULAR_SUCCESS;
261263
CellularPktStatus_t pktStatus = CELLULAR_PKT_STATUS_OK;
262-
int count = 0;
264+
uint32_t count = 0;
263265

264266
CellularAtReq_t atReqGetNoResult =
265267
{
@@ -490,11 +492,58 @@ uint32_t _Cellular_GetSocketId( CellularContext_t * pContext,
490492
cellularStatus = CELLULAR_BAD_PARAMETER;
491493
}
492494

493-
if( ( cellularStatus == CELLULAR_SUCCESS ) &&
494-
( sessionId >= MIN_TCP_SESSION_ID ) && ( sessionId <= MAX_TCP_SESSION_ID ) )
495+
if( ( cellularStatus == CELLULAR_SUCCESS ) && ( sessionId <= ( ( uint8_t ) MAX_TCP_SESSION_ID ) ) )
495496
{
496497
socketIndex = pModuleContext->pSessionMap[ sessionId ];
497498
}
498499

499500
return socketIndex;
500501
}
502+
503+
/*-----------------------------------------------------------*/
504+
505+
uint32_t _Cellular_GetSessionId( CellularContext_t * pContext,
506+
uint32_t socketIndex )
507+
{
508+
cellularModuleContext_t * pModuleContext = NULL;
509+
CellularError_t cellularStatus = CELLULAR_SUCCESS;
510+
uint32_t sessionId = INVALID_SESSION_ID;
511+
512+
if( pContext == NULL )
513+
{
514+
LogError( ( "_Cellular_GetSessionId invalid cellular context" ) );
515+
cellularStatus = CELLULAR_BAD_PARAMETER;
516+
}
517+
else if( socketIndex == INVALID_SOCKET_INDEX )
518+
{
519+
LogError( ( "_Cellular_GetSessionId invalid socketIndex" ) );
520+
cellularStatus = CELLULAR_BAD_PARAMETER;
521+
}
522+
else
523+
{
524+
cellularStatus = _Cellular_GetModuleContext( pContext, ( void ** ) &pModuleContext );
525+
}
526+
527+
if( cellularStatus == CELLULAR_SUCCESS )
528+
{
529+
for( sessionId = 0; sessionId < TCP_SESSION_TABLE_LEGNTH; sessionId++ )
530+
{
531+
if( pModuleContext->pSessionMap[ sessionId ] == socketIndex )
532+
{
533+
break;
534+
}
535+
}
536+
537+
/* Mapping is not found in the session mapping table. */
538+
if( sessionId == TCP_SESSION_TABLE_LEGNTH )
539+
{
540+
sessionId = INVALID_SESSION_ID;
541+
}
542+
}
543+
else
544+
{
545+
sessionId = INVALID_SESSION_ID;
546+
}
547+
548+
return sessionId;
549+
}

modules/sara_r4/cellular_r4.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,12 @@
3434

3535
/*-----------------------------------------------------------*/
3636

37-
#define MIN_TCP_SESSION_ID ( 0U )
38-
#define MAX_TCP_SESSION_ID ( 6U )
37+
#define MIN_TCP_SESSION_ID ( 0 )
38+
#define MAX_TCP_SESSION_ID ( 6 )
3939
#define TCP_SESSION_TABLE_LEGNTH ( MAX_TCP_SESSION_ID + 1 )
4040

4141
#define INVALID_SOCKET_INDEX ( UINT32_MAX )
42+
#define INVALID_SESSION_ID ( UINT32_MAX )
4243

4344
/*-----------------------------------------------------------*/
4445

@@ -52,6 +53,9 @@ typedef struct cellularModuleContext
5253
uint32_t _Cellular_GetSocketId( CellularContext_t * pContext,
5354
uint8_t sessionId );
5455

56+
uint32_t _Cellular_GetSessionId( CellularContext_t * pContext,
57+
uint32_t socketIndex );
58+
5559
CellularError_t rebootCellularModem( CellularContext_t * pContext,
5660
bool disablePsm,
5761
bool disableEidrx );

0 commit comments

Comments
 (0)