@@ -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+ }
0 commit comments