summaryrefslogtreecommitdiff
path: root/utils/loc_nmea.cpp
diff options
context:
space:
mode:
authorqctecmdr <qctecmdr@localhost>2020-01-08 10:49:30 -0800
committerGerrit - the friendly Code Review server <code-review@localhost>2020-01-08 10:49:30 -0800
commit7a736851d49f0eb3fffb0c3bf4ecbf4036086d46 (patch)
tree88ca5d7ac3be8fc3c704e4ef47b417d010781b8d /utils/loc_nmea.cpp
parente28fe313452b08fef7fcdf0b15bfb76ac2cf2c1b (diff)
parentf8883789e3c1eeb0e6b6b0c26c75a5f70a7af73c (diff)
downloadgps-7a736851d49f0eb3fffb0c3bf4ecbf4036086d46.tar.gz
Merge "FR 53788: DGNSS info for SPE position and SV measurement report"
Diffstat (limited to 'utils/loc_nmea.cpp')
-rw-r--r--utils/loc_nmea.cpp81
1 files changed, 76 insertions, 5 deletions
diff --git a/utils/loc_nmea.cpp b/utils/loc_nmea.cpp
index 9ee2716..32ae8e4 100644
--- a/utils/loc_nmea.cpp
+++ b/utils/loc_nmea.cpp
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2020, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -1756,17 +1756,51 @@ void loc_nmea_generate_pos(const UlpLocation &location,
if ((location.gpsLocation.flags & LOC_GPS_LOCATION_HAS_ALTITUDE) &&
(locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_ALTITUDE_MEAN_SEA_LEVEL))
{
- length = snprintf(pMarker, lengthRemaining, "%.1lf,,",
+ length = snprintf(pMarker, lengthRemaining, "%.1lf,",
ref_lla.alt - locationExtended.altitudeMeanSeaLevel);
}
else
{
- length = snprintf(pMarker, lengthRemaining,",,");
+ length = snprintf(pMarker, lengthRemaining, ",");
+ }
+ if (length < 0 || length >= lengthRemaining)
+ {
+ LOC_LOGE("NMEA Error in string formatting");
+ return;
}
+ pMarker += length;
+ lengthRemaining -= length;
+ if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_DGNSS_DATA_AGE)
+ {
+ length = snprintf(pMarker, lengthRemaining, "%.1f,",
+ (float)locationExtended.dgnssDataAgeMsec / 1000);
+ }
+ else
+ {
+ length = snprintf(pMarker, lengthRemaining, ",");
+ }
+ if (length < 0 || length >= lengthRemaining)
+ {
+ LOC_LOGE("NMEA Error in string formatting");
+ return;
+ }
pMarker += length;
lengthRemaining -= length;
+ if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_DGNSS_REF_STATION_ID)
+ {
+ length = snprintf(pMarker, lengthRemaining, "%04d",
+ locationExtended.dgnssRefStationId);
+ if (length < 0 || length >= lengthRemaining)
+ {
+ LOC_LOGE("NMEA Error in string formatting");
+ return;
+ }
+ pMarker += length;
+ lengthRemaining -= length;
+ }
+
// hardcode Navigation Status field to 'V'
length = snprintf(pMarker, lengthRemaining, ",%c", 'V');
pMarker += length;
@@ -1885,12 +1919,49 @@ void loc_nmea_generate_pos(const UlpLocation &location,
if ((location.gpsLocation.flags & LOC_GPS_LOCATION_HAS_ALTITUDE) &&
(locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_ALTITUDE_MEAN_SEA_LEVEL))
{
- length = snprintf(pMarker, lengthRemaining, "%.1lf,M,,",
+ length = snprintf(pMarker, lengthRemaining, "%.1lf,M,",
ref_lla.alt - locationExtended.altitudeMeanSeaLevel);
}
else
{
- length = snprintf(pMarker, lengthRemaining,",,,");
+ length = snprintf(pMarker, lengthRemaining, ",,");
+ }
+ if (length < 0 || length >= lengthRemaining)
+ {
+ LOC_LOGE("NMEA Error in string formatting");
+ return;
+ }
+ pMarker += length;
+ lengthRemaining -= length;
+
+ if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_DGNSS_DATA_AGE)
+ {
+ length = snprintf(pMarker, lengthRemaining, "%.1f,",
+ (float)locationExtended.dgnssDataAgeMsec / 1000);
+ }
+ else
+ {
+ length = snprintf(pMarker, lengthRemaining, ",");
+ }
+ if (length < 0 || length >= lengthRemaining)
+ {
+ LOC_LOGE("NMEA Error in string formatting");
+ return;
+ }
+ pMarker += length;
+ lengthRemaining -= length;
+
+ if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_DGNSS_REF_STATION_ID)
+ {
+ length = snprintf(pMarker, lengthRemaining, "%04d",
+ locationExtended.dgnssRefStationId);
+ if (length < 0 || length >= lengthRemaining)
+ {
+ LOC_LOGE("NMEA Error in string formatting");
+ return;
+ }
+ pMarker += length;
+ lengthRemaining -= length;
}
length = loc_nmea_put_checksum(sentence_GGA, sizeof(sentence_GGA));