1 #ifndef __NMEA__VDM__HPP__
2 #define __NMEA__VDM__HPP__
4 #include <marnav/nmea/sentence.hpp>
5 #include <marnav/utils/optional.hpp>
11 MARNAV_NMEA_DECLARE_SENTENCE_PARSE_FUNC(vdm
)
13 /// @brief VDM - AIS VHF Data-Link Message
18 /// $--VDM,x,x,x,a,s--s,x*hh<CR><LF>
22 /// 1. Number of fragments
23 /// 2. Fragment number
24 /// 3. Sequence Message ID
28 /// 5. Payload, 6-bit encoded content, max. 63 characters
29 /// 6. Number of fill bits (0..5)
31 class vdm
: public sentence
33 MARNAV_NMEA_SENTENCE_FRIENDS(vdm
)
36 constexpr static const sentence_id ID
= sentence_id::VDM
;
37 constexpr static const char * TAG
= "VDM";
40 vdm(const vdm
&) = default;
41 vdm
& operator=(const vdm
&) = default;
42 vdm(vdm
&&) = default;
43 vdm
& operator=(vdm
&&) = default;
46 vdm(sentence_id id
, const std::string
& tag
, const std::string
& talker
);
47 vdm(const std::string
& talker
, fields::const_iterator first
, fields::const_iterator last
);
49 virtual std::vector
<std::string
> get_data() const override
;
50 virtual char get_start_token() const override
{ return start_token_ais
; }
52 void read_fields(fields::const_iterator first
);
55 uint32_t n_fragments
= 0;
56 uint32_t fragment
= 0;
57 utils::optional
<uint32_t> seq_msg_id
;
58 utils::optional
<ais_channel
> radio_channel
; // A = 161.975MHz (87B), B = 162.025MHz (88B)
59 std::string payload
; // 6bit encoded content
60 uint32_t n_fill_bits
= 0; // 0..5
63 MARNAV_NMEA_GETTER(n_fragments
)
64 MARNAV_NMEA_GETTER(fragment
)
65 MARNAV_NMEA_GETTER(seq_msg_id
)
66 MARNAV_NMEA_GETTER(radio_channel
)
67 MARNAV_NMEA_GETTER(payload
)
68 MARNAV_NMEA_GETTER(n_fill_bits
)
70 void set_n_fragments(uint32_t t
) noexcept
{ n_fragments
= t
; }
71 void set_fragment(uint32_t t
) noexcept
{ fragment
= t
; }
72 void set_seq_msg_id(uint32_t t
) { seq_msg_id
= t
; }
73 void set_radio_channel(ais_channel channel
) noexcept
{ radio_channel
= channel
; }
74 void set_payload(const std::string
& data
, uint32_t fill_bits
) noexcept
77 n_fill_bits
= fill_bits
;
79 void set_payload(const std::pair
<std::string
, uint32_t> & data
)
81 set_payload(data
.first
, data
.second
);