1 #ifndef MARNAV_NMEA_GSV_HPP
2 #define MARNAV_NMEA_GSV_HPP
5 #include <marnav/nmea/sentence.hpp>
6 #include <marnav/utils/optional.hpp>
12 /// @brief GSV - Satellites in view
14 /// These sentences describe the sky position of a UPS satellite in view. Typically they’re
15 /// shipped in a group of 2 or 3.
20 /// $--GSV,x,x,x,x,x,x,x,...*hh<CR><LF>
24 /// 1. Total number of GSV messages to be transmitted in this group
25 /// 2. 1-origin number of this GSV message within current group
26 /// 3. Total number of satellites in view (leading zeros sent)
27 /// 4. Satellite PRN (pseudo random noise) number (leading zeros sent)
28 /// 5. Elevation in degrees (00-90) (leading zeros sent)
29 /// 6. Azimuth in degrees to true north (000-359) (leading zeros sent)
30 /// 7. SNR (signal to noise ratio) in dB (00-99) (leading zeros sent),
31 /// apparently this may be not defined.
34 /// after 7: more satellite info quadruples like 4-7
38 /// $GPGSV,3,1,11,03,03,111,00,04,15,270,00,06,01,010,00,13,06,292,00*74
39 /// $GPGSV,3,2,11,14,25,170,00,16,57,208,39,18,67,296,40,19,40,246,00*74
40 /// $GPGSV,3,3,11,22,42,067,42,24,14,311,43,27,05,244,00,,,,*4D
43 /// @note Although null fields for unused satellite info are not required,
44 /// this class will write them in any case.
45 class gsv
: public sentence
47 friend class detail::factory
;
50 struct satellite_info
{
53 uint32_t azimuth
; // azimuth against true
54 utils::optional
<uint32_t> snr
;
57 constexpr static sentence_id ID
= sentence_id::GSV
;
58 constexpr static const char * TAG
= "GSV";
61 gsv(const gsv
&) = default;
62 gsv
& operator=(const gsv
&) = default;
63 gsv(gsv
&&) = default;
64 gsv
& operator=(gsv
&&) = default;
67 gsv(talker talk
, fields::const_iterator first
, fields::const_iterator last
);
68 virtual void append_data_to(std::string
&) const override
;
71 uint32_t n_messages_
= 1;
72 uint32_t message_number_
= 1;
73 uint32_t n_satellites_in_view_
= 0;
74 std::array
<utils::optional
<satellite_info
>, 4> sat_
;
76 void check_index(int index
) const;
79 uint32_t get_n_messages() const { return n_messages_
; }
80 uint32_t get_message_number() const { return message_number_
; }
81 uint32_t get_n_satellites_in_view() const { return n_satellites_in_view_
; }
82 utils::optional
<satellite_info
> get_sat(int index
) const;
84 void set_n_messages(uint32_t t
);
85 void set_message_number(uint32_t t
);
86 void set_n_satellites_in_view(uint32_t t
) noexcept
{ n_satellites_in_view_
= t
; }
87 void set_sat(int index
, const satellite_info
& info
);