@@ -813,6 +813,55 @@ void processUart1Message(SEMP_PARSE_STATE *parse, uint16_t type)
813
813
else
814
814
systemPrintf (" Increase latestNmeaMaxLen to > %d\r\n " , parse->length );
815
815
}
816
+ else if (strstr (sempNmeaGetSentenceName (parse), " VTG" ) != nullptr )
817
+ {
818
+ if (parse->length < latestNmeaMaxLen)
819
+ {
820
+ memcpy (latestGPVTG, parse->buffer , parse->length );
821
+ latestGPVTG[parse->length ] = 0 ; // NULL terminate
822
+ if ((strlen (latestGPVTG) > 10 ) && (latestGPVTG[strlen (latestGPVTG) - 2 ] == ' \r ' ))
823
+ latestGPVTG[strlen (latestGPVTG) - 2 ] = 0 ; // Truncate the \r\n
824
+ forceTalkerId (" P" ,latestGPVTG,latestNmeaMaxLen);
825
+ }
826
+ else
827
+ systemPrintf (" Increase latestNmeaMaxLen to > %d\r\n " , parse->length );
828
+ }
829
+ else if ((strstr (sempNmeaGetSentenceName (parse), " GSA" ) != nullptr )
830
+ || (strstr (sempNmeaGetSentenceName (parse), " GSV" ) != nullptr ))
831
+ {
832
+ // If the Apple Accessory is sending the data to the EA Session,
833
+ // discard this GSA / GSV. Bad things would happen if we were to
834
+ // manipulate latestEASessionData while appleAccessory is using it.
835
+ if (appleAccessory->latestEASessionDataIsBlocking () == false )
836
+ {
837
+ size_t spaceAvailable = latestEASessionDataMaxLen - strlen (latestEASessionData);
838
+ spaceAvailable -= 3 ; // Leave room for the CR, LF and NULL
839
+ while (spaceAvailable < parse->length ) // If the buffer is full, delete the oldest message(s)
840
+ {
841
+ const char *lfPtr = strstr (latestEASessionData, " \n " ); // Find the first LF
842
+ if (lfPtr == nullptr )
843
+ break ; // Something has gone badly wrong...
844
+ lfPtr++; // Point at the byte after the LF
845
+ size_t oldLen = lfPtr - latestEASessionData; // This much data is old
846
+ size_t newLen = strlen (latestEASessionData) - oldLen; // This much is new (not old)
847
+ for (size_t i = 0 ; i <= newLen; i++) // Move the new data over the old. Include the NULL
848
+ latestEASessionData[i] = latestEASessionData[oldLen + i];
849
+ spaceAvailable += oldLen;
850
+ }
851
+ size_t dataLen = strlen (latestEASessionData);
852
+ memcpy (&latestEASessionData[dataLen], parse->buffer , parse->length ); // Add the new NMEA data
853
+ dataLen += parse->length ;
854
+ latestEASessionData[dataLen] = 0 ; // NULL terminate
855
+ if (latestEASessionData[dataLen - 1 ] != ' \n ' )
856
+ {
857
+ latestEASessionData[dataLen] = ' \r ' ; // Add CR
858
+ latestEASessionData[dataLen + 1 ] = ' \n ' ; // Add LF
859
+ latestEASessionData[dataLen + 2 ] = 0 ; // NULL terminate
860
+ }
861
+ }
862
+ else if (settings.debugNetworkLayer )
863
+ systemPrintf (" Discarding %d GSA/GSV bytes - latestEASessionDataIsBlocking\r\n " , parse->length );
864
+ }
816
865
}
817
866
818
867
// Determine if this message should be processed by the Unicore library
0 commit comments