-/**
- * Generate the GPS NMEA standard UTC time stamp. Data is written through the tncTxByte
- * callback function.
- */
-void tncNMEATime()
-{
- // UTC of position fix.
- tncPrintf ("%02d%02d%02d,", gpsPosition.hours, gpsPosition.minutes, gpsPosition.seconds);
-}
-
-/**
- * Generate the GPS NMEA standard latitude/longitude fix. Data is written through the tncTxByte
- * callback function.
- */
-void tncNMEAFix()
-{
- uint8_t dirChar;
- uint32_t coord, coordMin;
-
- // Latitude value.
- coord = gpsPosition.latitude;
-
- if (gpsPosition.latitude < 0)
- {
- coord = gpsPosition.latitude * -1;
- dirChar = 'S';
- } else {
- coord = gpsPosition.latitude;
- dirChar = 'N';
- }
-
- coordMin = (coord % 3600000) / 6;
- tncPrintf ("%02ld%02ld.%04ld,%c,", (uint32_t) (coord / 3600000), (uint32_t) (coordMin / 10000), (uint32_t) (coordMin % 10000), dirChar);
-
-
- // Longitude value.
- if (gpsPosition.longitude < 0)
- {
- coord = gpsPosition.longitude * - 1;
- dirChar = 'W';
- } else {
- coord = gpsPosition.longitude;
- dirChar = 'E';
- }
-
- coordMin = (coord % 3600000) / 6;
- tncPrintf ("%03ld%02ld.%04ld,%c,", (uint32_t) (coord / 3600000), (uint32_t) (coordMin / 10000), (uint32_t) (coordMin % 10000), dirChar);
-
-}
-
-/**
- * Generate the GPS NMEA-0183 $GPGGA packet. Data is written through the tncTxByte
- * callback function.
- */
-void tncGPGGAPacket()
-{
- // Generate the GPGGA message.
- tncPrintf ("$GPGGA,");
-
- // Standard NMEA time.
- tncNMEATime();
-
- // Standard NMEA-0183 latitude/longitude.
- tncNMEAFix();
-
- // GPS status where 0: not available, 1: available
- if (gpsGetFixType() != GPS_NO_FIX)
- tncPrintf ("1,");
- else
- tncPrintf ("0,");
-
- // Number of visible birds.
- tncPrintf ("%02d,", gpsPosition.trackedSats);
-
- // DOP
- tncPrintf ("%ld.%01ld,", gpsPosition.dop / 10, gpsPosition.dop % 10);
-
- // Altitude in meters.
- tncPrintf ("%ld.%02ld,M,,M,,", (int32_t) (gpsPosition.altitudeCM / 100l), (int32_t) (gpsPosition.altitudeCM % 100));
-
- // Checksum, we add 1 to skip over the $ character.
- tncPrintf ("*%02X", gpsNMEAChecksum(tncBuffer + 1, tncLength - 1));
-}
-
-/**
- * Generate the GPS NMEA-0183 $GPRMC packet. Data is written through the tncTxByte
- * callback function.
- */
-void tncGPRMCPacket()
-{
- uint32_t temp;
-
- // Generate the GPRMC message.
- tncPrintf ("$GPRMC,");
-
- // Standard NMEA time.
- tncNMEATime();
-
- // GPS status.
- if (gpsGetFixType() != GPS_NO_FIX)
- tncPrintf ("A,");
- else
- tncPrintf ("V,");
-
- // Standard NMEA-0183 latitude/longitude.
- tncNMEAFix();
-
- // Speed knots and heading.
- temp = (int32_t) gpsPosition.hSpeed * 75000 / 385826;
- tncPrintf ("%ld.%ld,%ld.%ld,", (int16_t) (temp / 10), (int16_t) (temp % 10), gpsPosition.heading / 10, gpsPosition.heading % 10);
-
- // Date
- tncPrintf ("%02d%02d%02ld,,", gpsPosition.day, gpsPosition.month, gpsPosition.year % 100);
-
- // Checksum, skip over the $ character.
- tncPrintf ("*%02X", gpsNMEAChecksum(tncBuffer + 1, tncLength - 1));
-}
-