Fixposition SDK 0.0.0-heads/main-0-gf826859
Collection of c++ libraries and apps for use with Fixposition products on Linux
Loading...
Searching...
No Matches
nmea.hpp
Go to the documentation of this file.
1/**
2 * \verbatim
3 * ___ ___
4 * \ \ / /
5 * \ \/ / Copyright (c) Fixposition AG (www.fixposition.com) and contributors
6 * / /\ \ License: see the LICENSE file
7 * /__/ \__\
8 *
9 * Based on work by flipflip (https://github.com/phkehl)
10 * The information on message structures, IDs, descriptions etc. in this file are from publicly available data, such as:
11 * - NMEA 0183 (https://www.nmea.org/)
12 * - https://en.wikipedia.org/wiki/NMEA_0183
13 * - u-blox ZED-F9P Interface Description (HPG 1.50) (https://www.u-blox.com/en/docs/UBXDOC-963802114-12815),
14 * copyright (c) 2024 u-blox AG
15 * \endverbatim
16 *
17 * @file
18 * @brief Fixposition SDK: Parser NMEA routines and types
19 */
20// clang-format off
21/**
22 * @page FPSDK_COMMON_PARSER_NMEA Parser NMEA routines and types
23 *
24 * **API**: fpsdk_common/parser/nmea.hpp and fpsdk::common::parser::nmea
25 *
26 * @fp_msgspec_begin{NMEA-Protocol}
27 *
28 * The NMEA framing and behaviour is defined by the NMEA 0183 standard (v4.11 and erratas).
29 *
30 * In NMEA speak messages are called *Sentences*. Frames (messages) are in this form:
31 *
32 * <code><b style="color: red;">$</b><b style="color: green;">Talker</b><b style="color: blue;">Formatter</b>,<em>field<sub>1</sub></em>,<em>field<sub>2</sub></em>,…,<em>field<sub>N</sub></em><b style="color: red;">\*CC</b><b style="color: red;">\\r\\n</b></code>
33 *
34 * Where:
35 *
36 * - The NMEA style framing:
37 * - <code><b style="color: red;">\$</b></code>
38 * -- Start character ("$", ASCII 36)
39 * - <code><b style="color: red;">\*CC</b></code>
40 * -- Checksum: "\*" (ASCII 42) and two digit XOR value of all payload
41 * characters in captial hexadecimal notation, for example:
42 * "FPX" = <code>'F' ^ 'P' ^ 'X' = 70 ^ 80 ^ 88 = 78 = 0x4e</code> = checksum <code>4E</code>
43 * - <code><b style="color: red;">\\r\\n</b></code>
44 * -- Sentence termination characters (CR + LF, ASCII 13 + 10)
45 * - A <code><b style="color: green;">Talker</b></code> ID -- Two capital characters:
46 * - `GP` -- Talker ID for GPS, also legacy resp. "compatibility"
47 * - `GL` -- Talker ID for GLONASS
48 * - `GA` -- Talker ID for Galileo
49 * - `GB` -- Talker ID for BeiDou
50 * - `GQ` -- Talker ID for QZSS
51 * - `GI` -- Talker ID for NavIC (IRNSS)
52 * - `GN` -- Talker ID for any combination of GNSS
53 * - A <code><b style="color: blue;">Formatter</b></code> ID -- Three capital characters, for example:
54 * - `RMC` for the message containing recommended minimum specific GNSS data
55 * - See the NMEA 0183 standard document for an extensive list
56 * - Data fields (payload)
57 * - <code><em>field<sub>1</sub></em>,<em>field<sub>2</sub></em>,…,<em>field<sub>N</sub></em></code>
58 * -- The structure of the message data is defined by the <code><b style="color: blue;">Formatter</b></code>.
59 * Each field can contain all printable 7-bit ASCII characters (ASCII 32–126), excluding the
60 * reserved characters `!` (ASCII 33), `$` (ASCII 36), `*` (ASCII 42), `,` (ASCII 44),
61 * `\` (ASCII 92), `~` (ASCII 126).
62 * - Field separators
63 * - All fields (identifier, message type, message version, data fields) are separated by a `,` (comma, ASCII 44)
64 * - Null fields
65 * - Data fields can be _null_, meaning their value is absent to indicate that no data is
66 * available. The data for null fields is the empty string. For example:
67 * - Definition: <code>…,<em>field<sub>i</sub></em>,<em>field<sub>i+1</sub></em>,<em>field<sub>i+2</sub></em>,…</code>
68 * - Values: <code><em>field<sub>i</sub></em></code> = 123, <code><em>field<sub>i+1</sub></em></code> = _null_,
69 * <code><em>field<sub>i+2</sub></em></code> = 456
70 * - Payload string: <code>…,123,,456,…</code>
71 * - Data field types:
72 * - See the NMEA 0183 standard document for specifications
73 *
74 * @fp_msgspec_end
75 *
76 */
77// clang-format on
78#ifndef __FPSDK_COMMON_PARSER_NMEA_HPP__
79#define __FPSDK_COMMON_PARSER_NMEA_HPP__
80
81/* LIBC/STL */
82#include <array>
83#include <cstdint>
84#include <memory>
85#include <string>
86#include <vector>
87
88/* EXTERNAL */
89
90/* PACKAGE */
91
92namespace fpsdk {
93namespace common {
94namespace parser {
95/**
96 * @brief Parser NMEA routines and types
97 */
98namespace nmea {
99/* ****************************************************************************************************************** */
100
101static constexpr uint8_t NMEA_PREAMBLE = '$'; //!< NMEA framing preamble
102static constexpr std::size_t NMEA_FRAME_SIZE = 6; //!< NMEA frame size ("$*cc\r\n")
103
104//! NMEA message meta data
106{
107 char talker_[3] = { 0 }; //!< Talker ID (for example, "GP", "GN" or "P"), nul-terminated string
108 char formatter_[20] = { 0 }; //!< Formatter (for example, "GGA", "RMC", or "UBX"), nul-terminated string
109 int payload_ix0_ = 0; //!< Index (offset) for start of payload, 0 if no payload available
110 int payload_ix1_ = 0; //!< Index (offset) for end of payload, 0 if no payload available
111};
112
113/**
114 * @brief Get NMEA message meta data
115 *
116 * @param[out] meta The meta data
117 * @param[in] msg Pointer to the NMEA message
118 * @param[in] msg_size Size of the NMEA message (>= 11)
119 *
120 * @note No check on the data provided is done. The caller must ensure that the data is a correct NMEA message.
121 *
122 * @returns true if the meta data was successfully extracted, false otherwise
123 */
124bool NmeaGetMessageMeta(NmeaMessageMeta& meta, const uint8_t* msg, const std::size_t msg_size);
125
126/**
127 * @brief Get NMEA message name
128 *
129 * Generates a name (string) in the form "NMEA-TALKER-FORMATTER" (for example, "NMEA-GP-GGA"). Some proprietary messages
130 * are recognised, for example, "NMEA-PUBX-POSITION".
131 *
132 * @param[out] name String to write the name to
133 * @param[in] size Size of \c name (incl. nul termination)
134 * @param[in] msg Pointer to the NMEA message
135 * @param[in] msg_size Size of the \c msg
136 *
137 * @note No check on the data provided is done. The caller must ensure that the data is a valid NMEA message.
138 *
139 * @returns true if message name was generated, false if \c name buffer was too small
140 */
141bool NmeaGetMessageName(char* name, const std::size_t size, const uint8_t* msg, const std::size_t msg_size);
142
143/**
144 * @brief Get NMEA message info
145 *
146 * This stringifies the content of some NMEA messages, for debugging.
147 *
148 * @param[out] info String to write the info to
149 * @param[in] size Size of \c name (incl. nul termination)
150 * @param[in] msg Pointer to the NMEA message
151 * @param[in] msg_size Size of the \c msg
152 *
153 * @note No check on the data provided is done. The caller must ensure that the data is a valid NMEA message.
154 *
155 * @returns true if message info was generated (even if info is empty), false if \c name buffer was too small
156 */
157bool NmeaGetMessageInfo(char* info, const std::size_t size, const uint8_t* msg, const std::size_t msg_size);
158
159/**
160 * @brief Make a NMEA message
161 *
162 * @param[out] msg The message frame
163 * @param[in] payload The message payload, including the talker ID and formatter
164 * (up to MAX_NMEA_SIZE - NMEA_FRAME_SIZE bytes, can be empty)
165 *
166 * @note Illegal (< 0x20 or > 0x7e) or reserved/special ('$', '\', '!', '~', '^' and '*') characters are replaced
167 * by a '_'.
168 *
169 * @returns true if the message was successfully constructed (\c msg now contains the message),
170 * false if failed contructing the message (payload too large)
171 */
172bool NmeaMakeMessage(std::vector<uint8_t>& msg, const std::string& payload);
173
174/**
175 * @brief Make a NMEA message
176 *
177 * @param[out] msg The message frame
178 * @param[in] payload The message payload, including the talker ID and formatter
179 * (up to MAX_NMEA_SIZE - NMEA_FRAME_SIZE bytes, can be empty)
180 *
181 * @note Illegal (< 0x20 or > 0x7e) or reserved/special ('$', '\', '!', '~', '^' and '*') characters are replaced
182 * by a '_'.
183 *
184 * @returns true if the message was successfully constructed (\c msg now contains the message),
185 * false if failed contructing the message (payload too large)
186 */
187bool NmeaMakeMessage(std::string& msg, const std::string& payload);
188
189/**
190 * @brief NMEA coordinates (integer degrees, float minutes and a sign for N/S resp. E/W)
191 */
193{
194 /**
195 * @brief Constructor
196 *
197 * @param[in] degs Decimal degrees
198 * @param[in] digits Number of digits (0-12), param clamped to range
199 */
200 explicit NmeaCoordinates(const double degs, const int digits = 5);
201
202 int deg_; //!< Integer degrees value, >= 0
203 double min_; //!< Fractional minutes value, >= 0.0
204 bool sign_; //!< false for negative (S or W), true for positive (N or E)
205};
206
207// ---------------------------------------------------------------------------------------------------------------------
208
209/**
210 * @brief NMEA talker IDs
211 */
212enum class NmeaTalkerId : int
213{ // clang-format off
214 UNSPECIFIED = '!', //!< Unspecified
215 PROPRIETARY = 'x', //!< Proprietary
216 GPS_SBAS = 'P', //!< GPS and/or SBAS
217 GLO = 'L', //!< GLONASS
218 GAL = 'A', //!< GALILEO
219 BDS = 'B', //!< BeiDou
220 NAVIC = 'I', //!< NavIC
221 QZSS = 'Q', //!< QZSS
222 GNSS = 'N', //!< GNSS (multi-constellation)
223}; // clang-format on
224
225/**
226 * @brief Stringify NMEA talker ID
227 *
228 * @param[in] talker The NMEA talker ID
229 *
230 * @returns the stringification of the NMEA talker ID
231 */
232const char* NmeaTalkerIdStr(const NmeaTalkerId talker);
233
234/**
235 * @brief NMEA formatter
236 */
238{
239 UNSPECIFIED, //!< Unspecified
240 GGA, //!< Formatter GGA (NmeaGgaPayload)
241 GLL, //!< Formatter GLL (NmeaGllPayload)
242 RMC, //!< Formatter RMC (NmeaRmcPayload)
243 VTG, //!< Formatter VTG (NmeaVtgPayload)
244 GST, //!< Formatter GST (NmeaGstPayload)
245 HDT, //!< Formatter HDT (NmeaHdtPayload)
246 ZDA, //!< Formatter ZDA (NmeaZdaPayload)
247 GSA, //!< Formatter GSA (NmeaGsaPayload)
248 GSV, //!< Formatter GSV (NmeaGsvPayload)
249};
250
251/**
252 * @brief Stringify NMEA formatter
253 *
254 * @param[in] formatter The NMEA formatter
255 *
256 * @returns the stringification of the NMEA formatter
257 */
258const char* NmeaFormatterStr(const NmeaFormatter formatter);
259
260/**
261 * @brief NMEA-Gx-GGA quality indicator
262 */
263enum class NmeaQualityGga : int
264{ // clang-format off
265 UNSPECIFIED = '!', //!< Unspecified
266 NOFIX = '0', //!< No fix
267 SPP = '1', //!< Autonomous GNSS fix
268 DGNSS = '2', //!< Differential GPS fix (e.g. with SBAS)
269 PPS = '3', //!< PPS mode
270 RTK_FIXED = '4', //!< RTK fixed
271 RTK_FLOAT = '5', //!< RTK float
272 ESTIMATED = '6', //!< Estimated (dead reckoning only)
273 MANUAL = '7', //!< Manual input mode
274 SIM = '8', //!< Simulator
275}; // clang-format on
276
277/**
278 * @brief Stringify NMEA-Gx-GGA quality indicator
279 *
280 * @param[in] qual The NMEA-Gx-GGA quality indicator
281 *
282 * @returns the stringification of the NMEA-Gx-GGA quality indicator
283 */
284const char* NmeaQualityGgaStr(const NmeaQualityGga qual);
285
286/**
287 * @brief NMEA-Gx-GLL and NMEA-Gx-RMC status
288 *
289 * @note Do not use <, >, >=, <= operators on this!
290 */
291enum class NmeaStatusGllRmc : int
292{ // clang-format off
293 UNSPECIFIED = '!', //!< Unspecified
294 INVALID = 'V', //!< Data invalid
295 VALID = 'A', //!< Data valid
296 // DIFFERENTIAL = 'D', // @todo another possible value?
297}; // clang-format on
298
299/**
300 * @brief Stringify NMEA-Gx-GLL and NMEA-Gx-RMC status
301 *
302 * @param[in] status The NMEA-Gx-GLL and NMEA-Gx-RMC status
303 *
304 * @returns the stringification of the NMEA-Gx-GLL and NMEA-Gx-RMC status
305 */
306const char* NmeaStatusGllRmcStr(const NmeaStatusGllRmc status);
307
308/**
309 * @brief NMEA-Gx-GLL pos mode
310 *
311 * @note Do not use <, >, >=, <= operators on this!
312 */
313enum class NmeaModeGll : int
314{ // clang-format off
315 UNSPECIFIED = '!', //!< Unspecified
316 AUTONOMOUS = 'A', //!< Autonomous mode (SPP)
317 DGNSS = 'D', //!< Differential GNSS fix
318 ESTIMATED = 'E', //!< Estimated (dead reckoning only)
319 MANUAL = 'M', //!< Manual input mode
320 SIM = 'S', //!< Simulator mode
321 INVALID = 'N', //!< Invalid (no fix)
322}; // clang-format on
323
324/**
325 * @brief Stringify NMEA-Gx-GLL pos mode
326 *
327 * @param[in] mode The NMEA-Gx-GLL pos mode
328 *
329 * @returns the stringification of the NMEA-Gx-GLL and NMEA-Gx-VTG pos mode
330 */
331const char* NmeaModeGllStr(const NmeaModeGll mode);
332
333/**
334 * @brief NMEA-Gx-VTG pos mode
335 *
336 * @note Do not use <, >, >=, <= operators on this!
337 */
338enum class NmeaModeVtg : int
339{ // clang-format off
340 UNSPECIFIED = '!', //!< Unspecified
341 AUTONOMOUS = 'A', //!< Autonomous mode (SPP)
342 DGNSS = 'D', //!< Differential GNSS fix
343 ESTIMATED = 'E', //!< Estimated (dead reckoning only)
344 MANUAL = 'M', //!< Manual input mode
345 INVALID = 'N', //!< Invalid (no fix)
346 PRECISE = 'P', //!< Precise (e.g. PPP)
347 SIM = 'S', //!< Simulator mode
348}; // clang-format on
349
350/**
351 * @brief Stringify NMEA-Gx-VTG pos mode
352 *
353 * @param[in] mode The NMEA-Gx-VTG pos mode
354 *
355 * @returns the stringification of the NMEA-Gx-GLL and NMEA-Gx-VTG pos mode
356 */
357const char* NmeaModeVtgStr(const NmeaModeVtg mode);
358
359/**
360 * @brief NMEA-Gx-RMC and NMEA-Gx-GNS pos mode
361 *
362 * @note Do not use <, >, >=, <= operators on this!
363 */
364enum class NmeaModeRmcGns : int
365{ // clang-format off
366 UNSPECIFIED = '!', //!< Unspecified
367 INVALID = 'N', //!< Invalid (no fix)
368 AUTONOMOUS = 'A', //!< Autonomous mode (SPP)
369 DGNSS = 'D', //!< Differential GNSS fix
370 ESTIMATED = 'E', //!< Estimated (dead reckoning only)
371 RTK_FIXED = 'R', //!< RTK fixed
372 RTK_FLOAT = 'F', //!< RTK float
373 PRECISE = 'P', //!< Precise
374 MANUAL = 'M', //!< Manual input mode
375 SIM = 'S', //!< Simulator mode
376}; // clang-format on
377
378/**
379 * @brief Stringify NMEA-Gx-RMC and NMEA-Gx-GNS pos mode
380 *
381 * @param[in] mode The NMEA-Gx-RMC and NMEA-Gx-GNS pos mode
382 *
383 * @returns the stringification of the NMEA-Gx-RMC and NMEA-Gx-GNS pos mode
384 */
385const char* NmeaModeRmcGnsStr(const NmeaModeRmcGns mode);
386
387/**
388 * @brief NMEA-Gx-RMC navigational status
389 *
390 * @note Do not use <, >, >=, <= operators on this!
391 */
392enum class NmeaNavStatusRmc : int
393{ // clang-format off
394 UNSPECIFIED = '!', //!< Unspecified
395 SAFE = 'S', //!< Safe
396 CAUTION = 'C', //!< Caution
397 UNSAFE = 'U', //!< Unsafe
398 NA = 'V', //!< Equipment does not provide navigational status
399}; // clang-format on
400
401/**
402 * @brief Stringify NMEA-Gx-RMC navigational status
403 *
404 * @param[in] navstatus The NMEA-Gx-RMC navigational status
405 *
406 * @returns the stringification of the NMEA-Gx-RMC navigational status
407 */
408const char* NmeaNavStatusRmcStr(const NmeaNavStatusRmc navstatus);
409
410/**
411 * @brief NMEA-Gx-GNS operation mode
412 *
413 * @note Do not use <, >, >=, <= operators on this!
414 */
415enum class NmeaOpModeGsa : int
416{ // clang-format off
417 UNSPECIFIED = '!', //!< Unspecified
418 MANUAL = 'M', //!< Manual
419 AUTO = 'A', //!< Automatic
420}; // clang-format on
421
422/**
423 * @brief Stringify NMEA-Gx-GNS operation mode
424 *
425 * @param[in] opmode The NMEA-Gx-GNS operation mode
426 *
427 * @returns the stringification of the NMEA-Gx-GNS operation mode
428 */
429const char* NmeaOpModeGsaStr(const NmeaOpModeGsa opmode);
430
431/**
432 * @brief NMEA-Gx-GNS nav mode
433 */
434enum class NmeaNavModeGsa : int
435{ // clang-format off
436 UNSPECIFIED = '!', //!< Unspecified
437 NOFIX = '1', //!< No fix
438 FIX2D = '2', //!< 2D fix
439 FIX3D = '3', //!< 3D fix
440}; // clang-format on
441
442/**
443 * @brief Stringify NMEA-Gx-GNS nav mode
444 *
445 * @param[in] navmode The NMEA-Gx-GNS nav mode
446 *
447 * @returns the stringification of the NMEA-Gx-GNS nav mode
448 */
449const char* NmeaNavModeGsaStr(const NmeaNavModeGsa navmode);
450
451/**
452 * @brief NMEA system IDs
453 *
454 * @note Do not use <, >, >=, <= operators on this!
455 */
456enum class NmeaSystemId : int
457{ // clang-format off
458 UNSPECIFIED = '!', //!< Unspecified
459 GPS_SBAS = '1', //!< GPS and/or SBAS
460 GLO = '2', //!< GLONASS
461 GAL = '3', //!< Galileo
462 BDS = '4', //!< BeiDou
463 QZSS = '5', //!< QZSS
464 NAVIC = '6', //!< NavIC
465}; // clang-format on
466
467/**
468 * @brief Stringify NMEA system ID
469 *
470 * @param[in] system The NMEA system ID
471 *
472 * @returns the stringification of the NMEA system ID
473 */
474const char* NmeaSystemIdStr(const NmeaSystemId system);
475
476/**
477 * @brief NMEA signal IDs
478 *
479 * @note Do not use <, >, >=, <= operators on this!
480 */
481enum class NmeaSignalId : int
482{ // clang-format off
483 UNSPECIFIED = 0x000 + '!', //!< Unspecified
484 NONE = 0x000 + '0', //!< None
485 // GPS (SBAS)
486 GPS_L1CA = 0x100 + '1', //!< GPS L1 C/A or SBAS L1 C/A
487 GPS_L2CL = 0x100 + '6', //!< GPS L2 CL
488 GPS_L2CM = 0x100 + '5', //!< GPS L2 CM
489 GPS_L5I = 0x100 + '7', //!< GPS L5 I
490 GPS_L5Q = 0x100 + '8', //!< GPS L5 Q
491 // GAL
492 GAL_E1 = 0x300 + '7', //!< Galileo E1
493 GAL_E5A = 0x300 + '1', //!< Galileo E5 A
494 GAL_E5B = 0x300 + '2', //!< Galileo E5 B
495 GAL_E6BC = 0x300 + '3', //!< Galileo E6 B/C
496 GAL_E6A = 0x300 + '4', //!< Galileo E6 A
497 // BDS
498 BDS_B1ID = 0x400 + '1', //!< BeiDou B1I D
499 BDS_B2ID = 0x400 + 'B', //!< BeiDou B2I D
500 BDS_B1C = 0x400 + '3', //!< BeiDou B1 C
501 BDS_B2A = 0x400 + '5', //!< BeiDou B2 a
502 BDS_B2B = 0x400 + '6', //!< BeiDou B2 b
503 // QZSS
504 QZSS_L1CA = 0x500 + '1', //!< QZSS L1 C/A
505 QZSS_L1S = 0x500 + '4', //!< QZSS L1S
506 QZSS_L2CM = 0x500 + '5', //!< QZSS L2 CM
507 QZSS_L2CL = 0x500 + '6', //!< QZSS L2 CL
508 QZSS_L5I = 0x500 + '7', //!< QZSS L5 I
509 QZSS_L5Q = 0x500 + '8', //!< QZSS L5 Q
510 // GLO
511 GLO_L1OF = 0x200 + '1', //!< GLONASS L1 OF
512 GLO_L2OF = 0x200 + '3', //!< GLONASS L2 OF
513 // NAVIC
514 NAVIC_L5A = 0x600 + '5', //!< NavIC L5 A
515}; // clang-format on
516
517/**
518 * @brief Stringify NMEA signal IDs
519 *
520 * @param[in] signal The NMEA signal IDs
521 *
522 * @returns the stringification of the NMEA signal IDs
523 */
524const char* NmeaSignalIdStr(const NmeaSignalId signal);
525
526/**
527 * @brief NMEA time (hour, minutes, seconds)
528 */
530{
531 bool valid = false; //!< Data is valid
532 int hours = 0; //!< Hours
533 int mins = 0; //!< Minutes
534 double secs = 0.0; //!< Seconds
535
536 bool operator==(const NmeaTime& rhs) const; //!< Equal
537 bool operator!=(const NmeaTime& rhs) const; //!< Not equal
538};
539
540/**
541 * @brief NMEA date (year, month, day)
542 */
544{
545 bool valid = false; //!< Data is valid
546 int years = 0; //!< Year
547 int months = 0; //!< Month
548 int days = 0.0; //!< Day
549
550 bool operator==(const NmeaDate& rhs) const; //!< Equal
551 bool operator!=(const NmeaDate& rhs) const; //!< Not equal
552};
553
554/**
555 * @brief NMEA geodetic position
556 */
558{
559 bool latlon_valid = false; //!< Latitude/longitude is valid
560 double lat = 0.0; //!< Latitude [deg], >= 0.0 East, < 0.0 West
561 double lon = 0.0; //!< Longitude [deg], >= 0.0 North, < 0.0 South
562 bool height_valid = false; //!< Height is valid
563 double height = 0.0; //!< Ellipsoidal (!) height [m]
564};
565
566/**
567 * @brief NMEA satellite (used, e.g. in GSA)
568 */
570{
571 bool valid = false; //!< Data is valid
573 int svid = 0; //!< Satellite ID (numbering cf. NMEA 0183)
574};
575
576/**
577 * @brief Constants for different versions of NMEA
578 */
580{
581 const int svid_min_gps = -1; //!< Min GPS satellite ID
582 const int svid_max_gps = -1; //!< Max GPS satellite ID
583 const int svid_min_sbas = -1; //!< Min SBAS satellite ID
584 const int svid_max_sbas = -1; //!< Max SBAS satellite ID
585 const int svid_min_gal = -1; //!< Min Galileo satellite ID
586 const int svid_max_gal = -1; //!< Max Galileo satellite ID
587 const int svid_min_bds = -1; //!< Min BeiDou satellite ID
588 const int svid_max_bds = -1; //!< Max BeiDou satellite ID
589 const int svid_min_glo = -1; //!< Min GLONASS satellite ID
590 const int svid_max_glo = -1; //!< Max GLONASS satellite ID
591 const int svid_min_qzss = -1; //!< Min QZSS satellite ID, -1 if not available
592 const int svid_max_qzss = -1; //!< Max QZSS satellite ID, -1 if not available
593 const int svid_min_navic = -1; //!< Min NavIC satellite ID, -1 if not available
594 const int svid_max_navic = -1; //!< Max NavIC satellite ID, -1 if not available
595 static const NmeaVersion V410; //!< Value for NMEA v4.10
596 static const NmeaVersion V410_UBX_EXT; //!< Value for NMEA v4.10 extended (u-blox flavour)
597 static const NmeaVersion V411; //!< Value for NMEA v4.11
598};
599
600/**
601 * NMEA satellite position (GSA)
602 */
604{
605 bool valid = false; //!< Data is valid
607 int svid = 0; //!< Satellite ID (numbering cf. NMEA 0183)
608 int el = 0; //!< Elevation [deg] (-90..90)
609 int az = 0; //!< Azimuth [deg] (0..360)
610};
611
612/**
613 * NMEA signal levels (GSA)
614 */
616{
617 bool valid = false; //!< Data valid
619 int svid = 0; //!< Satellite ID (numbering cf. NMEA 0183)
621 int cno = 0; //!< Signal level [dBHz]
622};
623
624/**
625 * @brief NMEA integer value
626 */
628{
629 bool valid = false; //!< Data is valid
630 int value = 0; //!< Value
631};
632
633/**
634 * @brief NMEA float value
635 */
637{
638 bool valid = false; //!< Data is valid
639 double value = 0; //!< Value
640};
641
642/**
643 * @brief NMEA payload base class
644 */
646{
649 bool valid_ = false; //!< Payload successfully decoded (true), or not (yet) decoded (false)
650 virtual ~NmeaPayload() = default; //!< Virtual dtor for polymorphism
651
652 /**
653 * @brief Set data from message
654 *
655 * @param[in] msg Pointer to the NMEA message
656 * @param[in] msg_size Size of the NMEA message (>= 11)
657 *
658 * @returns true if sentence payload was correct and all data could be extracted (fields are now valid), or false
659 * otherwise (fields are now invalid)
660 */
661 virtual bool SetFromMsg(const uint8_t* msg, const std::size_t msg_size) = 0;
662
663 /**
664 * @brief Set data from message
665 *
666 * @param[in] buf The NMEA message data
667 *
668 * @returns true if message payload was correct and all data could be extracted (fields are now valid), or false
669 * otherwise (fields are now invalid)
670 */
671 inline bool SetFromBuf(const std::vector<uint8_t>& buf)
672 {
673 return SetFromMsg(buf.data(), buf.size());
674 }
675};
676
677/**
678 * @brief NMEA-Gx-GGA message payload
679 */
681{
682 NmeaTime time; //!< Time
683 NmeaLlh llh; //!< Position (with ellipsoidal height)
684 NmeaFloat height_msl; //!< Orthomeric height [m]
686 NmeaInt num_sv; //!< Number of satellites used (may be limited to 12)
687 NmeaFloat hdop; //!< Horizontal dilution of precision (only with valid fix)
688 NmeaFloat diff_age; //!< Differential data age (optional, NMEA 4.11 only)
689 NmeaInt diff_sta; //!< Differential station ID (optional, NMEA 4.11 only)
690
691 bool SetFromMsg(const uint8_t* msg, const std::size_t msg_size) final;
692
693 static constexpr const char* FORMATTER = "GGA"; //!< Formatter
694};
695
696/**
697 * @brief NMEA-Gx-GLL message payload
698 */
700{
701 NmeaLlh ll; //!< Position (no height)
702 NmeaTime time; //!< Time
703 NmeaStatusGllRmc status = NmeaStatusGllRmc::UNSPECIFIED; //!< Positioning system status
704 NmeaModeGll mode = NmeaModeGll::UNSPECIFIED; //!< Positioning system mode
705
706 bool SetFromMsg(const uint8_t* msg, const std::size_t msg_size) final;
707
708 static constexpr const char* FORMATTER = "GLL"; //!< Formatter
709};
710
711/**
712 * @brief NMEA-Gx-RMC message payload
713 */
715{
716 NmeaTime time; //!< Time
717 NmeaStatusGllRmc status = NmeaStatusGllRmc::UNSPECIFIED; //!< Positioning system status
718 NmeaLlh ll; //!< Position (no height)
719 NmeaFloat speed; //!< Speed over ground [knots]
720 NmeaFloat course; //!< Course over ground w.r.t. True North [deg]
721 NmeaDate date; //!< Date
722 NmeaModeRmcGns mode = NmeaModeRmcGns::UNSPECIFIED; //!< Positioning system mode indicator
723 NmeaNavStatusRmc navstatus = NmeaNavStatusRmc::UNSPECIFIED; //!< Navigational status (optional)
724
725 bool SetFromMsg(const uint8_t* msg, const std::size_t msg_size) final;
726
727 static constexpr const char* FORMATTER = "RMC"; //!< Formatter
728};
729
730/**
731 * @brief NMEA-Gx-VTG message payload
732 */
734{
735 NmeaFloat cogt; //!< Course over ground (true) [deg]
736 NmeaFloat cogm; //!< Course over ground (magnetic) [deg], not typically available
737 NmeaFloat sogn; //!< Speed over ground [knots]
738 NmeaFloat sogk; //!< Speed over ground [km/h]
739 NmeaModeVtg mode = NmeaModeVtg::UNSPECIFIED; //!< Positioning system mode
740
741 bool SetFromMsg(const uint8_t* msg, const std::size_t msg_size) final;
742
743 static constexpr const char* FORMATTER = "VTG"; //!< Talker
744};
745
746/**
747 * @brief NMEA-Gx-GST message payload
748 */
750{
751 NmeaTime time; //!< Time
752 NmeaFloat rms_range; //!< RMS value of the standard deviation of the range inputs to the navigation process
753 NmeaFloat std_major; //!< Standard deviation of semi-major axis of error ellipse
754 NmeaFloat std_minor; //!< Standard deviation of semi-minor axis of error ellipse
755 NmeaFloat angle_major; //!< Angle of semi-major axis of error ellipse from true North
756 NmeaFloat std_lat; //!< Standard deviation of latitude error
757 NmeaFloat std_lon; //!< Standard deviation of longitude error
758 NmeaFloat std_alt; //!< Standard deviation of altitude error
759
760 bool SetFromMsg(const uint8_t* msg, const std::size_t msg_size) final;
761
762 static constexpr const char* FORMATTER = "GST"; //!< Formatter
763};
764
765/**
766 * @brief NMEA-Gx-HDT message payload
767 */
769{
770 NmeaFloat heading; //!< True heading
771
772 bool SetFromMsg(const uint8_t* msg, const std::size_t msg_size) final;
773
774 static constexpr const char* FORMATTER = "HDT"; //!< Formatter
775};
776
777/**
778 * @brief NMEA-Gx-ZDA message payload
779 */
781{
782 NmeaTime time; //!< Time
783 NmeaDate date; //!< Date
784 NmeaInt local_hr; //!< Local zone hours, always 00 (= UTC)
785 NmeaInt local_min; //!< Local zone minutes, always 00 (= UTC)
786
787 bool SetFromMsg(const uint8_t* msg, const std::size_t msg_size) final;
788
789 static constexpr const char* FORMATTER = "ZDA"; //!< Formatter
790};
791
792/**
793 * @brief NMEA-Gx-GSA message payload (NMEA 4.11 only!)
794 */
796{
799 std::array<NmeaSat, 12> sats; //!< Satellites, valid ones are 0..(num_sats-1)
800 int num_sats = 0; //!< Number of valid sats (the first n of sats[])
801 NmeaFloat pdop; //!< PDOP
802 NmeaFloat hdop; //!< HDOP
803 NmeaFloat vdop; //!< VDOP
805
806 bool SetFromMsg(const uint8_t* msg, const std::size_t msg_size) final;
807
808 static constexpr const char* FORMATTER = "GSA"; //!< Formatter
809};
810
811/**
812 * @brief NMEA-Gx-GSV message payload (NMEA 4.11 only!)
813 */
815{
816 NmeaInt num_msgs; //!< Number of messages in this GSV sequence (for this signal ID)
817 NmeaInt msg_num; //!< Message number in sequence (1...num_msgs)
818 NmeaInt tot_num_sat; //!< Number of sat/sig info in the whole sequence of GSV messages
819 std::array<NmeaAzEl, 4> azels; //!< Satellite positions, valid ones are 0..(num_sats-1)
820 int num_azels = 0; //!< Number of valid satellite positions (the first n of azels[])
821 std::array<NmeaCno, 4> cnos; //!< Signal levels, valid ones are 0..(num_sats-1)
822 int num_cnos = 0; //!< Number of valid signal levels (the first n of azels[])
823 NmeaSystemId system; //!< System ID
824 NmeaSignalId signal; //!< Signal ID
825
826 bool SetFromMsg(const uint8_t* msg, const std::size_t msg_size) final;
827
828 static constexpr const char* FORMATTER = "GSV"; //!< Formatter
829};
830
831// ---------------------------------------------------------------------------------------------------------------------
832
833//! Pointer to NMEA payload
834using NmeaPayloadPtr = std::unique_ptr<NmeaPayload>;
835
836/**
837 * @brief Decode NMEA message
838 *
839 * @param[in] msg Pointer to the NMEA message
840 * @param[in] msg_size Size of the NMEA message (>= 11)
841 *
842 * @returns an instance of the decoded payload on success, nullptr otherwise (bad or unknown message)
843 */
844NmeaPayloadPtr NmeaDecodeMessage(const uint8_t* msg, const std::size_t msg_size);
845
846/**
847 * @brief Decode NMEA message
848 *
849 * @param[in] msg The NMEA message data
850 *
851 * @returns an instance of the decoded payload on success, nullptr otherwise (bad or unknown message)
852 */
853inline NmeaPayloadPtr NmeaDecodeMessage(const std::vector<uint8_t>& msg)
854{
855 return NmeaDecodeMessage(msg.data(), msg.size());
856}
857
858// ---------------------------------------------------------------------------------------------------------------------
859
860/**
861 * @brief Collector for NMEA-Gx-GSA and NMEA-Gx-GPA
862 *
863 * Note that the user is responsible to call Complete() on every end of epoch. This collector by itself has no means to
864 * determine start or end of epoch. If Complete() is not called, the Add...() methods refuse to collect more data after
865 * a certain threshold (see MAX_COLLECT below) and fail. This is to prevent memory growing forever if Complete() is not
866 * called appropriately.
867 */
869{
870 /**
871 * @brief Satellite info
872 */
873 struct Sat
874 {
876 int svid_ = 0; //!< Satellite ID (numbering cf. NMEA 0183)
877 int az_ = 0; //!< Azimuth [deg] (0..360)
878 int el_ = 0; //!< Elevation [deg] (-90..90)
879 };
880
881 /**
882 * Signal info
883 */
884 struct Sig
885 {
887 int svid_ = 0; //!< Satellite ID (numbering cf. NMEA 0183)
889 double cno_ = 0.0; //!< Signal level [dBHz]
890 bool used_ = false; //!< Signal is used in navigation
891 };
892
893 std::vector<Sat> sats_; //!< Collected satellite info
894 std::vector<Sig> sigs_; //!< Collected signal info
895
896 /**
897 * @brief Add NMEA-GN-GSA message to collection
898 *
899 * These must be provided in order and completely, and before the GSV messages.
900 *
901 * @param[in] gsa Decoded message payload
902 *
903 * @returns true if the message was accepted, false otherwise
904 */
905 bool AddGsa(const NmeaGsaPayload& gsa);
906
907 /**
908 * @brief Add NMEA-Gx-GSV message to collection
909 *
910 * These must be provided in order and completely, and after the GSA messages.
911 *
912 * @param[in] gsv Decoded message payload
913 *
914 * @returns true if the message was accepted, false otherwise
915 */
916 bool AddGsv(const NmeaGsvPayload& gsv);
917
918 /**
919 * @brief Complete collection after feeding all GSA and GSV messages
920 */
921 void Complete();
922
923 /**
924 * @brief Add NMEA-GN-GSA and NMEA-Gx-GSV messages to collection
925 *
926 * Does all of AddGsa(), AddGsv() and Complete() in one call.
927 *
928 * @param[in] gsas All decoded message payloads, complete and in order
929 * @param[in] gsvs All decoded message payloads, complete and in order
930 *
931 * @returns true if all messages were collected successfully
932 */
933 bool AddGsaAndGsv(const std::vector<NmeaGsaPayload>& gsas, const std::vector<NmeaGsvPayload>& gsvs);
934
935 private:
936 std::vector<NmeaSat> gsa_sats_; //!< Satellites used
937
938 /**
939 * @brief Maximum number of entries to collect for any of sats_, sigs_ or gsa_sats_
940 *
941 * This is to prevent the memory usage growing over time if the user keeps adding data and never calls Complete().
942 * The value is large enough to cover the maximum number of satellits and signals a receiver will see. This should
943 * never be reached when the collector is used properly (by calling Complete() on end of epoch).
944 */
945 static constexpr std::size_t MAX_COLLECT = 1000;
946};
947
948/* ****************************************************************************************************************** */
949} // namespace nmea
950} // namespace parser
951} // namespace common
952} // namespace fpsdk
953#endif // __FPSDK_COMMON_PARSER_NMEA_HPP__
Parser NMEA routines and types.
Definition nmea.hpp:98
NmeaSystemId
NMEA system IDs.
Definition nmea.hpp:457
NmeaModeRmcGns
NMEA-Gx-RMC and NMEA-Gx-GNS pos mode.
Definition nmea.hpp:365
const char * NmeaNavStatusRmcStr(const NmeaNavStatusRmc navstatus)
Stringify NMEA-Gx-RMC navigational status.
const char * NmeaNavModeGsaStr(const NmeaNavModeGsa navmode)
Stringify NMEA-Gx-GNS nav mode.
static constexpr std::size_t NMEA_FRAME_SIZE
NMEA frame size ("$*cc\r\n").
Definition nmea.hpp:102
bool NmeaMakeMessage(std::vector< uint8_t > &msg, const std::string &payload)
Make a NMEA message.
NmeaOpModeGsa
NMEA-Gx-GNS operation mode.
Definition nmea.hpp:416
NmeaNavStatusRmc
NMEA-Gx-RMC navigational status.
Definition nmea.hpp:393
@ NA
Equipment does not provide navigational status.
Definition nmea.hpp:398
const char * NmeaSystemIdStr(const NmeaSystemId system)
Stringify NMEA system ID.
const char * NmeaTalkerIdStr(const NmeaTalkerId talker)
Stringify NMEA talker ID.
NmeaPayloadPtr NmeaDecodeMessage(const uint8_t *msg, const std::size_t msg_size)
Decode NMEA message.
NmeaModeGll
NMEA-Gx-GLL pos mode.
Definition nmea.hpp:314
@ AUTONOMOUS
Autonomous mode (SPP).
Definition nmea.hpp:316
const char * NmeaModeRmcGnsStr(const NmeaModeRmcGns mode)
Stringify NMEA-Gx-RMC and NMEA-Gx-GNS pos mode.
static constexpr uint8_t NMEA_PREAMBLE
NMEA framing preamble.
Definition nmea.hpp:101
const char * NmeaStatusGllRmcStr(const NmeaStatusGllRmc status)
Stringify NMEA-Gx-GLL and NMEA-Gx-RMC status.
NmeaFormatter
NMEA formatter.
Definition nmea.hpp:238
@ ZDA
Formatter ZDA (NmeaZdaPayload).
Definition nmea.hpp:246
@ HDT
Formatter HDT (NmeaHdtPayload).
Definition nmea.hpp:245
@ RMC
Formatter RMC (NmeaRmcPayload).
Definition nmea.hpp:242
@ GGA
Formatter GGA (NmeaGgaPayload).
Definition nmea.hpp:240
@ GST
Formatter GST (NmeaGstPayload).
Definition nmea.hpp:244
@ GSV
Formatter GSV (NmeaGsvPayload).
Definition nmea.hpp:248
@ GSA
Formatter GSA (NmeaGsaPayload).
Definition nmea.hpp:247
@ GLL
Formatter GLL (NmeaGllPayload).
Definition nmea.hpp:241
@ VTG
Formatter VTG (NmeaVtgPayload).
Definition nmea.hpp:243
NmeaNavModeGsa
NMEA-Gx-GNS nav mode.
Definition nmea.hpp:435
const char * NmeaModeVtgStr(const NmeaModeVtg mode)
Stringify NMEA-Gx-VTG pos mode.
NmeaTalkerId
NMEA talker IDs.
Definition nmea.hpp:213
@ GNSS
GNSS (multi-constellation).
Definition nmea.hpp:222
const char * NmeaQualityGgaStr(const NmeaQualityGga qual)
Stringify NMEA-Gx-GGA quality indicator.
const char * NmeaOpModeGsaStr(const NmeaOpModeGsa opmode)
Stringify NMEA-Gx-GNS operation mode.
const char * NmeaModeGllStr(const NmeaModeGll mode)
Stringify NMEA-Gx-GLL pos mode.
const char * NmeaSignalIdStr(const NmeaSignalId signal)
Stringify NMEA signal IDs.
std::unique_ptr< NmeaPayload > NmeaPayloadPtr
Pointer to NMEA payload.
Definition nmea.hpp:834
NmeaStatusGllRmc
NMEA-Gx-GLL and NMEA-Gx-RMC status.
Definition nmea.hpp:292
bool NmeaGetMessageInfo(char *info, const std::size_t size, const uint8_t *msg, const std::size_t msg_size)
Get NMEA message info.
bool NmeaGetMessageMeta(NmeaMessageMeta &meta, const uint8_t *msg, const std::size_t msg_size)
Get NMEA message meta data.
NmeaModeVtg
NMEA-Gx-VTG pos mode.
Definition nmea.hpp:339
NmeaSignalId
NMEA signal IDs.
Definition nmea.hpp:482
@ GPS_L1CA
GPS L1 C/A or SBAS L1 C/A.
Definition nmea.hpp:486
bool NmeaGetMessageName(char *name, const std::size_t size, const uint8_t *msg, const std::size_t msg_size)
Get NMEA message name.
const char * NmeaFormatterStr(const NmeaFormatter formatter)
Stringify NMEA formatter.
NmeaQualityGga
NMEA-Gx-GGA quality indicator.
Definition nmea.hpp:264
@ DGNSS
Differential GPS fix (e.g. with SBAS).
Definition nmea.hpp:268
@ ESTIMATED
Estimated (dead reckoning only).
Definition nmea.hpp:272
Fixposition SDK: Common library.
Definition doc.hpp:21
Fixposition SDK.
NmeaSystemId system
System ID.
Definition nmea.hpp:606
int az
Azimuth [deg] (0..360).
Definition nmea.hpp:609
int el
Elevation [deg] (-90..90).
Definition nmea.hpp:608
int svid
Satellite ID (numbering cf. NMEA 0183).
Definition nmea.hpp:607
int cno
Signal level [dBHz].
Definition nmea.hpp:621
NmeaSignalId signal
Signal ID.
Definition nmea.hpp:620
int svid
Satellite ID (numbering cf. NMEA 0183).
Definition nmea.hpp:619
NmeaSystemId system
System ID.
Definition nmea.hpp:618
int svid_
Satellite ID (numbering cf. NMEA 0183).
Definition nmea.hpp:876
int svid_
Satellite ID (numbering cf. NMEA 0183).
Definition nmea.hpp:887
bool used_
Signal is used in navigation.
Definition nmea.hpp:890
Collector for NMEA-Gx-GSA and NMEA-Gx-GPA.
Definition nmea.hpp:869
bool AddGsa(const NmeaGsaPayload &gsa)
Add NMEA-GN-GSA message to collection.
std::vector< Sat > sats_
Collected satellite info.
Definition nmea.hpp:893
bool AddGsv(const NmeaGsvPayload &gsv)
Add NMEA-Gx-GSV message to collection.
std::vector< Sig > sigs_
Collected signal info.
Definition nmea.hpp:894
bool AddGsaAndGsv(const std::vector< NmeaGsaPayload > &gsas, const std::vector< NmeaGsvPayload > &gsvs)
Add NMEA-GN-GSA and NMEA-Gx-GSV messages to collection.
void Complete()
Complete collection after feeding all GSA and GSV messages.
double min_
Fractional minutes value, >= 0.0.
Definition nmea.hpp:203
NmeaCoordinates(const double degs, const int digits=5)
Constructor.
bool sign_
false for negative (S or W), true for positive (N or E)
Definition nmea.hpp:204
int deg_
Integer degrees value, >= 0.
Definition nmea.hpp:202
NMEA date (year, month, day).
Definition nmea.hpp:544
bool operator==(const NmeaDate &rhs) const
Equal.
bool operator!=(const NmeaDate &rhs) const
Not equal.
NMEA-Gx-GGA message payload.
Definition nmea.hpp:681
static constexpr const char * FORMATTER
Formatter.
Definition nmea.hpp:693
NmeaFloat diff_age
Differential data age (optional, NMEA 4.11 only).
Definition nmea.hpp:688
NmeaLlh llh
Position (with ellipsoidal height).
Definition nmea.hpp:683
bool SetFromMsg(const uint8_t *msg, const std::size_t msg_size) final
Set data from message.
NmeaFloat height_msl
Orthomeric height [m].
Definition nmea.hpp:684
NmeaFloat hdop
Horizontal dilution of precision (only with valid fix).
Definition nmea.hpp:687
NmeaQualityGga quality
Fix quality.
Definition nmea.hpp:685
NmeaInt diff_sta
Differential station ID (optional, NMEA 4.11 only).
Definition nmea.hpp:689
NmeaInt num_sv
Number of satellites used (may be limited to 12).
Definition nmea.hpp:686
NMEA-Gx-GLL message payload.
Definition nmea.hpp:700
bool SetFromMsg(const uint8_t *msg, const std::size_t msg_size) final
Set data from message.
NmeaModeGll mode
Positioning system mode.
Definition nmea.hpp:704
NmeaLlh ll
Position (no height).
Definition nmea.hpp:701
static constexpr const char * FORMATTER
Formatter.
Definition nmea.hpp:708
NmeaStatusGllRmc status
Positioning system status.
Definition nmea.hpp:703
NMEA-Gx-GSA message payload (NMEA 4.11 only!).
Definition nmea.hpp:796
static constexpr const char * FORMATTER
Formatter.
Definition nmea.hpp:808
NmeaOpModeGsa opmode
Operation mode.
Definition nmea.hpp:797
int num_sats
Number of valid sats (the first n of sats[]).
Definition nmea.hpp:800
bool SetFromMsg(const uint8_t *msg, const std::size_t msg_size) final
Set data from message.
std::array< NmeaSat, 12 > sats
Satellites, valid ones are 0..(num_sats-1).
Definition nmea.hpp:799
NMEA-Gx-GST message payload.
Definition nmea.hpp:750
NmeaFloat angle_major
Angle of semi-major axis of error ellipse from true North.
Definition nmea.hpp:755
NmeaFloat std_lat
Standard deviation of latitude error.
Definition nmea.hpp:756
NmeaFloat std_alt
Standard deviation of altitude error.
Definition nmea.hpp:758
static constexpr const char * FORMATTER
Formatter.
Definition nmea.hpp:762
NmeaFloat std_lon
Standard deviation of longitude error.
Definition nmea.hpp:757
NmeaFloat std_major
Standard deviation of semi-major axis of error ellipse.
Definition nmea.hpp:753
NmeaFloat rms_range
RMS value of the standard deviation of the range inputs to the navigation process.
Definition nmea.hpp:752
NmeaFloat std_minor
Standard deviation of semi-minor axis of error ellipse.
Definition nmea.hpp:754
bool SetFromMsg(const uint8_t *msg, const std::size_t msg_size) final
Set data from message.
NMEA-Gx-GSV message payload (NMEA 4.11 only!).
Definition nmea.hpp:815
int num_azels
Number of valid satellite positions (the first n of azels[]).
Definition nmea.hpp:820
NmeaInt tot_num_sat
Number of sat/sig info in the whole sequence of GSV messages.
Definition nmea.hpp:818
NmeaInt num_msgs
Number of messages in this GSV sequence (for this signal ID).
Definition nmea.hpp:816
NmeaInt msg_num
Message number in sequence (1...num_msgs).
Definition nmea.hpp:817
std::array< NmeaAzEl, 4 > azels
Satellite positions, valid ones are 0..(num_sats-1).
Definition nmea.hpp:819
bool SetFromMsg(const uint8_t *msg, const std::size_t msg_size) final
Set data from message.
std::array< NmeaCno, 4 > cnos
Signal levels, valid ones are 0..(num_sats-1).
Definition nmea.hpp:821
int num_cnos
Number of valid signal levels (the first n of azels[]).
Definition nmea.hpp:822
static constexpr const char * FORMATTER
Formatter.
Definition nmea.hpp:828
NMEA-Gx-HDT message payload.
Definition nmea.hpp:769
static constexpr const char * FORMATTER
Formatter.
Definition nmea.hpp:774
bool SetFromMsg(const uint8_t *msg, const std::size_t msg_size) final
Set data from message.
NMEA geodetic position.
Definition nmea.hpp:558
double height
Ellipsoidal (!) height [m].
Definition nmea.hpp:563
bool latlon_valid
Latitude/longitude is valid.
Definition nmea.hpp:559
double lon
Longitude [deg], >= 0.0 North, < 0.0 South.
Definition nmea.hpp:561
double lat
Latitude [deg], >= 0.0 East, < 0.0 West.
Definition nmea.hpp:560
bool height_valid
Height is valid.
Definition nmea.hpp:562
char talker_[3]
Talker ID (for example, "GP", "GN" or "P"), nul-terminated string.
Definition nmea.hpp:107
char formatter_[20]
Formatter (for example, "GGA", "RMC", or "UBX"), nul-terminated string.
Definition nmea.hpp:108
int payload_ix1_
Index (offset) for end of payload, 0 if no payload available.
Definition nmea.hpp:110
int payload_ix0_
Index (offset) for start of payload, 0 if no payload available.
Definition nmea.hpp:109
NMEA payload base class.
Definition nmea.hpp:646
virtual bool SetFromMsg(const uint8_t *msg, const std::size_t msg_size)=0
Set data from message.
bool valid_
Payload successfully decoded (true), or not (yet) decoded (false).
Definition nmea.hpp:649
bool SetFromBuf(const std::vector< uint8_t > &buf)
Set data from message.
Definition nmea.hpp:671
virtual ~NmeaPayload()=default
Virtual dtor for polymorphism.
NmeaFormatter formatter_
Formatter.
Definition nmea.hpp:648
NMEA-Gx-RMC message payload.
Definition nmea.hpp:715
NmeaStatusGllRmc status
Positioning system status.
Definition nmea.hpp:717
NmeaLlh ll
Position (no height).
Definition nmea.hpp:718
NmeaNavStatusRmc navstatus
Navigational status (optional).
Definition nmea.hpp:723
static constexpr const char * FORMATTER
Formatter.
Definition nmea.hpp:727
NmeaModeRmcGns mode
Positioning system mode indicator.
Definition nmea.hpp:722
NmeaFloat speed
Speed over ground [knots].
Definition nmea.hpp:719
bool SetFromMsg(const uint8_t *msg, const std::size_t msg_size) final
Set data from message.
NmeaFloat course
Course over ground w.r.t. True North [deg].
Definition nmea.hpp:720
NMEA satellite (used, e.g. in GSA).
Definition nmea.hpp:570
int svid
Satellite ID (numbering cf. NMEA 0183).
Definition nmea.hpp:573
NmeaSystemId system
System ID.
Definition nmea.hpp:572
NMEA time (hour, minutes, seconds).
Definition nmea.hpp:530
bool operator==(const NmeaTime &rhs) const
Equal.
bool operator!=(const NmeaTime &rhs) const
Not equal.
Constants for different versions of NMEA.
Definition nmea.hpp:580
const int svid_max_glo
Max GLONASS satellite ID.
Definition nmea.hpp:590
const int svid_max_gps
Max GPS satellite ID.
Definition nmea.hpp:582
const int svid_min_sbas
Min SBAS satellite ID.
Definition nmea.hpp:583
const int svid_min_bds
Min BeiDou satellite ID.
Definition nmea.hpp:587
const int svid_min_navic
Min NavIC satellite ID, -1 if not available.
Definition nmea.hpp:593
static const NmeaVersion V410
Value for NMEA v4.10.
Definition nmea.hpp:595
const int svid_max_qzss
Max QZSS satellite ID, -1 if not available.
Definition nmea.hpp:592
const int svid_min_qzss
Min QZSS satellite ID, -1 if not available.
Definition nmea.hpp:591
const int svid_min_gps
Min GPS satellite ID.
Definition nmea.hpp:581
const int svid_min_gal
Min Galileo satellite ID.
Definition nmea.hpp:585
const int svid_max_gal
Max Galileo satellite ID.
Definition nmea.hpp:586
const int svid_max_sbas
Max SBAS satellite ID.
Definition nmea.hpp:584
static const NmeaVersion V410_UBX_EXT
Value for NMEA v4.10 extended (u-blox flavour).
Definition nmea.hpp:596
const int svid_max_navic
Max NavIC satellite ID, -1 if not available.
Definition nmea.hpp:594
const int svid_min_glo
Min GLONASS satellite ID.
Definition nmea.hpp:589
static const NmeaVersion V411
Value for NMEA v4.11.
Definition nmea.hpp:597
const int svid_max_bds
Max BeiDou satellite ID.
Definition nmea.hpp:588
NMEA-Gx-VTG message payload.
Definition nmea.hpp:734
NmeaFloat cogt
Course over ground (true) [deg].
Definition nmea.hpp:735
NmeaModeVtg mode
Positioning system mode.
Definition nmea.hpp:739
bool SetFromMsg(const uint8_t *msg, const std::size_t msg_size) final
Set data from message.
NmeaFloat sogk
Speed over ground [km/h].
Definition nmea.hpp:738
static constexpr const char * FORMATTER
Talker.
Definition nmea.hpp:743
NmeaFloat sogn
Speed over ground [knots].
Definition nmea.hpp:737
NmeaFloat cogm
Course over ground (magnetic) [deg], not typically available.
Definition nmea.hpp:736
NMEA-Gx-ZDA message payload.
Definition nmea.hpp:781
NmeaInt local_hr
Local zone hours, always 00 (= UTC).
Definition nmea.hpp:784
static constexpr const char * FORMATTER
Formatter.
Definition nmea.hpp:789
bool SetFromMsg(const uint8_t *msg, const std::size_t msg_size) final
Set data from message.
NmeaInt local_min
Local zone minutes, always 00 (= UTC).
Definition nmea.hpp:785