@@ -728,7 +728,8 @@ static CellularPktStatus_t _handleMsgType( CellularContext_t * pContext,
728728
729729static bool _findLineInStream ( CellularContext_t * pContext ,
730730 char * pLine ,
731- uint32_t bytesRead )
731+ uint32_t bytesRead ,
732+ uint32_t * pLineLength )
732733{
733734 bool keepProcess = true;
734735 char * pTempLine = pLine ;
@@ -747,6 +748,7 @@ static bool _findLineInStream( CellularContext_t * pContext,
747748 if ( i < bytesRead )
748749 {
749750 pTempLine [ i ] = '\0' ;
751+ * pLineLength = i ;
750752 }
751753 else
752754 {
@@ -833,11 +835,6 @@ static bool _preprocessLine( CellularContext_t * pContext,
833835 /* This is the case AT command don't need data send or data receive prefix. */
834836 /* MISRA empty else. */
835837 }
836-
837- if ( keepProcess == true )
838- {
839- keepProcess = _findLineInStream ( pContext , pTempLine , * pBytesRead );
840- }
841838 }
842839
843840 return keepProcess ;
@@ -877,17 +874,14 @@ static bool _handleDataResult( CellularContext_t * pContext,
877874static bool _getNextLine ( CellularContext_t * pContext ,
878875 char * * ppLine ,
879876 uint32_t * pBytesRead ,
877+ uint32_t currentLineLength ,
880878 CellularPktStatus_t pktStatus )
881879{
882- uint32_t stringLength = 0 ;
883880 bool keepProcess = true;
884881
885- /* Find other responses or urcs which need to be processed in this read buffer. */
886- stringLength = ( uint32_t ) strnlen ( * ppLine , * pBytesRead );
887-
888- /* Advanced 1 bytes to read next Line. */
889- * ppLine = & ( ( * ppLine )[ ( stringLength + 1U ) ] );
890- * pBytesRead = * pBytesRead - ( stringLength + 1U );
882+ /* Advanced 1 byte to read next Line. */
883+ * ppLine = & ( ( * ppLine )[ ( currentLineLength + 1U ) ] );
884+ * pBytesRead = * pBytesRead - ( currentLineLength + 1U );
891885 pContext -> pPktioReadPtr = * ppLine ;
892886 pContext -> partialDataRcvdLen = * pBytesRead ;
893887
@@ -915,6 +909,7 @@ static void _handleAllReceived( CellularContext_t * pContext,
915909 CellularPktStatus_t pktStatus = CELLULAR_PKT_STATUS_OK ;
916910 char * pStartOfData = NULL , * pTempLine = pData ;
917911 uint32_t bytesRead = bytesInBuffer ;
912+ uint32_t currentLineLength = 0U ;
918913 bool keepProcess = true;
919914
920915 while ( keepProcess == true )
@@ -932,6 +927,11 @@ static void _handleAllReceived( CellularContext_t * pContext,
932927 /* Preprocess line. */
933928 keepProcess = _preprocessLine ( pContext , pTempLine , & bytesRead , & pStartOfData );
934929
930+ if ( keepProcess == true )
931+ {
932+ keepProcess = _findLineInStream ( pContext , pTempLine , bytesRead , & currentLineLength );
933+ }
934+
935935 if ( keepProcess == true )
936936 {
937937 /* A complete Line received. Get the message type. */
@@ -949,13 +949,13 @@ static void _handleAllReceived( CellularContext_t * pContext,
949949 }
950950 else
951951 {
952- keepProcess = _getNextLine ( pContext , & pTempLine , & bytesRead , pktStatus );
952+ keepProcess = _getNextLine ( pContext , & pTempLine , & bytesRead , currentLineLength , pktStatus );
953953 }
954954 }
955955 else if ( ( pktStatus == CELLULAR_PKT_STATUS_OK ) || ( pktStatus == CELLULAR_PKT_STATUS_PENDING_DATA ) )
956956 {
957957 /* Process AT reponse success. Get the next Line. */
958- keepProcess = _getNextLine ( pContext , & pTempLine , & bytesRead , pktStatus );
958+ keepProcess = _getNextLine ( pContext , & pTempLine , & bytesRead , currentLineLength , pktStatus );
959959 }
960960 else
961961 {
0 commit comments